/* SPA Loading Styles */
.spa-loading {
    position: relative;
}
.spa-loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}
.spa-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spa-spin 1s linear infinite;
}
@keyframes spa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==============================================================
   Admin Dashboard Custom UI (Sidebar Layout)
   ============================================================== */
:root {
    --sidebar-width: 280px;
    --sidebar-bg: #151521;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: #3699ff;
    --sidebar-color: #7e8299;
    --sidebar-color-active: #ffffff;
    --topbar-height: 70px;
    --bg-light: #f3f6f9;
    --text-dark: #181c32;
    --card-glass: rgba(255, 255, 255, 0.7);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    --transition-speed: 0.3s;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #1cc88a 0%, #13855c 100%);
    --info-gradient: linear-gradient(135deg, #36b9cc 0%, #258391 100%);
    --warning-gradient: linear-gradient(135deg, #f6c23e 0%, #dda20a 100%);
}

body.admin-body {
    background-color: var(--bg-light);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* --- SIDEBAR --- */
.admin-sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    background-color: var(--sidebar-bg);
    z-index: 1040;
    transition: transform var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
}

[dir="rtl"] .admin-sidebar {
    left: auto;
    right: 0;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    background-color: rgba(0, 0, 0, 0.1);
    color: #fff;
    font-weight: 700;
}

.brand-icon {
    font-size: 1.5rem;
    margin-right: 0.75rem;
    color: #007bff;
}
[dir="rtl"] .brand-icon {
    margin-right: 0;
    margin-left: 0.75rem;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.brand-sub {
    font-size: 0.7rem;
    color: #a2a3b7;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
}
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-label {
    display: block;
    padding: 0 1.5rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #565674;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1.5rem;
    color: var(--sidebar-color);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
}

.sidebar-link:hover {
    color: var(--sidebar-color-active);
    background-color: var(--sidebar-hover);
}

.sidebar-link.active {
    color: var(--sidebar-color-active);
    background-color: rgba(54, 153, 255, 0.1);
    font-weight: 600;
}
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    bottom: 5px;
    width: 4px;
    background-color: var(--sidebar-active);
    border-radius: 0 4px 4px 0;
}
[dir="rtl"] .sidebar-link.active::before {
    left: auto;
    right: 0;
}

.link-icon {
    width: 25px;
    font-size: 1.1rem;
    text-align: center;
    margin-right: 0.75rem;
    opacity: 0.8;
}
[dir="rtl"] .link-icon {
    margin-right: 0;
    margin-left: 0.75rem;
}

.sidebar-link.active .link-icon {
    opacity: 1;
    color: var(--sidebar-active);
}

.link-text {
    flex: 1;
    font-size: 0.95rem;
}

.link-badge {
    font-size: 0.65rem;
    padding: 0.2em 0.5em;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
}
.live-badge {
    background-color: #dc3545;
    color: white;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(220, 53, 69, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    background-color: rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
}

.user-avatar i {
    font-size: 2rem;
    color: #a2a3b7;
}

.user-info {
    flex: 1;
    margin-left: 0.75rem;
    display: flex;
    flex-direction: column;
}
[dir="rtl"] .user-info {
    margin-left: 0;
    margin-right: 0.75rem;
}

.user-name {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}
.user-role {
    color: #565674;
    font-size: 0.75rem;
}

.logout-btn {
    background: none;
    border: none;
    color: #a2a3b7;
    transition: color 0.2s;
}
.logout-btn:hover {
    color: #dc3545;
}

/* --- MAIN WRAPPER & TOPBAR --- */
.admin-main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin var(--transition-speed) ease;
}
[dir="rtl"] .admin-main-wrapper {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

.admin-topbar {
    height: var(--topbar-height);
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-left {
    display: flex;
    align-items: center;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #565674;
    margin-right: 1rem;
    display: none; /* Hidden on desktop */
}
[dir="rtl"] .sidebar-toggle-btn {
    margin-right: 0;
    margin-left: 1rem;
}

.page-breadcrumb .page-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-dark);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-btn {
    background: #f5f8fa;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a1a5b7;
    transition: all 0.2s;
    position: relative;
}
.topbar-btn:hover {
    color: #007bff;
    background: #e1f0ff;
}
.lang-btn {
    width: auto;
    padding: 0 10px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}
.lang-btn i {
    margin-right: 5px;
}
[dir="rtl"] .lang-btn i {
    margin-right: 0;
    margin-left: 5px;
}

.notif-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.topbar-user-btn {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-dark);
    font-weight: 500;
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
}
.topbar-user-btn:hover {
    background: #f5f8fa;
}
.topbar-user-btn i.fa-user-circle {
    font-size: 1.5rem;
    color: #a1a5b7;
}

.notif-dropdown {
    width: 300px;
    max-height: 400px;
    overflow-y: auto;
}

/* --- CONTENT --- */
.admin-content {
    padding: 2rem;
    flex: 1;
}

/* --- GLOBAL PREMIUM OVERRIDES --- */
.card {
    background: var(--card-glass) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 16px !important;
    box-shadow: var(--card-shadow) !important;
    margin-bottom: 2rem !important;
}

.table {
    margin-bottom: 0;
    color: var(--text-dark);
}

.table thead th {
    border-top: none;
    border-bottom: 2px solid #f1f1f1;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 1rem 0.75rem;
    color: #a1a5b7;
}

.table tbody td {
    padding: 1.25rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid #f8f9fa;
}

.table-hover tbody tr:hover {
    background-color: rgba(54, 153, 255, 0.02) !important;
    transition: background-color 0.2s ease;
}

.form-control, .form-select {
    border-radius: 10px;
    padding: 0.6rem 1rem;
    border: 1px solid #e1e3ea;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--sidebar-active);
    box-shadow: 0 0 0 3px rgba(54, 153, 255, 0.1);
}

.btn {
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--sidebar-active) !important;
    border-color: var(--sidebar-active) !important;
    color: white !important;
}

.btn-primary:hover {
    background: #187de4 !important;
    border-color: #187de4 !important;
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(54, 153, 255, 0.3);
}

.badge {
    padding: 0.5em 0.85em;
    font-weight: 600;
    border-radius: 6px;
}

/* --- AUTH PAGE FALLBACK --- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-light);
    padding: 20px;
}

.auth-wrapper > main {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 991.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    [dir="rtl"] .admin-sidebar {
        transform: translateX(100%);
    }
    
    .admin-sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .admin-main-wrapper {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .sidebar-toggle-btn {
        display: block;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1030;
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-speed) ease;
    }
    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }
    .sidebar-close-btn {
        color: #fff;
        background: none;
        border: none;
        font-size: 1.25rem;
    }
}

/* Premium Glass Cards */
.glass-card {
    background: var(--card-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08);
}

.stat-card-premium {
    padding: 1.5rem;
    color: white;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
}

.stat-card-premium::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.bg-gradient-primary { background: var(--primary-gradient); }
.bg-gradient-success { background: var(--success-gradient); }
.bg-gradient-info { background: var(--info-gradient); }
.bg-gradient-warning { background: var(--warning-gradient); }

.premium-header {
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-dark);
}

.card-header-clean {
    background: transparent !important;
    border-bottom: 2px solid #f1f1f1 !important;
    padding: 1.25rem 1.5rem !important;
}

.card-header-clean h5 {
    color: var(--text-dark) !important;
    font-weight: 600;
    margin: 0;
}
