'use client';

import { usePathname, useRouter } from 'next/navigation';
import {
  LayoutDashboard,
  Users,
  Calendar,
  UserCog,
  FlaskConical,
  FileText,
  CreditCard
} from 'lucide-react';

const menu = [
  { name: 'Today', path: '/today', icon: LayoutDashboard },
  { name: 'Patients', path: '/patients', icon: Users },
  { name: 'Appointments', path: '/appointments', icon: Calendar },
  { name: 'Staff Management', path: '/staff', icon: UserCog },
  { name: 'Lab Management', path: '/lab', icon: FlaskConical },
  { name: 'Billing', path: '/billing', icon: CreditCard },
  { name: 'Reports', path: '/reports', icon: FileText },
];

export default function Sidebar() {
  const pathname = usePathname();
  const router = useRouter();

  return (
    <aside className="w-64 bg-background-secondary/90 border-r border-border text-text-primary flex flex-col p-4">
      <div className="mb-6 pb-4 border-b border-border">
        <h1 className="text-xl font-semibold tracking-tight">DyoLink</h1>
      </div>

      <nav className="flex flex-col gap-2">
        {menu.map((item) => {
          const Icon = item.icon;
          const isActive = pathname === item.path;

          return (
            <button
              key={item.name}
              onClick={() => router.push(item.path)}
              className={`flex items-center gap-3 px-3 py-2.5 rounded-[var(--radius-sm)] border transition-colors ${
                isActive
                  ? 'bg-primary-soft border-primary/60 text-text-primary'
                  : 'border-border/50 text-text-secondary hover:bg-background-card/70 hover:text-text-primary hover:border-border'
              }`}
            >
              <Icon className="w-[18px] h-[18px] icon-flat" />
              <span className="text-sm">{item.name}</span>
            </button>
          );
        })}
      </nav>
    </aside>
  );
}