:root {
    /* --- Colors --- */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --bg: #f8fafc;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --surface: #ffffff;
    --danger: #ef4444;
    --success: #166534;
    --success-bg: #dcfce7;
    --warning: #f59e0b;

    /* --- Dimensions --- */
    --sidebar-width: 260px;
    --navbar-height: 60px;

    /* --- Design Tokens --- */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

* {
    box-sizing: border-box;
    outline: none;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    padding-top: var(--navbar-height);
}

a {
    text-decoration: none;
    color: inherit;
}

/* =========================================
   GLOBAL LAYOUT & NAVBAR
   ========================================= */

/* --- Top Fixed Navbar --- */
.global-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 60;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

/* Navbar Right Side */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
}

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

.mobile-menu-toggle {
    display: none;
    /* Hidden on desktop */
    background: transparent;
    color: var(--text);
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
}

.mobile-menu-toggle .material-symbols-outlined {
    font-size: 1.5rem;
}


/* --- Sidebar Navigation (Dark Theme) --- */
.global-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: #011722;
    /* Dark Background */
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    /* Light Text */
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--navbar-height));
    position: sticky;
    top: var(--navbar-height);
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.user-mini {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Override Text Colors in Sidebar Header for Dark Mode */
.global-sidebar .user-mini #header-user-name {
    color: #f1f5f9 !important;
}

.global-sidebar .user-mini #header-user-email {
    color: #94a3b8 !important;
}

.sidebar-content {
    flex: 1;
    padding: 1.5rem 0;
    /* Remove horizontal padding for full-width items */
    overflow-y: auto;
}

.menu-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.5rem;
    margin-top: 1.5rem;
    font-weight: 600;
    padding: 0 1.5rem;
}

.menu-category:first-child {
    margin-top: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 1.5rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 0;
    margin-bottom: 0;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
}

.nav-link.active {
    background: #ffffff08;
    color: #fff;
    border-left: 3px solid var(--primary);
    padding-left: calc(1.5rem - 3px);
}

.nav-link .material-symbols-outlined {
    font-size: 1.25rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-btn {
    width: 100%;
    justify-content: flex-start;
    color: #ef4444;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
}

/* Backdrop for Mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 40;
    backdrop-filter: blur(2px);
}

/* --- Content Wrapper --- */
.content {
    flex-grow: 1;
    min-width: 0;
    padding: 30px;
    max-width: 1400px;
    /* Slightly wider for admin tables */
    margin: 0 auto;
    width: 100%;
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.page-desc {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* =========================================
   COMPONENTS
   ========================================= */

/* --- Cards --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    overflow: hidden;
}

.toolbar-card {
    background: var(--surface);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.section-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

/* --- Forms & Inputs --- */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 200px;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-wrapper .material-symbols-outlined {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
    font-size: 20px;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px 10px 40px;
    /* Space for icon */
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--surface);
    transition: border-color 0.2s;
}

input.no-icon,
select.no-icon {
    padding-left: 12px;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid transparent;
    height: 42px;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: white;
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--bg);
    border-color: #cbd5e1;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}

.btn-danger:hover {
    background: #fecaca;
}

/* --- Badges --- */
.badge {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg);
    border: 1px solid var(--border);
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

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

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8fafc;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --- Utilities --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    color: #cbd5e1;
    margin-bottom: 12px;
}

.text-right {
    text-align: right;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================================
   AUTHENTICATION PAGES (Admin Specific)
   ========================================= */
body.auth-page {
    padding-top: 0;
    align-items: center;
    justify-content: center;
    background-color: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.login-card p {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

/* Auth Dividers */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.divider::before {
    margin-right: 1rem;
}

.divider::after {
    margin-left: 1rem;
}

/* Google Button */
.btn-google {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 500;
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.95rem;
    height: 42px;
    transition: 0.2s;
}

.btn-google:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* Captcha */
.captcha-box {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    height: 42px;
    overflow: hidden;
    margin-top: 5px;
    background: #fff;
}

.captcha-input {
    border: none !important;
    padding-left: 16px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-radius: 0;
    background: transparent;
    height: 100%;
}

.captcha-input:focus {
    box-shadow: none;
    border: none;
}

#refresh-c {
    background: #f8fafc;
    border: none;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    cursor: pointer;
    padding: 0 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

#refresh-c:hover {
    background: #e2e8f0;
    color: var(--text);
}

.message-box {
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-top: 20px;
    text-align: center;
    display: none;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.error-message {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

/* =========================================
   RESPONSIVENESS
   ========================================= */
@media (max-width: 768px) {
    .global-sidebar {
        position: fixed;
        left: 0;
        top: var(--navbar-height);
        transform: translateX(-100%);
        width: 80%;
        max-width: 300px;
        height: calc(100vh - var(--navbar-height));
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .global-sidebar.open {
        transform: translateX(0);
    }

    .mobile-menu-toggle {
        display: block;
    }

    .sidebar-backdrop {
        top: var(--navbar-height);
    }

    .sidebar-backdrop.open {
        display: block;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 20px;
    }
}

button#btnBack {
    border: 1px solid #ddd;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 15px;
    margin-bottom: 10px;
    background: #fff;
}