<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" href="{{ asset('images/favicon-admin.png') }}" type="image/png">
    <title>@yield('title', 'Dashboard') - Admin MJM AC Mobil</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <style>
        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
        
        :root {
            --red: #C0392B;
            --maroon: #800020;
            --sidebar-bg: #1A0000;
            --sidebar-width: 260px;
        }

        body { font-family: 'Plus Jakarta Sans', sans-serif; background: #F3F4F6; color: #1A1A1A; min-height: 100vh; display: flex; }

        /* Sidebar */
        .sidebar {
            width: var(--sidebar-width);
            background: var(--sidebar-bg);
            min-height: 100vh;
            position: fixed;
            left: 0; top: 0; bottom: 0;
            display: flex;
            flex-direction: column;
            z-index: 100;
            transition: transform 0.3s ease;
        }

        .sidebar-header {
            padding: 24px 20px;
            border-bottom: 1px solid rgba(255,255,255,0.07);
        }

        .sidebar-logo {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .sidebar-logo img {
            height: 40px;
            object-fit: contain;
            filter: brightness(0) invert(1);
        }

        .sidebar-logo-text { font-weight: 800; color: white; font-size: 1rem; }
        .sidebar-logo-sub { font-size: 0.62rem; color: rgba(255,255,255,0.4); letter-spacing: 0.1em; text-transform: uppercase; }

        .sidebar-nav {
            flex: 1;
            padding: 16px 0;
        }

        .nav-group-label {
            font-size: 0.65rem;
            font-weight: 700;
            letter-spacing: 0.12em;
            text-transform: uppercase;
            color: rgba(255,255,255,0.3);
            padding: 8px 20px;
            margin-top: 8px;
        }

        .sidebar-link {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 20px;
            color: rgba(255,255,255,0.65);
            text-decoration: none;
            font-size: 0.88rem;
            font-weight: 500;
            transition: all 0.2s;
            border-left: 3px solid transparent;
        }

        .sidebar-link:hover {
            background: rgba(255,255,255,0.06);
            color: white;
        }

        .sidebar-link.active {
            background: rgba(192,57,43,0.2);
            color: white;
            border-left-color: var(--red);
        }

        .sidebar-link .icon { font-size: 1.1rem; width: 22px; text-align: center; }

        .sidebar-footer {
            padding: 16px 20px;
            border-top: 1px solid rgba(255,255,255,0.07);
        }

        .logout-btn {
            display: flex;
            align-items: center;
            gap: 12px;
            width: 100%;
            padding: 10px 12px;
            background: rgba(192,57,43,0.2);
            border: 1px solid rgba(192,57,43,0.3);
            color: #FF8080;
            border-radius: 10px;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            font-family: inherit;
            transition: all 0.2s;
            text-decoration: none;
        }

        .logout-btn:hover { background: rgba(192,57,43,0.4); }

        /* Main Content */
        .main-content {
            margin-left: var(--sidebar-width);
            flex: 1;
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

        /* Topbar */
        .topbar {
            background: white;
            padding: 16px 32px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-shadow: 0 1px 8px rgba(0,0,0,0.06);
            position: sticky;
            top: 0;
            z-index: 50;
        }

        .topbar-title {
            font-size: 1.2rem;
            font-weight: 700;
            color: #1A1A1A;
        }

        .topbar-user {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: linear-gradient(135deg, #C0392B, #800020);
            color: white;
            font-weight: 700;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.9rem;
        }

        .user-name { font-size: 0.88rem; font-weight: 600; }

        /* Page Content */
        .page-content {
            padding: 32px;
            flex: 1;
        }

        /* Alert */
        .alert-success {
            background: rgba(74,222,128,0.1);
            border: 1px solid rgba(74,222,128,0.3);
            color: #059669;
            padding: 12px 20px;
            border-radius: 12px;
            margin-bottom: 24px;
            font-size: 0.9rem;
        }

        /* Cards */
        .card {
            background: white;
            border-radius: 16px;
            box-shadow: 0 2px 12px rgba(0,0,0,0.06);
            overflow: hidden;
        }

        .card-header {
            padding: 20px 24px;
            border-bottom: 1px solid #F0F0F0;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .card-header h3 {
            font-size: 1rem;
            font-weight: 700;
        }

        .card-body { padding: 24px; }

        /* Tabs */
        .tabs {
            display: flex;
            gap: 4px;
            background: #F3F4F6;
            padding: 4px;
            border-radius: 10px;
            margin-bottom: 28px;
        }

        .tab-btn {
            flex: 1;
            padding: 10px 16px;
            border: none;
            background: transparent;
            border-radius: 8px;
            font-family: inherit;
            font-size: 0.85rem;
            font-weight: 600;
            color: #6B7280;
            cursor: pointer;
            transition: all 0.2s;
        }

        .tab-btn.active {
            background: white;
            color: var(--red);
            box-shadow: 0 1px 6px rgba(0,0,0,0.1);
        }

        .tab-panel { display: none; }
        .tab-panel.active { display: block; }

        /* Form */
        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            font-size: 0.82rem;
            font-weight: 600;
            color: #374151;
            margin-bottom: 6px;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .form-control {
            width: 100%;
            padding: 10px 14px;
            border: 1.5px solid #E5E7EB;
            border-radius: 10px;
            font-size: 0.9rem;
            font-family: inherit;
            color: #1A1A1A;
            transition: all 0.2s;
            outline: none;
        }

        .form-control:focus {
            border-color: var(--red);
            box-shadow: 0 0 0 3px rgba(192,57,43,0.1);
        }

        textarea.form-control { min-height: 100px; resize: vertical; }

        .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
        .form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

        /* Image upload */
        .upload-area {
            border: 2px dashed #E5E7EB;
            border-radius: 12px;
            padding: 24px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
        }

        .upload-area:hover { border-color: var(--red); background: rgba(192,57,43,0.03); }

        .upload-preview {
            max-width: 200px;
            max-height: 120px;
            object-fit: contain;
            border-radius: 8px;
            margin-bottom: 12px;
        }

        /* Buttons */
        .btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 10px 20px;
            border-radius: 10px;
            font-family: inherit;
            font-size: 0.88rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            border: none;
            text-decoration: none;
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--red), var(--maroon));
            color: white;
        }

        .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(192,57,43,0.3); }

        .btn-danger {
            background: rgba(239,68,68,0.1);
            color: #EF4444;
        }

        .btn-danger:hover { background: #EF4444; color: white; }

        .btn-sm { padding: 7px 14px; font-size: 0.8rem; }

        /* Table */
        .table { width: 100%; border-collapse: collapse; }
        .table th { padding: 12px 16px; text-align: left; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #9CA3AF; border-bottom: 1px solid #F0F0F0; }
        .table td { padding: 14px 16px; border-bottom: 1px solid #F9F9F9; font-size: 0.88rem; vertical-align: middle; }
        .table tr:hover td { background: #FAFAFA; }

        .stars { color: #F59E0B; font-size: 0.85rem; }
        .badge { display: inline-block; padding: 3px 10px; border-radius: 50px; font-size: 0.75rem; font-weight: 600; }
        .badge-green { background: rgba(74,222,128,0.1); color: #059669; }
        .badge-gray { background: #F3F4F6; color: #6B7280; }

        /* JSON Editor */
        .json-items { display: flex; flex-direction: column; gap: 16px; }

        .json-item {
            border: 1px solid #E5E7EB;
            border-radius: 12px;
            padding: 20px;
            position: relative;
        }

        .json-item-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 16px;
        }

        .json-item-title { font-weight: 700; font-size: 0.9rem; }

        /* Modal */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.5);
            backdrop-filter: blur(4px);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            padding: 24px;
        }

        .modal-overlay.open { display: flex; }

        .modal {
            background: white;
            border-radius: 20px;
            padding: 32px;
            width: 100%;
            max-width: 560px;
            box-shadow: 0 40px 80px rgba(0,0,0,0.3);
        }

        .modal-title {
            font-size: 1.2rem;
            font-weight: 700;
            margin-bottom: 24px;
        }

        .form-actions {
            display: flex;
            gap: 12px;
            justify-content: flex-end;
            margin-top: 24px;
            padding-top: 20px;
            border-top: 1px solid #F0F0F0;
        }

        @media (max-width: 768px) {
            .sidebar { transform: translateX(-100%); }
            .main-content { margin-left: 0; }
            .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
        }
    </style>
</head>
<body>
    <!-- Sidebar -->
    <aside class="sidebar">
        <div class="sidebar-header">
            <div class="sidebar-logo">
                <img src="{{ \App\Models\SiteSetting::get('logo', '/images/logo_mjm.png') }}" alt="Logo">
                <div>
                    <div class="sidebar-logo-text">{{ \App\Models\SiteSetting::get('site_name', 'MJM AC MOBIL') }}</div>
                    <div class="sidebar-logo-sub">Admin Panel</div>
                </div>
            </div>
        </div>

        <nav class="sidebar-nav">
            <div class="nav-group-label">Menu Utama</div>
            <a href="{{ route('admin.dashboard') }}" class="sidebar-link {{ request()->routeIs('admin.dashboard') ? 'active' : '' }}">
                <span class="icon">🏠</span> Dashboard
            </a>
            <a href="{{ route('admin.testimonials') }}" class="sidebar-link {{ request()->routeIs('admin.testimonials') ? 'active' : '' }}">
                <span class="icon">⭐</span> Testimoni
            </a>
            <div class="nav-group-label">Lainnya</div>
            <a href="/" class="sidebar-link" target="_blank">
                <span class="icon">🌐</span> Lihat Website
            </a>
        </nav>

        <div class="sidebar-footer">
            <form action="{{ route('logout') }}" method="POST">
                @csrf
                <button type="submit" class="logout-btn">
                    🚪 Keluar
                </button>
            </form>
        </div>
    </aside>

    <!-- Main -->
    <div class="main-content">
        <header class="topbar">
            <div class="topbar-title">@yield('page-title', 'Dashboard')</div>
            <div class="topbar-user">
                <div class="user-avatar">{{ strtoupper(substr(auth()->user()->name ?? 'A', 0, 1)) }}</div>
                <span class="user-name">{{ auth()->user()->name ?? 'Admin' }}</span>
            </div>
        </header>

        <main class="page-content">
            @if(session('success'))
            <div class="alert-success">✅ {{ session('success') }}</div>
            @endif

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