<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@yield('title', 'SuperAdmin Panel') - MyOpticals</title>
    <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <style>
        :root {
            --primary: #6366F1;
            --primary-dark: #4F46E5;
            --bg-dark: #090E17;
            --sidebar-bg: #111827;
            --card-bg: #1F2937;
            --border: rgba(255, 255, 255, 0.08);
            --text: #F9FAFB;
            --text-muted: #9CA3AF;
            --success: #10B981;
            --danger: #EF4444;
        }
        * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Outfit', sans-serif; }
        body { background: var(--bg-dark); color: var(--text); display: flex; min-height: 100vh; }

        /* Sidebar */
        aside {
            width: 260px; background: var(--sidebar-bg); border-right: 1px solid var(--border);
            display: flex; flex-direction: column; justify-content: space-between; padding: 1.5rem;
        }
        .logo { font-size: 1.4rem; font-weight: 800; display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; margin-bottom: 2rem; }
        .logo span { color: var(--primary); }
        .nav-menu { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
        .nav-link {
            display: flex; align-items: center; gap: 12px; padding: 0.75rem 1rem; border-radius: 12px;
            color: var(--text-muted); text-decoration: none; font-weight: 500; transition: 0.2s;
        }
        .nav-link:hover, .nav-link.active { background: rgba(99, 102, 241, 0.15); color: #fff; border-left: 3px solid var(--primary); }
        .nav-link i { font-size: 1.1rem; }

        /* Main Content */
        main { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
        header {
            padding: 1.2rem 2.5rem; background: rgba(17, 24, 39, 0.8); backdrop-filter: blur(10px);
            border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center;
        }
        .content { padding: 2.5rem; flex: 1; }

        /* Cards & Tables */
        .card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; margin-bottom: 1.5rem; }
        .grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
        .stat-card {
            background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem;
            display: flex; align-items: center; gap: 1.2rem;
        }
        .stat-icon {
            width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
            font-size: 1.4rem; background: rgba(99, 102, 241, 0.15); color: var(--primary);
        }
        .stat-val { font-size: 1.8rem; font-weight: 700; margin-top: 4px; }

        table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
        th, td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
        th { color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.5px; }

        .badge { display: inline-block; padding: 4px 10px; border-radius: 99px; font-size: 0.75rem; font-weight: 700; }
        .badge-success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
        .badge-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

        .btn {
            padding: 0.6rem 1.2rem; border-radius: 8px; font-weight: 600; text-decoration: none;
            display: inline-flex; align-items: center; gap: 8px; border: none; cursor: pointer; font-size: 0.9rem; transition: 0.2s;
        }
        .btn-primary { background: var(--primary); color: #fff; }
        .btn-primary:hover { background: var(--primary-dark); }
        .btn-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
        .btn-danger:hover { background: rgba(239, 68, 68, 0.4); }

        .alert-success { background: rgba(16, 185, 129, 0.2); border: 1px solid var(--success); color: #fff; padding: 1rem; border-radius: 12px; margin-bottom: 1.5rem; }

        input, select, textarea {
            width: 100%; padding: 0.75rem 1rem; background: #111827; border: 1px solid var(--border);
            border-radius: 8px; color: #fff; font-size: 0.95rem; margin-top: 6px; margin-bottom: 1rem;
        }
    </style>
</head>
<body>

    <!-- Sidebar -->
    <aside>
        <div>
            <a href="/admin/dashboard" class="logo">
                <i class="fa-solid fa-shield-halved"></i>
                <div>Super<span>Admin</span></div>
            </a>
            <ul class="nav-menu">
                <li><a href="/admin/dashboard" class="nav-link {{ request()->is('admin/dashboard') ? 'active' : '' }}"><i class="fa-solid fa-chart-line"></i> Dashboard</a></li>
                <li><a href="/admin/vendors" class="nav-link {{ request()->is('admin/vendors*') ? 'active' : '' }}"><i class="fa-solid fa-store"></i> Optical Vendors</a></li>
                <li><a href="/admin/packages" class="nav-link {{ request()->is('admin/packages*') ? 'active' : '' }}"><i class="fa-solid fa-box-open"></i> Packages</a></li>
                <li><a href="/admin/transactions" class="nav-link {{ request()->is('admin/transactions*') ? 'active' : '' }}"><i class="fa-solid fa-receipt"></i> Transactions</a></li>
                <li><a href="/admin/settings" class="nav-link {{ request()->is('admin/settings*') ? 'active' : '' }}"><i class="fa-solid fa-sliders"></i> Platform Settings</a></li>
                <li><a href="/" target="_blank" class="nav-link"><i class="fa-solid fa-globe"></i> View Website</a></li>
            </ul>
        </div>
        <div>
            <form action="{{ route('admin.logout') }}" method="POST">
                @csrf
                <button type="submit" class="btn btn-danger" style="width: 100%; justify-content: center;"><i class="fa-solid fa-arrow-right-from-bracket"></i> Logout</button>
            </form>
        </div>
    </aside>

    <!-- Main Section -->
    <main>
        <header>
            <h2>@yield('header_title', 'Dashboard')</h2>
            <div style="display: flex; align-items: center; gap: 15px;">
                <span style="font-weight: 600;">{{ Auth::user()->name }}</span>
                <div style="width: 36px; height: 36px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700;">A</div>
            </div>
        </header>

        <div class="content">
            @if(session('success'))
                <div class="alert-success">
                    <i class="fa-solid fa-circle-check"></i> {{ session('success') }}
                </div>
            @endif

            @yield('content')
        </div>
    </main>

</body>
</html>
