<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@yield('title', 'Admin') — MUVR Labs</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <style>
        :root { --brand:#E5943C; --dark:#0f172a; }
        body { font-family:'Inter',system-ui,sans-serif; background:#f1f5f9; font-size:.88rem; }
        .sidebar { width:240px; min-height:100vh; background:var(--dark); position:fixed; top:0; left:0; z-index:100; overflow-y:auto; }
        .sidebar-brand { padding:1.25rem 1.5rem; border-bottom:1px solid rgba(255,255,255,.08); }
        .sidebar-brand .brand-text { font-size:1rem; font-weight:800; color:#fff; }
        .sidebar-brand .brand-text span { color:var(--brand); }
        .sidebar-brand .brand-sub { font-size:.68rem; color:#64748b; margin-top:2px; }
        .sidebar-nav { padding:1rem 0; }
        .nav-section { padding:.6rem 1.25rem .3rem; font-size:.65rem; font-weight:700; color:#475569; letter-spacing:1.5px; text-transform:uppercase; }
        .sidebar-link { display:flex; align-items:center; gap:.65rem; padding:.55rem 1.5rem; color:#94a3b8; text-decoration:none; font-size:.82rem; font-weight:500; transition:all .15s; }
        .sidebar-link:hover, .sidebar-link.active { color:#fff; background:rgba(255,255,255,.07); }
        .sidebar-link.active { color:var(--brand); border-left:3px solid var(--brand); }
        .sidebar-link i { width:18px; text-align:center; font-size:.95rem; }
        .main-content { margin-left:240px; min-height:100vh; }
        .topbar { background:#fff; border-bottom:1px solid #e2e8f0; padding:.75rem 1.5rem; display:flex; justify-content:space-between; align-items:center; position:sticky; top:0; z-index:50; }
        .topbar-title { font-size:1rem; font-weight:700; color:var(--dark); }
        .page-body { padding:1.5rem; }
        .card-admin { background:#fff; border:1px solid #e2e8f0; border-radius:10px; }
        .stat-card { background:#fff; border:1px solid #e2e8f0; border-radius:10px; padding:1.25rem; }
        .stat-number { font-size:1.8rem; font-weight:800; color:var(--dark); }
        .stat-label { font-size:.78rem; color:#64748b; }
        .badge-new { background:#fef9c3; color:#854d0e; }
        .btn-admin { background:var(--brand); color:#fff; border:none; font-size:.82rem; font-weight:600; }
        .btn-admin:hover { background:#d4832e; color:#fff; }
        .table th { font-size:.75rem; font-weight:700; color:#64748b; text-transform:uppercase; letter-spacing:.5px; border-bottom:2px solid #e2e8f0; }
        .table td { font-size:.82rem; vertical-align:middle; }
        .form-label { font-size:.8rem; font-weight:600; color:#374151; }
        .form-control, .form-select { font-size:.83rem; }
        .badge-status-new { background:#dbeafe; color:#1e40af; }
        .badge-status-read { background:#f0fdf4; color:#166534; }
        .badge-status-replied { background:#f0fdf4; color:#166534; }
        @media(max-width:768px){.sidebar{transform:translateX(-100%)}.main-content{margin-left:0}}
    </style>
    @stack('styles')
</head>
<body>

<!-- SIDEBAR -->
<aside class="sidebar">
    <div class="sidebar-brand">
        <div class="brand-text"><span>MUVR</span> Labs</div>
        <div class="brand-sub">Admin Panel</div>
    </div>
    <nav class="sidebar-nav">
        <div class="nav-section">Dashboard</div>
        <a href="{{ route('admin.dashboard') }}" class="sidebar-link {{ request()->routeIs('admin.dashboard') ? 'active' : '' }}">
            <i class="bi bi-speedometer2"></i> Dashboard
        </a>

        <div class="nav-section">Content</div>
        <a href="{{ route('admin.products.index') }}" class="sidebar-link {{ request()->routeIs('admin.products*') ? 'active' : '' }}">
            <i class="bi bi-box-seam"></i> Products
        </a>
        <a href="{{ route('admin.solutions.index') }}" class="sidebar-link {{ request()->routeIs('admin.solutions*') ? 'active' : '' }}">
            <i class="bi bi-lightbulb"></i> Solutions
        </a>
        <a href="{{ route('admin.case-studies.index') }}" class="sidebar-link {{ request()->routeIs('admin.case-studies*') ? 'active' : '' }}">
            <i class="bi bi-briefcase"></i> Case Studies
        </a>
        <a href="{{ route('admin.resources.index') }}" class="sidebar-link {{ request()->routeIs('admin.resources*') ? 'active' : '' }}">
            <i class="bi bi-folder2"></i> Resources
        </a>
        <a href="{{ route('admin.jobs.index') }}" class="sidebar-link {{ request()->routeIs('admin.jobs*') ? 'active' : '' }}">
            <i class="bi bi-person-badge"></i> Jobs
        </a>

        <div class="nav-section">Enquiries</div>
        <a href="{{ route('admin.enquiries.index') }}" class="sidebar-link {{ request()->routeIs('admin.enquiries*') ? 'active' : '' }}">
            <i class="bi bi-envelope"></i> Enquiries
            @php $newEnquiries = \App\Models\Enquiry::where('status','new')->count(); @endphp
            @if($newEnquiries > 0)<span class="badge badge-new ms-auto">{{ $newEnquiries }}</span>@endif
        </a>
        <a href="{{ route('admin.applications.index') }}" class="sidebar-link {{ request()->routeIs('admin.applications*') ? 'active' : '' }}">
            <i class="bi bi-file-person"></i> CV Applications
            @php $newApps = \App\Models\JobApplication::where('status','new')->count(); @endphp
            @if($newApps > 0)<span class="badge badge-new ms-auto">{{ $newApps }}</span>@endif
        </a>

        <div class="nav-section">Settings</div>
        <a href="{{ route('admin.settings') }}" class="sidebar-link {{ request()->routeIs('admin.settings') ? 'active' : '' }}">
            <i class="bi bi-gear"></i> Site Settings
        </a>
        <a href="{{ route('admin.hero') }}" class="sidebar-link {{ request()->routeIs('admin.hero') ? 'active' : '' }}">
            <i class="bi bi-image"></i> Hero Section
        </a>
        <a href="{{ route('admin.about') }}" class="sidebar-link {{ request()->routeIs('admin.about') ? 'active' : '' }}">
            <i class="bi bi-info-circle"></i> About Page
        </a>
        <a href="{{ route('admin.process') }}" class="sidebar-link {{ request()->routeIs('admin.process') ? 'active' : '' }}">
            <i class="bi bi-list-ol"></i> Process Steps
        </a>
        <a href="{{ route('admin.why-us') }}" class="sidebar-link {{ request()->routeIs('admin.why-us') ? 'active' : '' }}">
            <i class="bi bi-check2-circle"></i> Why Us Points
        </a>

        <div class="nav-section mt-3">Account</div>
        <a href="{{ route('home') }}" target="_blank" class="sidebar-link">
            <i class="bi bi-box-arrow-up-right"></i> View Site
        </a>
        <a href="{{ route('admin.logout') }}" class="sidebar-link" onclick="event.preventDefault();document.getElementById('logout-form').submit()">
            <i class="bi bi-box-arrow-left"></i> Logout
        </a>
        <form id="logout-form" action="{{ route('admin.logout') }}" method="POST" class="d-none">@csrf</form>
    </nav>
</aside>

<!-- MAIN -->
<div class="main-content">
    <div class="topbar">
        <div class="topbar-title">@yield('page-title', 'Dashboard')</div>
        <div class="d-flex align-items-center gap-3">
            <span style="font-size:.82rem;color:#64748b"><i class="bi bi-person-circle me-1"></i>{{ auth()->user()->name }}</span>
        </div>
    </div>
    <div class="page-body">
        @if(session('success'))
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            {{ session('success') }}
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
        @endif
        @if(session('error'))
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
            {{ session('error') }}
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
        @endif
        @yield('content')
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
@stack('scripts')
</body>
</html>
