<!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 Panel')</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" rel="stylesheet">

    @php
        $pagesMenuOpen = request()->routeIs('admin.pages.*');
    @endphp

    <style>
        :root{
            --ad-dark:#0f172a;
            --ad-dark-soft:#162033;
            --ad-dark-2:#1e293b;
            --ad-brand:#2563eb;
            --ad-brand-2:#7c3aed;
            --ad-success:#16a34a;
            --ad-bg:#f8fafc;
            --ad-card:#ffffff;
            --ad-border:#e2e8f0;
            --ad-text:#0f172a;
            --ad-muted:#64748b;
            --ad-danger:#dc2626;
            --ad-radius-xl:28px;
            --ad-radius-lg:22px;
            --ad-radius-md:16px;
            --ad-shadow:0 18px 45px rgba(15,23,42,.08);
        }

        *{
            box-sizing:border-box;
        }

        html,body{
            margin:0;
            padding:0;
            font-family:'Poppins',sans-serif;
            background:var(--ad-bg);
            color:var(--ad-text);
        }

        a{
            text-decoration:none;
        }

        button{
            font-family:inherit;
        }

        .ad_app{
            min-height:100vh;
            display:flex;
            background:
                radial-gradient(circle at top left, rgba(37,99,235,.05), transparent 28%),
                radial-gradient(circle at bottom right, rgba(124,58,237,.06), transparent 25%),
                var(--ad-bg);
        }

        .ad_sidebar{
            width:300px;
            flex-shrink:0;
            background:linear-gradient(180deg, var(--ad-dark) 0%, var(--ad-dark-soft) 45%, var(--ad-dark-2) 100%);
            color:#fff;
            padding:20px 16px;
            position:fixed;
            inset:0 auto 0 0;
            overflow-y:auto;
            z-index:1100;
            box-shadow:24px 0 60px rgba(15,23,42,.22);
        }

        .ad_sidebar::-webkit-scrollbar{
            width:8px;
        }

        .ad_sidebar::-webkit-scrollbar-thumb{
            background:rgba(255,255,255,.14);
            border-radius:999px;
        }

        .ad_brand{
            display:flex;
            align-items:center;
            gap:14px;
            padding:10px 10px 22px;
            margin-bottom:16px;
            border-bottom:1px solid rgba(255,255,255,.08);
        }

        .ad_brand_logo{
            width:58px;
            height:58px;
            border-radius:18px;
            background:linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,.04));
            display:flex;
            align-items:center;
            justify-content:center;
            overflow:hidden;
            flex-shrink:0;
            border:1px solid rgba(255,255,255,.08);
            box-shadow:0 12px 24px rgba(0,0,0,.15);
        }

        .ad_brand_logo img{
            width:100%;
            height:100%;
            object-fit:cover;
        }

        .ad_brand_logo i{
            font-size:22px;
            color:#fff;
        }

        .ad_brand_text strong{
            display:block;
            font-size:18px;
            line-height:1.2;
            color:#fff;
            font-weight:800;
        }

        .ad_brand_text span{
            display:block;
            margin-top:5px;
            font-size:12px;
            color:rgba(255,255,255,.62);
            font-weight:500;
        }

        .ad_group_title{
            font-size:11px;
            text-transform:uppercase;
            letter-spacing:.12em;
            color:rgba(255,255,255,.4);
            font-weight:800;
            padding:0 12px;
            margin:18px 0 10px;
        }

        .ad_sidebar_nav{
            list-style:none;
            margin:0;
            padding:0;
            display:flex;
            flex-direction:column;
            gap:8px;
        }

        .ad_sidebar_item{
            width:100%;
        }

        .ad_nav_link,
        .ad_nav_toggle{
            width:100%;
            display:flex;
            align-items:center;
            justify-content:space-between;
            gap:12px;
            padding:14px 14px;
            border:none;
            background:transparent;
            color:#dbe4f0;
            border-radius:16px;
            transition:all .25s ease;
            font-weight:700;
        }

        .ad_nav_link:hover,
        .ad_nav_toggle:hover{
            background:rgba(255,255,255,.07);
            color:#fff;
        }

        .ad_nav_link.ad_active,
        .ad_nav_toggle.ad_active{
            background:linear-gradient(135deg, rgba(37,99,235,.95), rgba(124,58,237,.88));
            color:#fff;
            box-shadow:0 14px 28px rgba(37,99,235,.18);
        }

        .ad_nav_left{
            display:flex;
            align-items:center;
            gap:12px;
            min-width:0;
        }

        .ad_nav_left i{
            width:18px;
            text-align:center;
            font-size:15px;
            flex-shrink:0;
        }

        .ad_nav_left span{
            white-space:nowrap;
            overflow:hidden;
            text-overflow:ellipsis;
        }

        .ad_nav_arrow{
            font-size:12px;
            transition:transform .25s ease;
            color:inherit;
        }

        .ad_sidebar_dropdown.ad_open .ad_nav_arrow{
            transform:rotate(180deg);
        }

        .ad_submenu{
            list-style:none;
            margin:8px 0 0;
            padding:0 0 0 16px;
            display:none;
        }

        .ad_sidebar_dropdown.ad_open .ad_submenu{
            display:block;
        }

        .ad_submenu li{
            margin-bottom:6px;
        }

        .ad_submenu a{
            display:flex;
            align-items:center;
            gap:10px;
            padding:11px 14px;
            border-radius:14px;
            color:#9fb0c8;
            font-weight:600;
            transition:all .25s ease;
            background:transparent;
        }

        .ad_submenu a::before{
            content:"";
            width:6px;
            height:6px;
            border-radius:999px;
            background:currentColor;
            opacity:.7;
            flex-shrink:0;
        }

        .ad_submenu a:hover{
            background:rgba(255,255,255,.06);
            color:#fff;
        }

        .ad_submenu a.ad_active{
            background:rgba(37,99,235,.18);
            color:#fff;
        }

        .ad_logout_wrap{
            margin-top:26px;
            padding:0 4px;
        }

        .ad_logout_btn{
            width:100%;
            border:0;
            border-radius:16px;
            padding:14px 18px;
            background:linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
            color:#fff;
            font-weight:700;
            display:inline-flex;
            align-items:center;
            justify-content:center;
            gap:10px;
            transition:all .25s ease;
            box-shadow:0 14px 28px rgba(220,38,38,.2);
        }

        .ad_logout_btn:hover{
            transform:translateY(-1px);
            opacity:.96;
        }

        .ad_main{
            flex:1;
            margin-left:300px;
            min-width:0;
        }

        .ad_topbar{
            position:sticky;
            top:0;
            z-index:1000;
            padding:20px 28px;
            border-bottom:1px solid var(--ad-border);
            background:rgba(248,250,252,.9);
            backdrop-filter:blur(14px);
        }

        .ad_topbar_inner{
            display:flex;
            align-items:center;
            justify-content:space-between;
            gap:18px;
        }

        .ad_page_heading h1{
            margin:0;
            font-size:30px;
            font-weight:800;
            line-height:1.1;
            color:var(--ad-text);
        }

        .ad_page_heading p{
            margin:7px 0 0;
            color:var(--ad-muted);
            font-size:14px;
            font-weight:500;
        }

        .ad_topbar_actions{
            display:flex;
            align-items:center;
            gap:12px;
            flex-wrap:wrap;
        }

        .ad_btn,
        .ad_btn_outline{
            display:inline-flex;
            align-items:center;
            justify-content:center;
            gap:10px;
            padding:12px 18px;
            border-radius:14px;
            font-weight:700;
            transition:all .25s ease;
        }

        .ad_btn{
            background:linear-gradient(135deg, var(--ad-brand) 0%, var(--ad-brand-2) 100%);
            color:#fff;
            border:0;
            box-shadow:0 14px 28px rgba(37,99,235,.16);
        }

        .ad_btn:hover{
            color:#fff;
            transform:translateY(-1px);
            opacity:.97;
        }

        .ad_btn_outline{
            background:#fff;
            color:var(--ad-text);
            border:1px solid var(--ad-border);
            box-shadow:0 8px 20px rgba(15,23,42,.04);
        }

        .ad_btn_outline:hover{
            color:var(--ad-text);
            border-color:#cbd5e1;
            transform:translateY(-1px);
        }

        .ad_page{
            padding:28px;
        }

        .ad_alert{
            border-radius:18px;
            padding:16px 18px;
            margin-bottom:22px;
            font-weight:700;
            border:1px solid transparent;
        }

        .ad_alert_success{
            background:#ecfdf3;
            color:#166534;
            border-color:#bbf7d0;
        }

        .ad_card{
            background:var(--ad-card);
            border:1px solid var(--ad-border);
            border-radius:var(--ad-radius-xl);
            box-shadow:var(--ad-shadow);
        }

        .ad_card_inner{
            padding:26px;
        }

        .ad_stat_card{
            height:100%;
        }

        .ad_stat_icon{
            width:58px;
            height:58px;
            border-radius:18px;
            background:linear-gradient(135deg, rgba(37,99,235,.12), rgba(124,58,237,.12));
            color:var(--ad-brand);
            display:flex;
            align-items:center;
            justify-content:center;
            font-size:22px;
            margin-bottom:18px;
        }

        .ad_stat_label{
            font-size:14px;
            color:var(--ad-muted);
            margin-bottom:8px;
            font-weight:600;
        }

        .ad_stat_value{
            font-size:36px;
            font-weight:800;
            line-height:1;
            color:var(--ad-text);
        }

        .ad_box{
            background:#fff;
            border:1px solid var(--ad-border);
            border-radius:22px;
            padding:22px;
            margin-bottom:22px;
            box-shadow:var(--ad-shadow);
        }

        .ad_box h3{
            margin:0 0 18px;
            font-size:22px;
            font-weight:700;
        }

        .ad_label{
            display:inline-block;
            margin-bottom:8px;
            font-size:14px;
            font-weight:700;
            color:#334155;
        }

        .ad_input,
        .ad_textarea,
        .ad_file{
            width:100%;
            border:1px solid #dbe2ea;
            border-radius:16px;
            background:#fff;
            padding:14px 16px;
            font-size:15px;
            outline:none;
            color:var(--ad-text);
            transition:all .25s ease;
        }

        .ad_input,
        .ad_file{
            min-height:52px;
        }

        .ad_textarea{
            min-height:140px;
            resize:vertical;
        }

        .ad_input:focus,
        .ad_textarea:focus,
        .ad_file:focus{
            border-color:#93c5fd;
            box-shadow:0 0 0 4px rgba(59,130,246,.10);
        }

        .ad_preview_logo{
            width:76px;
            height:76px;
            object-fit:cover;
            border-radius:16px;
            border:1px solid var(--ad-border);
            background:#fff;
            padding:4px;
        }

        .ad_small_card{
            border:1px solid var(--ad-border);
            border-radius:20px;
            padding:18px;
            background:#fff;
            height:100%;
        }

        .ad_small_card p:last-child{
            margin-bottom:0;
        }

        @media (max-width: 1199.98px){
            .ad_sidebar{
                width:280px;
            }

            .ad_main{
                margin-left:280px;
            }
        }

        @media (max-width: 991.98px){
            .ad_app{
                display:block;
            }

            .ad_sidebar{
                position:relative;
                inset:auto;
                width:100%;
                box-shadow:none;
                border-bottom-left-radius:24px;
                border-bottom-right-radius:24px;
            }

            .ad_main{
                margin-left:0;
            }

            .ad_topbar_inner{
                flex-direction:column;
                align-items:flex-start;
            }

            .ad_page,
            .ad_topbar{
                padding:20px;
            }
        }
    </style>

    @stack('ad_styles')
</head>
<body>
    <div class="ad_app">
        <aside class="ad_sidebar">
            <div class="ad_brand">
                <div class="ad_brand_logo">
                    @if($siteSettings?->logo)
                        <img src="{{ asset('storage/' . $siteSettings->logo) }}" alt="{{ $siteSettings->website_name }}">
                    @else
                        <i class="fa-solid fa-shield-halved"></i>
                    @endif
                </div>

                <div class="ad_brand_text">
                    <strong>{{ $siteSettings->website_name ?? 'Admin Panel' }}</strong>
                    <span>Management Area</span>
                </div>
            </div>

            <div class="ad_group_title">Main</div>

            <ul class="ad_sidebar_nav">
                <li class="ad_sidebar_item">
                    <a href="{{ route('admin.dashboard') }}" class="ad_nav_link {{ request()->routeIs('admin.dashboard') ? 'ad_active' : '' }}">
                        <span class="ad_nav_left">
                            <i class="fa-solid fa-gauge-high"></i>
                            <span>Dashboard</span>
                        </span>
                    </a>
                </li>
            </ul>

            <div class="ad_group_title">Website Content</div>

            <ul class="ad_sidebar_nav">
                <li class="ad_sidebar_item ad_sidebar_dropdown {{ $pagesMenuOpen ? 'ad_open' : '' }}">
                    <button type="button" class="ad_nav_toggle {{ $pagesMenuOpen ? 'ad_active' : '' }}" data-sidebar-toggle>
                        <span class="ad_nav_left">
                            <i class="fa-solid fa-file-lines"></i>
                            <span>Pages</span>
                        </span>
                        <i class="fa-solid fa-chevron-down ad_nav_arrow"></i>
                    </button>

                    <ul class="ad_submenu">
                        <li><a href="{{ route('admin.pages.index.edit') }}" class="{{ request()->routeIs('admin.pages.index.*') ? 'ad_active' : '' }}">Home</a></li>
                        <li><a href="{{ route('admin.pages.packages.edit') }}" class="{{ request()->routeIs('admin.pages.packages.*') ? 'ad_active' : '' }}">Packages</a></li>
                        <li><a href="{{ route('admin.pages.candidates-profiles.edit') }}" class="{{ request()->routeIs('admin.pages.candidates-profiles.*') ? 'ad_active' : '' }}">Candidates Profiles</a></li>
                        <li><a href="{{ route('admin.pages.profiles.edit') }}" class="{{ request()->routeIs('admin.pages.profiles.*') ? 'ad_active' : '' }}">Profiles</a></li>
                        <li><a href="{{ route('admin.pages.profile-details.edit') }}" class="{{ request()->routeIs('admin.pages.profile-details.*') ? 'ad_active' : '' }}">Profile Details</a></li>
                        <li><a href="{{ route('admin.pages.full-time-live-in.edit') }}" class="{{ request()->routeIs('admin.pages.full-time-live-in.*') ? 'ad_active' : '' }}">Full Time Live-In</a></li>
                        <li><a href="{{ route('admin.pages.services.edit') }}" class="{{ request()->routeIs('admin.pages.services.*') ? 'ad_active' : '' }}">Services</a></li>
                        <li><a href="{{ route('admin.pages.about-us.edit') }}" class="{{ request()->routeIs('admin.pages.about-us.*') ? 'ad_active' : '' }}">About Us</a></li>
                        <li><a href="{{ route('admin.pages.maid-visa.edit') }}" class="{{ request()->routeIs('admin.pages.maid-visa.*') ? 'ad_active' : '' }}">Maid Visa</a></li>
                        <li><a href="{{ route('admin.pages.contact-us.edit') }}" class="{{ request()->routeIs('admin.pages.contact-us.*') ? 'ad_active' : '' }}">Contact Us</a></li>
                        <li><a href="{{ route('admin.pages.terms-and-conditions.edit') }}" class="{{ request()->routeIs('admin.pages.terms-and-conditions.*') ? 'ad_active' : '' }}">Terms and Conditions</a></li>
                        <li><a href="{{ route('admin.pages.privacy-policy.edit') }}" class="{{ request()->routeIs('admin.pages.privacy-policy.*') ? 'ad_active' : '' }}">Privacy Policy</a></li>
                        <li><a href="{{ route('admin.pages.page-contents.index') }}" class="{{ request()->routeIs('admin.pages.page-contents.*') ? 'ad_active' : '' }}">Page Contents (JSON)</a></li>
                    </ul>
                </li>

                <li class="ad_sidebar_item">
                    <a href="{{ route('admin.inquiries.index') }}" class="ad_nav_link {{ request()->routeIs('admin.inquiries.*') ? 'ad_active' : '' }}">
                        <span class="ad_nav_left">
                            <i class="fa-solid fa-envelope-open-text"></i>
                            <span>Inquiries</span>
                        </span>
                    </a>
                </li>

                <li class="ad_sidebar_item">
                    <a href="{{ route('admin.callback-requests.index') }}" class="ad_nav_link {{ request()->routeIs('admin.callback-requests.*') ? 'ad_active' : '' }}">
                        <span class="ad_nav_left">
                            <i class="fa-solid fa-phone-volume"></i>
                            <span>Callback Requests</span>
                        </span>
                    </a>
                </li>

                <li class="ad_sidebar_item">
                    <a href="{{ route('admin.blogs.index') }}" class="ad_nav_link {{ request()->routeIs('admin.blogs.*') ? 'ad_active' : '' }}">
                        <span class="ad_nav_left">
                            <i class="fa-solid fa-blog"></i>
                            <span>Blogs</span>
                        </span>
                    </a>
                </li>

                <li class="ad_sidebar_item">
                    <a href="{{ route('admin.maid-links.index') }}" class="ad_nav_link {{ request()->routeIs('admin.maid-links.*') ? 'ad_active' : '' }}">
                        <span class="ad_nav_left">
                            <i class="fa-solid fa-link"></i>
                            <span>Maids Links</span>
                        </span>
                    </a>
                </li>

                <li class="ad_sidebar_item">
                    <a href="{{ route('admin.candidates.index') }}" class="ad_nav_link {{ request()->routeIs('admin.candidates.*') ? 'ad_active' : '' }}">
                        <span class="ad_nav_left">
                            <i class="fa-solid fa-user-group"></i>
                            <span>Candidates</span>
                        </span>
                    </a>
                </li>

                <li class="ad_sidebar_item">
                    <a href="{{ route('admin.settings.edit') }}" class="ad_nav_link {{ request()->routeIs('admin.settings.*') ? 'ad_active' : '' }}">
                        <span class="ad_nav_left">
                            <i class="fa-solid fa-sliders"></i>
                            <span>Setting</span>
                        </span>
                    </a>
                </li>
            </ul>

            <div class="ad_logout_wrap">
                <form method="POST" action="{{ route('admin.logout') }}">
                    @csrf
                    <button type="submit" class="ad_logout_btn">
                        <i class="fa-solid fa-right-from-bracket"></i>
                        <span>Logout</span>
                    </button>
                </form>
            </div>
        </aside>

        <div class="ad_main">
            <div class="ad_topbar">
                <div class="ad_topbar_inner">
                    <div class="ad_page_heading">
                        <h1>@yield('ad_page_title', 'Admin Panel')</h1>
                        <p>@yield('ad_page_subtitle', 'Manage your website content and settings')</p>
                    </div>

                    <div class="ad_topbar_actions">
                        <a href="{{ route('home') }}" target="_blank" class="ad_btn_outline">
                            <i class="fa-solid fa-arrow-up-right-from-square"></i>
                            <span>Preview Website</span>
                        </a>
                    </div>
                </div>
            </div>

            <div class="ad_page">
                @if(session('success'))
                    <div class="ad_alert ad_alert_success">{{ session('success') }}</div>
                @endif

                @yield('ad_content')
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        document.addEventListener('click', function (e) {
            const toggle = e.target.closest('[data-sidebar-toggle]');

            if (!toggle) {
                return;
            }

            const dropdown = toggle.closest('.ad_sidebar_dropdown');

            if (!dropdown) {
                return;
            }

            dropdown.classList.toggle('ad_open');
        });
    </script>
    @stack('ad_scripts')
</body>
</html>