import React from 'react';

type Page = 'dashboard' | 'settings';

interface LayoutProps {
    children: React.ReactNode;
    currentPage: Page;
    onNavigate: (page: Page) => void;
}

export function Layout({ children, currentPage, onNavigate }: LayoutProps) {
    return (
        <div className="flex h-screen bg-neutral-900 text-white overflow-hidden font-sans">
            <aside className="w-64 bg-neutral-950 border-r border-neutral-800 flex flex-col pt-10">
                <div className="px-6 mb-8">
                    <h1 className="text-xl font-bold tracking-tight bg-gradient-to-br from-indigo-400 to-purple-400 bg-clip-text text-transparent">
                        Antigravity
                    </h1>
                    <p className="text-xs text-neutral-500 mt-1">System Optimizer</p>
                </div>

                <nav className="flex-1 px-4 space-y-1">
                    <NavItem
                        isActive={currentPage === 'dashboard'}
                        onClick={() => onNavigate('dashboard')}
                        icon="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"
                        label="Dashboard"
                    />
                    <NavItem
                        isActive={currentPage === 'settings'}
                        onClick={() => onNavigate('settings')}
                        icon="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
                        label="Settings"
                    />
                </nav>

                <div className="p-4 border-t border-neutral-800">
                    <div className="flex items-center gap-3">
                        <div className="w-8 h-8 rounded-full bg-indigo-500/20 border border-indigo-500/30 flex items-center justify-center text-indigo-400 text-xs font-bold">
                            KV
                        </div>
                        <div className="text-sm">
                            <div className="font-medium text-neutral-200">Dev Mode</div>
                            <div className="text-xs text-neutral-500">v0.1.0</div>
                        </div>
                    </div>
                </div>
            </aside>

            <main className="flex-1 bg-neutral-900 overflow-y-auto">
                {children}
            </main>
        </div>
    );
}

function NavItem({ isActive, onClick, icon, label }: any) {
    return (
        <button
            onClick={onClick}
            className={`w-full flex items-center gap-3 px-3 py-2 rounded-md text-sm font-medium transition-all duration-200
        ${isActive
                    ? 'bg-white/10 text-white shadow-sm'
                    : 'text-neutral-400 hover:text-white hover:bg-white/5'
                }`}
        >
            <svg className="w-5 h-5 opacity-70" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={icon} />
            </svg>
            {label}
        </button>
    );
}
