<!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 Dashboard') - The Mini Port</title>
    
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    
    <meta name="csrf-token" content="{{ csrf_token() }}">
    
    @stack('styles')
    
    <style>
        :root {
            --sidebar-width: 280px;
            --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --dark-gradient: linear-gradient(180deg, #1a1f36 0%, #0d1025 100%);
            --card-shadow: 0 4px 20px rgba(0,0,0,0.08);
            --hover-shadow: 0 8px 30px rgba(0,0,0,0.12);
        }
        
        * { box-sizing: border-box; }
        
        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
            min-height: 100vh;
            font-size: 0.875rem; /* 14px */
            line-height: 1.5;
        }
        
        /* Premium Sidebar */
        .admin-sidebar {
            position: fixed;
            top: 0;
            left: 0;
            width: var(--sidebar-width);
            height: 100vh;
            background: var(--dark-gradient);
            z-index: 1000;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            overflow-y: auto;
            overflow-x: hidden;
        }
        
        .admin-sidebar::-webkit-scrollbar { width: 4px; }
        .admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
        
        .sidebar-brand {
            padding: 1.5rem;
            background: rgba(255,255,255,0.03);
            border-bottom: 1px solid rgba(255,255,255,0.06);
            display: flex;
            align-items: center;
            gap: 12px;
        }
        .sidebar-brand-logo {
            width: 44px;
            height: 44px;
            border-radius: 12px;
            background: var(--primary-gradient);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            color: #fff;
            font-size: 1.2rem;
            flex-shrink: 0;
        }
        .sidebar-brand-text h6 {
            color: #fff;
            margin: 0;
            font-weight: 600;
            font-size: 0.95rem;
        }
        .sidebar-brand-text small {
            color: rgba(255,255,255,0.5);
            font-size: 0.7rem;
        }
        
        /* Navigation */
        .nav-section {
            padding: 1rem 0;
        }
        .nav-section-title {
            color: rgba(255,255,255,0.35);
            font-size: 0.65rem;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            font-weight: 600;
            padding: 0.5rem 1.5rem;
            margin-bottom: 0.25rem;
        }
        .admin-sidebar .nav-link {
            color: rgba(255,255,255,0.65);
            padding: 0.7rem 1.5rem;
            display: flex;
            align-items: center;
            gap: 12px;
            transition: all 0.2s ease;
            text-decoration: none;
            font-size: 0.85rem;
            font-weight: 500;
            border-left: 3px solid transparent;
        }
        .admin-sidebar .nav-link i {
            font-size: 1rem;
            width: 22px;
            text-align: center;
            transition: transform 0.2s;
        }
        .admin-sidebar .nav-link:hover {
            color: #fff;
            background: rgba(255,255,255,0.05);
        }
        .admin-sidebar .nav-link:hover i {
            transform: scale(1.1);
        }
        .admin-sidebar .nav-link.active {
            color: #fff;
            background: linear-gradient(90deg, rgba(102,126,234,0.2) 0%, transparent 100%);
            border-left-color: #667eea;
        }
        
        /* Main Content */
        .admin-main {
            margin-left: var(--sidebar-width);
            min-height: 100vh;
            transition: margin-left 0.3s;
        }
        
        /* Premium Topbar */
        .admin-topbar {
            background: rgba(255,255,255,0.95);
            backdrop-filter: blur(20px);
            padding: 0.75rem 1.5rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.03);
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: sticky;
            top: 0;
            z-index: 100;
            border-bottom: 1px solid rgba(0,0,0,0.04);
        }
        
        .topbar-icon {
            width: 40px;
            height: 40px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #f1f5f9;
            color: #64748b;
            transition: all 0.2s;
            border: none;
            cursor: pointer;
        }
        .topbar-icon:hover { background: #e2e8f0; color: #334155; }
        
        /* Profile Dropdown */
        .profile-dropdown {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 6px 12px 6px 6px;
            border-radius: 50px;
            background: #f1f5f9;
            cursor: pointer;
            transition: all 0.2s;
            border: none;
        }
        .profile-dropdown:hover { background: #e2e8f0; }
        .profile-avatar {
            width: 34px;
            height: 34px;
            border-radius: 50%;
            background: var(--primary-gradient);
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-weight: 600;
        }
        
        /* Mobile Toggle */
        .sidebar-toggle {
            display: none;
            width: 40px;
            height: 40px;
            border-radius: 12px;
            background: #f1f5f9;
            border: none;
            color: #64748b;
        }
        
        @media (max-width: 991px) {
            .admin-sidebar { transform: translateX(-100%); }
            .admin-sidebar.show { transform: translateX(0); }
            .admin-main { margin-left: 0; }
            .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
            .sidebar-overlay {
                position: fixed;
                top: 0; left: 0; width: 100%; height: 100%;
                background: rgba(0,0,0,0.5);
                z-index: 999;
                opacity: 0;
                visibility: hidden;
                transition: all 0.3s;
            }
            .sidebar-overlay.show { opacity: 1; visibility: visible; }
        }
        
        /* Content Wrapper */
        .content-wrapper { padding: 1.5rem; }
        
        /* Global Premium Styles */
        .card {
            border: none;
            border-radius: 16px;
            box-shadow: var(--card-shadow);
            transition: all 0.3s ease;
        }
        .card:hover { box-shadow: var(--hover-shadow); transform: translateY(-2px); }
        .card-header {
            background: transparent;
            border-bottom: 1px solid rgba(0,0,0,0.05);
            padding: 0.75rem 1.25rem;
        }
        
        .btn-primary-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border: none;
            color: #fff;
            padding: 0.6rem 1.5rem;
            border-radius: 10px;
            font-weight: 500;
            transition: all 0.3s;
        }
        .btn-primary-gradient:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(102,126,234,0.4);
            color: #fff;
        }

        .page-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            flex-wrap: wrap;
            gap: 1rem;
        }
        .page-title { font-weight: 700; color: #1e293b; margin-bottom: 0; }
        
        /* Stat Cards */
        .stat-card {
            border-radius: 16px;
            padding: 1.25rem;
            color: #1e293b; /* Default Dark Color */
            display: flex;
            align-items: flex-start;
            gap: 1rem;
            transition: all 0.3s;
            height: 100%;
            background: #fff; /* Default White Background */
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
            border: 1px solid #e2e8f0;
        }
        .stat-card:hover { transform: translateY(-4px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); }
        
        /* Colored Variants - Force White Text */
        .stat-card-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; border: none; }
        .stat-card-success { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); color: #fff; border: none; }
        .stat-card-warning { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: #fff; border: none; }
        .stat-card-info { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); color: #fff; border: none; }
        .stat-card-secondary { background: linear-gradient(135deg, #8e9eab 0%, #eef2f3 100%); color: #444; border: none; }
        .stat-card-secondary .stat-icon { background: rgba(0,0,0,0.1); color: #444; }
        
        .stat-icon {
            width: 48px;
            height: 48px;
            background: rgba(255,255,255,0.2);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.4rem;
            flex-shrink: 0;
        }
        .stat-value { font-size: 1.5rem; font-weight: 700; display: block; line-height: 1.2; }
        .stat-label { font-size: 0.75rem; opacity: 0.9; display: block; margin-bottom: 0.25rem; }
        
        /* Table Styling */
        .table-hover tbody tr:hover { background-color: rgba(102,126,234,0.02); }
        .table thead th {
            font-weight: 600;
            text-transform: uppercase;
            font-size: 0.75rem;
            letter-spacing: 0.5px;
            color: #64748b;
            background: #f8fafc;
            border-bottom: 1px solid #e2e8f0;
            padding: 0.75rem 1rem;
        }
        .table td { padding: 0.75rem 1rem; vertical-align: middle; color: #334155; font-size: 0.875rem; }

        /* Global Admin Components */
        .filter-card {
            background: #fff;
            border: 1px solid #e2e8f0;
            border-radius: 12px;
            padding: 1.5rem;
            margin-bottom: 1.5rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        }
        
        .data-table {
            background: #fff;
            border: 1px solid #e2e8f0;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
            margin-bottom: 1.5rem;
        }
        
        .action-btn {
            width: 32px;
            height: 32px;
            border-radius: 6px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border: 1px solid #e2e8f0;
            background: #fff;
            color: #64748b;
            transition: all 0.2s;
            text-decoration: none;
            cursor: pointer;
        }
        .action-btn:hover { background: #f8fafc; color: #0f172a; border-color: #cbd5e1; }
        .action-btn.primary:hover { background: #eff6ff; color: #3b82f6; border-color: #bfdbfe; }
        .action-btn.danger:hover { background: #fef2f2; color: #ef4444; border-color: #fecaca; }
        .action-btn.success:hover { background: #f0fdf4; color: #22c55e; border-color: #bbf7d0; }
        .action-btn.warning:hover { background: #fffbeb; color: #f59e0b; border-color: #fde68a; }
        .action-btn.info:hover { background: #e0f2fe; color: #0284c7; border-color: #bae6fd; }

        .status-badge {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 10px;
            border-radius: 9999px;
            font-size: 0.75rem;
            font-weight: 600;
            white-space: nowrap;
        }
        .status-badge.active, .status-badge.success, .status-badge.open { background: #dcfce7; color: #166534; }
        .status-badge.pending, .status-badge.warning { background: #fef9c3; color: #854d0e; }
        .status-badge.closed, .status-badge.inactive, .status-badge.secondary { background: #f1f5f9; color: #475569; }
        .status-badge.danger, .status-badge.banned { background: #fee2e2; color: #991b1b; }
        .status-badge.primary, .status-badge.featured { background: #e0f2fe; color: #0369a1; }
    @stack('styles')
</head>
<body>
    @php $currentRoute = Route::currentRouteName(); @endphp

    <!-- Sidebar Overlay -->
    <div class="sidebar-overlay" id="sidebarOverlay"></div>

    <!-- Sidebar -->
    @include('admin.partials.sidebar')


    <!-- Main Content -->
    <div class="admin-main">
        <!-- Topbar -->
        <div class="admin-topbar">
            <div class="d-flex align-items-center gap-3">
                <button class="sidebar-toggle" id="sidebarToggle">
                    <i class="bi bi-list fs-5"></i>
                </button>
                <div class="d-none d-md-block text-muted small">
                    <a href="{{ route('admin.dashboard') }}" class="text-decoration-none text-muted">Admin</a> / @yield('title', 'Dashboard')
                </div>
            </div>
            
            <div class="d-flex align-items-center gap-3">
                <!-- Notification Bell -->
                @include('partials.notification-bell')
                
                <div class="dropdown">
                    <button class="profile-dropdown" type="button" data-bs-toggle="dropdown">
                        <div class="profile-avatar">
                            {{ strtoupper(substr(Auth::user()->name, 0, 1)) }}
                        </div>
                        <div class="d-none d-md-block text-start" style="line-height: 1.2;">
                            <strong class="d-block text-dark" style="font-size: 0.85rem;">{{ Auth::user()->name }}</strong>
                            <small class="text-muted" style="font-size: 0.7rem;">Administrator</small>
                        </div>
                        <i class="bi bi-chevron-down text-muted ms-1" style="font-size: 0.7rem;"></i>
                    </button>
                    <ul class="dropdown-menu dropdown-menu-end shadow-lg border-0">
                        <li><a class="dropdown-item" href="#"><i class="bi bi-person me-2"></i>Profile</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li>
                            <a class="dropdown-item text-danger" href="{{ route('logout') }}"
                               onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                                <i class="bi bi-box-arrow-left me-2"></i>Logout
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        
        <!-- Content -->
        <div class="content-wrapper">
            @if(session('success'))
                <div class="alert alert-success alert-dismissible fade show border-0 shadow-sm" role="alert">
                    <i class="bi bi-check-circle-fill me-2"></i>{{ 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 border-0 shadow-sm" role="alert">
                    <i class="bi bi-x-circle-fill me-2"></i>{{ session('error') }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
            @endif
            
            @yield('admin-content')
        </div>
    </div>

    <!-- Scripts -->
    <script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        document.getElementById('sidebarToggle')?.addEventListener('click', function() {
            document.getElementById('adminSidebar').classList.toggle('show');
            document.getElementById('sidebarOverlay').classList.toggle('show');
        });
        document.getElementById('sidebarOverlay')?.addEventListener('click', function() {
            document.getElementById('adminSidebar').classList.remove('show');
            this.classList.remove('show');
        });
    </script>
    
    @stack('scripts')
</body>
</html>
