'use client';

import { useGameStore } from '@/stores/gameStore';
import { t } from '@/lib/i18n';
import {
  User, Target, Briefcase, Package, Users, MessageSquare
} from 'lucide-react';

const TABS = [
  { id: 'profile', icon: User, labelKey: 'sidebar.profile' },
  { id: 'missions', icon: Target, labelKey: 'sidebar.missions' },
  { id: 'employment', icon: Briefcase, labelKey: 'sidebar.employment' },
  { id: 'inventory', icon: Package, labelKey: 'sidebar.inventory' },
  { id: 'multiplayer', icon: Users, labelKey: 'sidebar.multiplayer' },
  { id: 'chat', icon: MessageSquare, labelKey: 'sidebar.chat' },
] as const;

export function SidebarLeft() {
  const { activeSidebarLeftTab, setSidebarLeftTab, uiVisibility } = useGameStore();

  return (
    <div className="flex flex-col h-full">
      {/* Tab navigation */}
      <div
        className="flex border-b shrink-0 overflow-x-auto"
        style={{ borderColor: 'var(--border-dark)' }}
      >
        {TABS.map((tab) => {
          // Progressive disclosure: profile always visible, others only when unlocked
          if (tab.id !== 'profile') {
            const visKey = tab.id as keyof typeof uiVisibility;
            if (visKey in uiVisibility && !uiVisibility[visKey]) return null;
          }

          const Icon = tab.icon;
          const isActive = activeSidebarLeftTab === tab.id;

          return (
            <button
              key={tab.id}
              onClick={() => setSidebarLeftTab(tab.id)}
              className="flex-1 flex flex-col items-center gap-0.5 py-2 px-1 text-[10px] transition-colors relative"
              style={{
                color: isActive ? 'var(--color-gold)' : 'var(--text-muted)',
                background: isActive ? 'var(--bg-tertiary)' : 'transparent',
              }}
              title={t(tab.labelKey)}
            >
              <Icon size={16} />
              <span className="truncate w-full text-center">{t(tab.labelKey)}</span>
              {isActive && (
                <div
                  className="absolute bottom-0 left-0 right-0 h-[2px]"
                  style={{ background: 'var(--color-gold)' }}
                />
              )}
            </button>
          );
        })}
      </div>

      {/* Tab content */}
      <div className="flex-1 overflow-y-auto p-3">
        {activeSidebarLeftTab === 'profile' && (
          <div className="text-center py-4">
            <div
              className="w-16 h-16 rounded-full mx-auto mb-3 flex items-center justify-center text-2xl font-bold"
              style={{ background: 'var(--color-gold-dark)', color: 'var(--color-black)' }}
            >
              ?
            </div>
            <p className="text-sm" style={{ color: 'var(--text-secondary)' }}>
              {t('onboarding.welcome')}
            </p>
          </div>
        )}

        {activeSidebarLeftTab === 'missions' && (
          <div className="text-center py-8">
            <Target size={32} style={{ color: 'var(--text-muted)' }} className="mx-auto mb-2" />
            <p className="text-xs" style={{ color: 'var(--text-muted)' }}>
              {t('sidebar.missions')}
            </p>
          </div>
        )}

        {/* Other tabs show placeholder when no content yet */}
        {!['profile', 'missions'].includes(activeSidebarLeftTab) && (
          <div className="text-center py-8">
            <p className="text-xs" style={{ color: 'var(--text-muted)' }}>
              {t(`sidebar.${activeSidebarLeftTab}`)}
            </p>
          </div>
        )}
      </div>
    </div>
  );
}
