'use client';

import { useGameStore } from '@/stores/gameStore';
import { Header } from './Header';
import { SidebarLeft } from './SidebarLeft';
import { SidebarRight } from './SidebarRight';
import { Footer } from './Footer';

interface GameLayoutProps {
  children: React.ReactNode;
}

/**
 * 5-Zone Game Layout
 * ┌──────────────────────────────────┐
 * │            HEADER                │
 * ├────────┬──────────────┬──────────┤
 * │SIDEBAR │    MAIN      │ SIDEBAR  │
 * │  LEFT  │   (center)   │  RIGHT   │
 * │        │  ratio 1:3:1 │          │
 * ├────────┴──────────────┴──────────┤
 * │            FOOTER                │
 * └──────────────────────────────────┘
 */
export function GameLayout({ children }: GameLayoutProps) {
  const { uiVisibility } = useGameStore();

  return (
    <div className="h-screen flex flex-col overflow-hidden" style={{ background: 'var(--bg-primary)' }}>
      {/* HEADER */}
      <Header />

      {/* MIDDLE: Sidebars + Main */}
      <div className="flex flex-1 overflow-hidden">
        {/* SIDEBAR LEFT */}
        {uiVisibility.sidebar_left && (
          <aside
            className="shrink-0 overflow-y-auto"
            style={{
              width: 'var(--sidebar-width)',
              background: 'var(--bg-panel)',
              borderRight: '1px solid var(--border-dark)',
            }}
          >
            <SidebarLeft />
          </aside>
        )}

        {/* MAIN CENTER */}
        <main className="flex-1 overflow-y-auto overflow-x-hidden relative">
          {children}
        </main>

        {/* SIDEBAR RIGHT */}
        {uiVisibility.sidebar_right && (
          <aside
            className="shrink-0 overflow-y-auto"
            style={{
              width: 'var(--sidebar-width)',
              background: 'var(--bg-panel)',
              borderLeft: '1px solid var(--border-dark)',
            }}
          >
            <SidebarRight />
          </aside>
        )}
      </div>

      {/* FOOTER */}
      <Footer />
    </div>
  );
}
