Spaces:
Sleeping
Sleeping
File size: 11,073 Bytes
0f226f2 24cf0c4 0f226f2 ee111cd 88fa3b1 0f226f2 24cf0c4 ee111cd 0f226f2 24cf0c4 ee111cd 7782325 88fa3b1 7782325 88fa3b1 7782325 ee111cd 24cf0c4 ee111cd 0f226f2 7782325 0f226f2 7782325 ee111cd 0f226f2 7782325 0f226f2 7782325 0f226f2 ee111cd 0f226f2 7782325 0f226f2 7782325 0f226f2 7782325 ee111cd 7782325 0f226f2 7782325 0f226f2 7782325 0f226f2 7782325 0f226f2 ee111cd 7782325 ee111cd 7782325 ee111cd 7782325 ee111cd 7782325 ee111cd 7782325 ee111cd 7782325 ee111cd 0f226f2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | "use client";
import Link from "next/link";
import { usePathname, useRouter } from "next/navigation";
import { cn } from "@/lib/utils";
import { motion } from "framer-motion";
import {
LayoutDashboard, ArrowRightLeft, BarChart2, Wallet, Target,
MessageSquare, Settings, LogOut, Zap, Shield, Sparkles,
Activity, CreditCard, Sun, Moon, Globe,
} from "lucide-react";
import { useAuthStore } from "@/lib/stores/authStore";
import { useThemeStore } from "@/lib/stores/themeStore";
import { useLanguageStore, LANGUAGES, Language } from "@/lib/stores/languageStore";
import { useState } from "react";
export function Sidebar() {
const pathname = usePathname();
const router = useRouter();
const { logout } = useAuthStore();
const { theme, toggle } = useThemeStore();
const { language, setLanguage, t } = useLanguageStore();
const [showLang, setShowLang] = useState(false);
const navigation = [
{ key: "overview", href: "/", icon: LayoutDashboard },
{ key: "transactions", href: "/transactions", icon: ArrowRightLeft },
{ key: "payments", href: "/payments", icon: CreditCard, badge: "NEW" },
{ key: "analytics", href: "/analytics", icon: BarChart2 },
{ key: "simulator", href: "/simulator", icon: Zap },
{ key: "loans", href: "/loans", icon: Wallet },
{ key: "goals", href: "/goals", icon: Target },
{ key: "ai_assistant", href: "/chat", icon: MessageSquare, badge: "AI" },
{ key: "security", href: "/security", icon: Shield },
{ key: "system_status", href: "/status", icon: Activity },
{ key: "settings", href: "/settings", icon: Settings },
];
const handleLogout = () => { logout(); router.replace("/login"); };
const isLight = theme === "light";
return (
<div
className="flex h-full w-60 flex-col overflow-y-auto border-r text-sm backdrop-blur-2xl transition-colors duration-300"
style={{
background: "var(--sidebar-bg)",
borderColor: "var(--border)",
color: "var(--fg)",
}}
>
{/* ββ Logo βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */}
<div
className="flex h-16 shrink-0 items-center gap-2.5 px-5 border-b"
style={{ borderColor: "var(--border)" }}
>
<div className="flex h-8 w-8 items-center justify-center rounded-xl bg-gradient-to-br from-emerald-400 to-cyan-500 shadow-lg shadow-emerald-500/20">
<Sparkles className="h-4 w-4 text-white" />
</div>
<div>
<h1 className="text-base font-bold leading-tight" style={{ color: "var(--fg)" }}>
BankBot
</h1>
<p className="text-[10px] text-emerald-500 leading-tight">AI Finance</p>
</div>
</div>
{/* ββ Nav ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */}
<div className="flex flex-1 flex-col justify-between px-3 py-4">
<nav className="space-y-0.5">
{navigation.map((item) => {
const isActive = pathname === item.href;
return (
<Link
key={item.key}
href={item.href}
className={cn(
"group relative flex items-center rounded-xl px-3 py-2.5 font-medium transition-all duration-200",
isActive
? ""
: isLight
? "hover:bg-black/5"
: "hover:bg-white/5"
)}
style={{
color: isActive
? "var(--fg)"
: "var(--fg-subtle)",
}}
>
{/* Active background pill */}
{isActive && (
<motion.div
layoutId="activeNav"
className={cn(
"absolute inset-0 rounded-xl border",
isLight
? "bg-emerald-50 border-emerald-200/80"
: "bg-white/10 border-white/10"
)}
transition={{ type: "spring", bounce: 0.2, duration: 0.4 }}
/>
)}
{/* Active left accent */}
{isActive && (
<div className="absolute left-0 top-1/2 -translate-y-1/2 h-5 w-0.5 rounded-full bg-emerald-500" />
)}
<item.icon
className={cn(
"relative mr-3 h-4 w-4 flex-shrink-0 transition-colors",
isActive
? "text-emerald-500"
: isLight
? "text-slate-400 group-hover:text-slate-600"
: "text-zinc-500 group-hover:text-zinc-300"
)}
/>
<span className="relative flex-1">{t(item.key)}</span>
{item.badge && (
<span
className={cn(
"relative ml-auto rounded-md px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wide border",
item.badge === "AI"
? "bg-emerald-500/15 text-emerald-500 border-emerald-500/30"
: "bg-blue-500/15 text-blue-500 border-blue-500/30"
)}
>
{item.badge}
</span>
)}
</Link>
);
})}
</nav>
{/* ββ Bottom controls βββββββββββββββββββββββββββββββββββββββββββββββββ */}
<div
className="space-y-1 pt-4 border-t"
style={{ borderColor: "var(--border)" }}
>
{/* AI Shield status */}
<div
className={cn(
"flex items-center gap-2.5 rounded-xl px-3 py-2.5 border",
isLight
? "bg-emerald-50 border-emerald-200/80"
: "bg-emerald-500/5 border-emerald-500/10"
)}
>
<div className="h-1.5 w-1.5 rounded-full bg-emerald-400 animate-pulse flex-shrink-0" />
<div className="flex-1 min-w-0">
<p className="text-xs font-medium text-emerald-500 leading-tight">
{t("ai_shield")}
</p>
<p
className="text-[10px] leading-tight truncate"
style={{ color: "var(--fg-subtle)" }}
>
{t("all_normal")}
</p>
</div>
</div>
{/* Theme toggle */}
<button
onClick={toggle}
className={cn(
"flex w-full items-center rounded-xl px-3 py-2.5 font-medium transition-all duration-200",
isLight ? "hover:bg-black/5" : "hover:bg-white/5"
)}
style={{ color: "var(--fg-muted)" }}
>
{isLight
? <Sun className="mr-3 h-4 w-4 text-amber-500" />
: <Moon className="mr-3 h-4 w-4 text-indigo-400" />}
{isLight ? t("theme_light") : t("theme_dark")}
</button>
{/* Language switcher */}
<div className="relative">
<button
onClick={() => setShowLang(!showLang)}
className={cn(
"flex w-full items-center rounded-xl px-3 py-2.5 font-medium transition-all duration-200",
isLight ? "hover:bg-black/5" : "hover:bg-white/5",
showLang && (isLight ? "bg-black/5" : "bg-white/5")
)}
style={{ color: "var(--fg-muted)" }}
>
<Globe className="mr-3 h-4 w-4" />
<span className="flex-1 text-left">{LANGUAGES[language].native}</span>
<span className="text-base leading-none">{LANGUAGES[language].flag}</span>
</button>
{showLang && (
<motion.div
initial={{ opacity: 0, y: 4, scale: 0.97 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: 4, scale: 0.97 }}
transition={{ duration: 0.15 }}
className="absolute bottom-full left-0 right-0 mb-1.5 rounded-xl border overflow-hidden shadow-2xl z-50"
style={{
background: isLight ? "white" : "#18181b",
borderColor: "var(--border-strong)",
boxShadow: isLight
? "0 8px 32px rgba(15,23,42,0.12)"
: "0 8px 32px rgba(0,0,0,0.5)",
}}
>
{(Object.entries(LANGUAGES) as [Language, typeof LANGUAGES[Language]][]).map(
([code, info]) => (
<button
key={code}
onClick={() => { setLanguage(code); setShowLang(false); }}
className={cn(
"flex w-full items-center gap-3 px-3 py-2.5 text-sm transition-colors",
language === code
? isLight
? "bg-emerald-50 text-emerald-700"
: "bg-emerald-500/10 text-emerald-400"
: isLight
? "text-slate-600 hover:bg-slate-50"
: "text-zinc-300 hover:bg-white/5"
)}
>
<span className="text-base leading-none">{info.flag}</span>
<span className="flex-1 text-left font-medium">{info.native}</span>
<span
className="text-xs"
style={{ color: "var(--fg-subtle)" }}
>
{info.label}
</span>
{language === code && (
<span className="ml-1 text-emerald-500 text-xs">β</span>
)}
</button>
)
)}
</motion.div>
)}
</div>
{/* Sign out */}
<button
onClick={handleLogout}
className={cn(
"flex w-full items-center rounded-xl px-3 py-2.5 font-medium transition-all duration-200",
isLight
? "text-slate-500 hover:bg-red-50 hover:text-red-600"
: "text-zinc-500 hover:bg-red-500/10 hover:text-red-400"
)}
>
<LogOut className="mr-3 h-4 w-4 flex-shrink-0" />
{t("sign_out")}
</button>
</div>
</div>
</div>
);
}
|