/*
 * Rehlati v2 - Professional Green Theme
 * Emerald color palette with light/dark/auto modes
 */

/* ==========================================================================
   CSS CUSTOM PROPERTIES - GREEN THEME
   ========================================================================== */

:root {
    /* ================== PRIMARY COLORS ================== */
    --rehlati-primary: #1F7A4D;          /* Emerald 700 */
    --rehlati-primary-light: #35A86B;    /* Emerald 500 */
    --rehlati-primary-dark: #0F5F3A;     /* Emerald 900 */
    --rehlati-primary-darker: #0B4A2E;   /* Emerald 950 */
    
    /* ================== ACCENT COLORS ================== */
    --rehlati-accent: #f59e0b;           /* Amber 500 - Gold accent */
    --rehlati-accent-light: #fbbf24;     /* Amber 400 */
    --rehlati-accent-dark: #d97706;      /* Amber 600 */
    
    /* ================== SEMANTIC COLORS ================== */
    --rehlati-success: #22c55e;          /* Green 500 */
    --rehlati-warning: #f59e0b;          /* Amber 500 */
    --rehlati-danger: #ef4444;           /* Red 500 */
    --rehlati-info: #06b6d4;             /* Cyan 500 */
    
    /* ================== GRADIENT DEFINITIONS ================== */
    --rehlati-gradient-primary: linear-gradient(135deg, #1F7A4D 0%, #0F5F3A 100%);
    --rehlati-gradient-accent: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --rehlati-gradient-hero: linear-gradient(135deg, #1F7A4D 0%, #168C5A 50%, #0F5F3A 100%);
    
    /* Gray Gradients for Headings */
    --rehlati-gradient-heading-light: linear-gradient(135deg, #1f2937 0%, #4b5563 100%);
    --rehlati-gradient-heading-dark: linear-gradient(135deg, #f3f4f6 0%, #9ca3af 100%);
    
    /* ================== THEME MODE (set by JS) ================== */
    --theme-mode: 'light';
}

/* TomSelect dropdowns should float above complex panels */
.ts-dropdown {
    z-index: 2000 !important;
}

/* ==========================================================================
   LIGHT THEME (Default)
   ========================================================================== */

[data-bs-theme="light"], 
[data-rehlati-theme="light"],
:root {
    /* Backgrounds */
    --bg-body: #f0fdf4;                  /* Emerald 50 */
    --bg-primary: #ffffff;
    --bg-secondary: #f1f7f6;             /* Slate 50 -> Green Slate 50 */
    --bg-tertiary: #ecfdf5;              /* Emerald 50 */
    --bg-elevated: #ffffff;
    
    /* Navbar */
    --surface-nav: linear-gradient(135deg, #1F7A4D 0%, #0F5F3A 100%);
    --surface-nav-alt: linear-gradient(135deg, #168C5A 0%, #0B4A2E 100%);
    
    /* Text */
    --text-primary: #0b1a16;             /* Slate 900 -> Green Slate 900 */
    --text-secondary: #344e47;           /* Slate 600 -> Green Slate 600 */
    --text-muted: #2f4f46;               /* Darker muted for light mode */
    --text-on-primary: #ffffff;
    --text-accent: #1F7A4D;              /* Emerald 700 */
    
    /* Borders */
    --border-primary: #d1fae5;           /* Emerald 100 */
    --border-secondary: #d1e1de;         /* Slate 200 -> Green Slate 200 */
    --border-accent: #1F7A4D;            /* Emerald 700 */
    
    /* Cards & Surfaces */
    --card-bg: #ffffff;
    --card-border: rgba(31, 122, 77, 0.15);
    --card-shadow: 0 4px 20px rgba(31, 122, 77, 0.08);
    --card-shadow-hover: 0 8px 30px rgba(31, 122, 77, 0.15);
    
    /* Interactive */
    --interactive-primary: #1F7A4D;
    --interactive-hover: #168C5A;
    --interactive-active: #0F5F3A;
    --interactive-subtle: rgba(31, 122, 77, 0.1);
    
    /* Tables */
    --table-header-bg: linear-gradient(135deg, #1F7A4D 0%, #168C5A 100%);
    --table-header-text: #ffffff;
    --table-stripe-bg: rgba(31, 122, 77, 0.04);
    --table-hover-bg: rgba(31, 122, 77, 0.08);
    
    /* Inputs */
    --input-bg: #ffffff;
    --input-border: #b6c7c1;
    --input-focus-border: #1F7A4D;
    --input-focus-ring: rgba(31, 122, 77, 0.25);
}

/* ==========================================================================
   DARK THEME
   ========================================================================== */

[data-bs-theme="dark"],
[data-rehlati-theme="dark"] {
    /* Backgrounds */
    --bg-body: #0b1a16;                  /* Slate 900 -> Green Slate 900 */
    --bg-primary: #152621;               /* Slate 800 -> Green Slate 800 */
    --bg-secondary: #0b1a16;             /* Slate 900 -> Green Slate 900 */
    --bg-tertiary: #152621;              /* Slate 800 -> Green Slate 800 */
    --bg-elevated: #243933;              /* Slate 700 -> Green Slate 700 */
    
    /* Navbar */
    --surface-nav: linear-gradient(135deg, #0F5F3A 0%, #0B4A2E 100%);
    --surface-nav-alt: linear-gradient(135deg, #1F7A4D 0%, #0F5F3A 100%);
    
    /* Text */
    --text-primary: #e8f2f0;             /* Slate 100 -> Green Slate 100 */
    --text-secondary: #b2cbc7;           /* Slate 300 -> Green Slate 300 */
    --text-muted: #7ea199;               /* Slate 400 -> Green Slate 400 */
    --text-on-primary: #ffffff;
    --text-accent: #35A86B;              /* Emerald 500 */
    
    /* Borders */
    --border-primary: rgba(53, 168, 107, 0.2);
    --border-secondary: rgba(148, 163, 184, 0.2);
    --border-accent: #35A86B;
    
    /* Cards & Surfaces */
    --card-bg: #152621;
    --card-border: rgba(53, 168, 107, 0.15);
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --card-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.4);
    
    /* Interactive */
    --interactive-primary: #35A86B;
    --interactive-hover: #1F7A4D;
    --interactive-active: #168C5A;
    --interactive-subtle: rgba(53, 168, 107, 0.15);
    
    /* Tables */
    --table-header-bg: linear-gradient(135deg, #0F5F3A 0%, #1F7A4D 100%);
    --table-header-text: #ffffff;
    --table-stripe-bg: rgba(53, 168, 107, 0.05);
    --table-hover-bg: rgba(53, 168, 107, 0.1);
    
    /* Inputs */
    --input-bg: #152621;
    --input-border: #344e47;
    --input-focus-border: #35A86B;
    --input-focus-ring: rgba(53, 168, 107, 0.25);
    
    /* Soft Backgrounds */
    --bg-soft-primary: rgba(31, 122, 77, 0.1);
    --bg-soft-success: rgba(22, 140, 90, 0.1);
    --bg-soft-info: rgba(31, 122, 77, 0.1);
    --bg-soft-warning: rgba(245, 158, 11, 0.1);
}

.bg-soft-primary { background-color: var(--bg-soft-primary) !important; }
.bg-soft-success { background-color: var(--bg-soft-success) !important; }
.bg-soft-info { background-color: var(--bg-soft-info) !important; }
.bg-soft-warning { background-color: var(--bg-soft-warning) !important; }

/* ================== TABLE WARNING GLOBAL FIX ================== */
.table-warning,
.table-warning > td,
.table-warning > th {
    background-color: #fef3c7 !important; /* Amber 100 */
    color: #92400e !important;           /* Amber 900 */
    border-color: #fde68a !important;   /* Amber 200 */
}

[data-bs-theme="dark"] .table-warning,
[data-bs-theme="dark"] .table-warning > td,
[data-bs-theme="dark"] .table-warning > th {
    background-color: #78350f !important; /* Amber 900 (Stronger) */
    color: #fef3c7 !important;           /* Amber 100 */
    border-color: #92400e !important;
}

/* ==========================================================================
   GLOBAL STYLES - GREEN THEME APPLICATION
   ========================================================================== */

body {
    background-color: var(--bg-body) !important;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ================== GLOBAL HEADING GRADIENTS ================== */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: #152621; /* Green Slate 800 */
    margin-top: 0;
}

[data-bs-theme="dark"] h1, 
[data-bs-theme="dark"] h2, 
[data-bs-theme="dark"] h3, 
[data-bs-theme="dark"] h4, 
[data-bs-theme="dark"] h5, 
[data-bs-theme="dark"] h6,
[data-bs-theme="dark"] .h1, 
[data-bs-theme="dark"] .h2, 
[data-bs-theme="dark"] .h3, 
[data-bs-theme="dark"] .h4, 
[data-bs-theme="dark"] .h5, 
[data-bs-theme="dark"] .h6 {
    color: #ffffff !important; /* Force White in Dark Mode */
}

/* Ensure headings inside colored headers remain white */
.card-header h1, .card-header h2, .card-header h3, 
.card-header h4, .card-header h5, .card-header h6,
.admin-header h1, .admin-header h2, .admin-header h3,
.admin-header h4, .admin-header h5, .admin-header h6,
.dashboard-header h1, .dashboard-header h2, .dashboard-header h3,
.dashboard-header h4, .dashboard-header h5, .dashboard-header h6 {
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: initial !important;
    background-clip: initial !important;
    color: #ffffff !important;
    display: block !important;
}

/* ==========================================================================
   NAVBAR GREEN STYLING
   ========================================================================== */

.al-sumri-navbar {
    background: var(--surface-nav) !important;
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.18) !important;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.65),
        inset 0 -2px 0 rgba(0, 0, 0, 0.22),
        0 10px 28px rgba(12, 48, 34, 0.28);
    transform: translateZ(0);
}

.al-sumri-navbar.navbar-scrolled {
    background: var(--surface-nav-alt) !important;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.55),
        inset 0 -2px 0 rgba(0, 0, 0, 0.26),
        0 12px 30px rgba(12, 48, 34, 0.34);
}

/* Brand Logo Styling */
.al-sumri-navbar .navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.al-sumri-navbar .navbar-brand img.brand-logo {
    height: 40px;
    width: auto;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px;
}

/* ==========================================================================
   THEME TOGGLE IN NAVBAR (3-way: Light/Dark/Auto)
   ========================================================================== */

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: var(--text-on-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.theme-toggle-btn i {
    font-size: 1rem;
}

.theme-toggle-btn::after {
    display: none !important; /* Hide dropdown arrow */
}

/* Show/hide icons based on theme preference */
.theme-toggle-btn .theme-icon-light,
.theme-toggle-btn .theme-icon-dark,
.theme-toggle-btn .theme-icon-auto {
    display: none;
}

.theme-toggle-btn.theme-light .theme-icon-light { display: inline; }
.theme-toggle-btn.theme-dark .theme-icon-dark { display: inline; }
.theme-toggle-btn.theme-auto .theme-icon-auto { display: inline; }

/* Default to showing auto icon if no class set */
.theme-toggle-btn:not(.theme-light):not(.theme-dark):not(.theme-auto) .theme-icon-auto {
    display: inline;
}

/* Theme dropdown styling */
.theme-dropdown {
    min-width: 160px;
}

.theme-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
}

.theme-dropdown .dropdown-item.active {
    background: var(--interactive-subtle);
    color: var(--rehlati-primary);
}

.theme-dropdown .dropdown-item.active::after {
    content: '✓';
    margin-left: auto;
    color: var(--rehlati-primary);
}

/* Sun icon for dark mode, moon for light */
[data-bs-theme="light"] .theme-toggle-btn .fa-sun { display: none; }
[data-bs-theme="light"] .theme-toggle-btn .fa-moon { display: inline; }
[data-bs-theme="dark"] .theme-toggle-btn .fa-sun { display: inline; }
[data-bs-theme="dark"] .theme-toggle-btn .fa-moon { display: none; }

/* ==========================================================================
   CARDS - GREEN THEME
   ========================================================================== */

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

.card .card-header {
    background: var(--rehlati-gradient-primary);
    color: var(--text-on-primary);
    border-bottom: none;
}

.card .card-header h1,
.card .card-header h2,
.card .card-header h3,
.card .card-header h4,
.card .card-header h5,
.card .card-header h6 {
    color: var(--text-on-primary);
}

/* ==========================================================================
   BUTTONS - GREEN VARIANTS
   ========================================================================== */

.btn-primary {
    background: var(--rehlati-gradient-primary) !important;
    border-color: var(--rehlati-primary) !important;
    color: var(--text-on-primary) !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #168C5A 0%, #0B4A2E 100%) !important;
    border-color: var(--rehlati-primary-dark) !important;
    box-shadow: 0 4px 15px rgba(31, 122, 77, 0.3) !important;
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--rehlati-primary) !important;
    border-color: var(--rehlati-primary) !important;
    background: transparent !important;
}

.btn-outline-primary:hover {
    background: var(--rehlati-primary) !important;
    color: var(--text-on-primary) !important;
}

/* Fix for btn-check toggles */
.btn-check:checked + .btn-outline-primary,
.btn-check:active + .btn-outline-primary {
    background-color: var(--rehlati-primary) !important;
    color: var(--text-on-primary) !important;
    border-color: var(--rehlati-primary) !important;
}

.btn-success {
    background: var(--rehlati-success) !important;
    border-color: var(--rehlati-success) !important;
    color: white !important;
}

/* Light button - ensure dark text */
.btn-light {
    background: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: #0b1a16 !important; /* Dark text for visibility */
}

.btn-light:hover {
    background: #e8f2f0 !important;
    color: #0b1a16 !important;
}

/* Outline light button */
.btn-outline-light {
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
}

.btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

/* ==========================================================================
   TABLES - GREEN THEME
   ========================================================================== */

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
}

.table thead th {
    background: var(--table-header-bg) !important;
    color: var(--table-header-text) !important;
    border: none;
    font-weight: 600;
    padding: 1rem 0.75rem;
}

.table tbody tr:nth-child(even) {
    background-color: var(--table-stripe-bg);
}

.table tbody tr:hover {
    background-color: var(--table-hover-bg);
}

.table tbody td {
    border-color: var(--border-secondary);
    color: var(--text-primary);
    background-color: transparent; /* Ensure transparent to show card bg or stripe */
    vertical-align: middle;
}

/* ==========================================================================
   FORMS - GREEN THEME
   ========================================================================== */

.form-control,
.form-select {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--input-bg);
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 0.25rem var(--input-focus-ring);
    color: var(--text-primary);
}

.form-label {
    color: var(--text-primary);
    font-weight: 500;
}

/* ==========================================================================
   BADGES - GREEN VARIANTS
   ========================================================================== */

.badge.bg-primary {
    background: var(--rehlati-primary) !important;
    color: var(--text-on-primary) !important;
}

.badge.bg-success {
    background: var(--rehlati-success) !important;
}

.badge.bg-info {
    background: var(--rehlati-info) !important;
}

/* Status Badges */
.badge-scheduled {
    background: var(--rehlati-primary) !important;
    color: white !important;
}

.badge-enroute,
.badge-inprogress {
    background: var(--rehlati-info) !important;
    color: white !important;
}

.badge-completed {
    background: var(--rehlati-success) !important;
    color: white !important;
}

.badge-delayed {
    background: var(--rehlati-warning) !important;
    color: #131f1c !important;
}

.badge-cancelled {
    background: var(--rehlati-danger) !important;
    color: white !important;
}

/* ==========================================================================
   PAGINATION - GREEN THEME
   ========================================================================== */

.page-link {
    color: var(--rehlati-primary);
    border-color: var(--border-secondary);
    background-color: var(--card-bg);
}

.page-link:hover {
    color: var(--rehlati-primary-dark);
    background-color: var(--interactive-subtle);
    border-color: var(--rehlati-primary);
}

.page-item.active .page-link {
    background-color: var(--rehlati-primary);
    border-color: var(--rehlati-primary);
    color: white;
}

/* ==========================================================================
   DROPDOWN MENUS - GREEN THEME (Fixed visibility)
   ========================================================================== */

.dropdown-menu {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-secondary) !important;
    box-shadow: var(--card-shadow) !important;
}

.dropdown-item {
    color: var(--text-primary) !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-item i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Keep icon colors visible */
.dropdown-item i.text-primary { color: var(--rehlati-primary) !important; }
.dropdown-item i.text-success { color: var(--rehlati-success) !important; }
.dropdown-item i.text-info { color: var(--rehlati-info) !important; }
.dropdown-item i.text-warning { color: var(--rehlati-warning) !important; }
.dropdown-item i.text-danger { color: var(--rehlati-danger) !important; }
.dropdown-item i.text-secondary { color: var(--text-secondary) !important; }

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--interactive-subtle) !important;
    color: var(--text-accent) !important;
}

.dropdown-header {
    color: var(--rehlati-primary) !important;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-divider {
    border-color: var(--border-secondary) !important;
}

/* ==========================================================================
   PROGRESS BARS - GREEN THEME
   ========================================================================== */

.progress {
    background-color: var(--border-secondary);
    border-radius: 999px;
}

.progress-bar {
    background: var(--rehlati-gradient-primary);
}

.progress-bar.bg-success {
    background: var(--rehlati-success) !important;
}

.progress-bar.bg-warning {
    background: var(--rehlati-warning) !important;
}

.progress-bar.bg-danger {
    background: var(--rehlati-danger) !important;
}

/* ==========================================================================
   ALERTS - GREEN THEME
   ========================================================================== */

.alert-success {
    background-color: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #166534;
}

[data-bs-theme="dark"] .alert-success {
    background-color: rgba(34, 197, 94, 0.15);
    color: #86efac;
}

.alert-info {
    background-color: rgba(6, 182, 212, 0.1);
    border-color: rgba(6, 182, 212, 0.3);
    color: #0e7490;
}

[data-bs-theme="dark"] .alert-info {
    background-color: rgba(6, 182, 212, 0.15);
    color: #67e8f9;
}

/* ==========================================================================
   FOOTER - MODERN GREEN THEME
   ========================================================================== */

.rehlati-footer {
    background: var(--surface-nav) !important;
    color: var(--text-on-primary) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-logo {
    height: 36px;
    width: auto;
    border-radius: 8px;
}

.footer-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.footer-desc {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.5;
}

.footer-link {
    color: rgba(255, 255, 255, 0.85) !important;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.footer-link:hover {
    color: var(--rehlati-accent-light) !important;
    transform: translateY(-1px);
}

.footer-link i {
    font-size: 0.85rem;
}

.footer-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

@media (max-width: 991px) {
    .footer-contact {
        justify-content: center;
    }
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.footer-copyright {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
}

.footer-version {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
}

footer h5 {
    color: var(--text-on-primary) !important;
}

footer .text-muted {
    color: rgba(255, 255, 255, 0.7) !important;
}

footer hr {
    border-color: rgba(255, 255, 255, 0.2) !important;
}

/* ==========================================================================
   MOBILE OFFCANVAS - GREEN THEME
   ========================================================================== */

#mobileNavOffcanvas {
    background: linear-gradient(180deg, #1F7A4D 0%, #0B4A2E 100%) !important;
}

#mobileNavOffcanvas .offcanvas-header {
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#mobileNavOffcanvas .accordion-button {
    background: transparent !important;
    color: white !important;
}

#mobileNavOffcanvas .accordion-button::after {
    filter: brightness(0) invert(1);
}

/* ==========================================================================
   TOM SELECT - GREEN THEME
   ========================================================================== */

.ts-control {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-primary) !important;
}

.ts-control:focus,
.ts-wrapper.focus .ts-control {
    border-color: var(--input-focus-border) !important;
    box-shadow: 0 0 0 0.25rem var(--input-focus-ring) !important;
}

.ts-dropdown {
    background-color: var(--card-bg) !important;
    border-color: var(--border-secondary) !important;
    box-shadow: var(--card-shadow) !important;
}

.ts-dropdown .option {
    color: var(--text-primary) !important;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
    background-color: var(--interactive-subtle) !important;
    color: var(--text-accent) !important;
}

.ts-dropdown .optgroup-header {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
}

/* Fix for Tom Select Input Text Color in Dark Mode */
.ts-control > input {
    color: var(--text-primary) !important;
}

.ts-dropdown .option {
    color: var(--text-primary) !important;
}

/* Ensure active option text is visible */
.ts-dropdown .active,
.ts-dropdown .option.active {
    background-color: var(--interactive-subtle) !important;
    color: var(--rehlati-primary) !important;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

/* ==========================================================================
   UTILITY CLASSES & GRADIENTS
   ========================================================================== */

/* Background Gradients (Missing from Bootstrap 5 default sometimes) */
.bg-gradient-primary {
    background: var(--rehlati-gradient-primary) !important;
    color: #ffffff !important;
}

.bg-gradient-success {
    background: linear-gradient(135deg, #1F7A4D 0%, #168C5A 100%) !important;
    color: #ffffff !important;
}

.bg-gradient-info {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%) !important;
    color: #ffffff !important;
}

.bg-gradient-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: #ffffff !important;
}

.bg-gradient-danger {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%) !important;
    color: #ffffff !important;
}

/* Ensure text-white-50 works on these backgrounds */
.bg-gradient-primary .text-white-50,
.bg-gradient-success .text-white-50,
.bg-gradient-info .text-white-50,
.bg-gradient-warning .text-white-50,
.bg-gradient-danger .text-white-50 {
    color: rgba(255, 255, 255, 0.75) !important; /* Boost opacity for readability */
}

.text-primary { color: var(--rehlati-primary) !important; }
.text-accent { color: var(--rehlati-accent) !important; }
.bg-primary { background-color: var(--rehlati-primary) !important; color: #ffffff !important; }
.bg-primary-subtle { background-color: var(--interactive-subtle) !important; }
.border-primary { border-color: var(--rehlati-primary) !important; }

/* Global Text Overrides for Dark Mode */
.text-muted { color: var(--text-muted) !important; }
[data-bs-theme="light"] .text-muted { color: var(--text-muted) !important; }
[data-bs-theme="dark"] .text-muted { color: #cbd5e1 !important; } /* Lighter muted for Dark Mode */

[data-bs-theme="dark"] .text-dark { color: #f8fafc !important; }
[data-bs-theme="dark"] .text-black-50 { color: rgba(255,255,255,0.6) !important; }

/* Ensure specific classes like fw-bold text-white work */
[data-bs-theme="dark"] .text-white { color: #ffffff !important; }
[data-bs-theme="dark"] .fw-bold { font-weight: 700 !important; }

/* Glass morphism effect */
.glass-effect {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-bs-theme="dark"] .glass-effect {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   ADMIN HEADER - LIGHT THEME FIX
   Text must be visible (dark) in light theme, white in dark theme
   ========================================================================== */

.admin-header,
.dashboard-header,
.welcome-header {
    background: var(--rehlati-gradient-primary);
    color: #ffffff;
    padding: 1.5rem 2rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
}

.admin-header h2,
.admin-header h4,
.dashboard-header h1,
.dashboard-header h2,
.welcome-header h4 {
    color: #ffffff !important;
    font-weight: 700;
    margin: 0;
}

.admin-header p,
.dashboard-header p,
.welcome-header p {
    color: rgba(255, 255, 255, 0.9) !important;
    margin: 0.5rem 0 0;
}

/* ==========================================================================
   FORCE CHART & CARD HEADER VISIBILITY
   ========================================================================== */

/* High specificity overrides for card headers that appear white on white */
.card-header h1, .card-header h2, .card-header h3, 
.card-header h4, .card-header h5, .card-header h6,
.admin-card .card-header h5,
.metric-content h3 {
    color: var(--text-primary) !important;
}

/* Explicitly force dark text in Light Mode for these elements */
[data-bs-theme="light"] .card-header h1, 
[data-bs-theme="light"] .card-header h2, 
[data-bs-theme="light"] .card-header h3, 
[data-bs-theme="light"] .card-header h4, 
[data-bs-theme="light"] .card-header h5, 
[data-bs-theme="light"] .card-header h6,
[data-bs-theme="light"] .admin-card .card-header h5,
[data-bs-theme="light"] .metric-content h3 {
    color: #0f172a !important; /* Dark Slate (near black) */
}

/* Revert to white/light in Dark Mode */
[data-bs-theme="dark"] .card-header h1, 
[data-bs-theme="dark"] .card-header h2, 
[data-bs-theme="dark"] .card-header h3, 
[data-bs-theme="dark"] .card-header h4, 
[data-bs-theme="dark"] .card-header h5, 
[data-bs-theme="dark"] .card-header h6,
[data-bs-theme="dark"] .admin-card .card-header h5,
[data-bs-theme="dark"] .metric-content h3 {
    color: #f8fafc !important;
}

.admin-header .badge,
.welcome-header .badge {
    color: #131f1c !important; /* Dark text on badge */
}

.header-stat,
.admin-header .header-right span {
    color: rgba(255, 255, 255, 0.9) !important;
}

.admin-header .header-right i {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* ==========================================================================
   LIST GROUP - CONSISTENT STYLING
   ========================================================================== */

.list-group-item {
    background-color: var(--card-bg) !important;
    border-color: var(--border-secondary) !important;
    color: var(--text-primary) !important;
}

.list-group-item .fw-semibold {
    color: var(--text-primary) !important;
}

.list-group-item small.text-muted {
    color: var(--text-muted) !important;
}

.list-group-item:hover {
    background-color: var(--interactive-subtle) !important;
}

[data-bs-theme="dark"] .list-group-item {
    background-color: var(--bg-primary) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* ==========================================================================
   NAVBAR DROPDOWNS - PREMIUM DARK MODE
   Glass morphism with emerald accent
   ========================================================================== */

[data-bs-theme="dark"] .dropdown-menu {
    background: linear-gradient(135deg, rgba(21, 38, 33, 0.95) 0%, rgba(11, 26, 22, 0.98) 100%) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(53, 168, 107, 0.2) !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(53, 168, 107, 0.1) !important;
    border-radius: 12px !important;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #d1e1de !important;
    border-radius: 8px;
    margin: 2px 6px;
    padding: 0.6rem 1rem;
    transition: all 0.2s ease;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background: linear-gradient(135deg, rgba(31, 122, 77, 0.2) 0%, rgba(53, 168, 107, 0.15) 100%) !important;
    color: #35A86B !important;
    transform: translateX(4px);
}

[data-bs-theme="dark"] .dropdown-item.active {
    background: linear-gradient(135deg, #1F7A4D 0%, #0F5F3A 100%) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-color: rgba(53, 168, 107, 0.15) !important;
    margin: 0.5rem 0;
}

[data-bs-theme="dark"] .dropdown-header {
    color: #35A86B !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    padding: 0.5rem 1rem;
}

/* Light theme dropdowns also get polish */
[data-bs-theme="light"] .dropdown-menu {
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(31, 122, 77, 0.15) !important;
    box-shadow: 0 10px 40px rgba(31, 122, 77, 0.12), 0 0 0 1px rgba(31, 122, 77, 0.05) !important;
    border-radius: 12px !important;
}

[data-bs-theme="light"] .dropdown-item:hover,
[data-bs-theme="light"] .dropdown-item:focus {
    background: rgba(31, 122, 77, 0.08) !important;
    color: #0F5F3A !important;
}

/* Navbar specific dropdown enhancements */
.navbar .dropdown-menu {
    padding: 0.5rem !important;
}

.navbar .dropdown-item i {
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.navbar .dropdown-item:hover i {
    opacity: 1;
}

/* ==========================================================================
   ALERTS - THEME AWARE STYLING
   Fix visibility issues in light theme
   ========================================================================== */

/* Base alert styling */
.alert {
    border-radius: 12px;
    border: none;
}

/* Alert info - use green theme */
.alert-info {
    background: linear-gradient(135deg, rgba(31, 122, 77, 0.15) 0%, rgba(6, 182, 212, 0.12) 100%) !important;
    border-left: 4px solid #1F7A4D !important;
    color: #0B4A2E !important;
}

[data-bs-theme="dark"] .alert-info {
    background: linear-gradient(135deg, rgba(31, 122, 77, 0.2) 0%, rgba(6, 182, 212, 0.15) 100%) !important;
    color: #b9f4d8 !important;
}

.alert-info .alert-link,
.alert-info strong {
    color: #0F5F3A !important;
}

[data-bs-theme="dark"] .alert-info .alert-link,
[data-bs-theme="dark"] .alert-info strong {
    color: #35A86B !important;
}

/* Alert warning */
.alert-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(251, 191, 36, 0.12) 100%) !important;
    border-left: 4px solid #f59e0b !important;
    color: #92400e !important;
}

[data-bs-theme="dark"] .alert-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(251, 191, 36, 0.15) 100%) !important;
    color: #fef3c7 !important;
}

/* Alert success */
.alert-success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15) 0%, rgba(31, 122, 77, 0.12) 100%) !important;
    border-left: 4px solid #22c55e !important;
    color: #166534 !important;
}

[data-bs-theme="dark"] .alert-success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2) 0%, rgba(31, 122, 77, 0.15) 100%) !important;
    color: #bbf7d0 !important;
}

/* Alert danger */
.alert-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(220, 38, 38, 0.12) 100%) !important;
    border-left: 4px solid #ef4444 !important;
    color: #991b1b !important;
}

[data-bs-theme="dark"] .alert-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(220, 38, 38, 0.15) 100%) !important;
    color: #fecaca !important;
}

/* Fix buttons INSIDE alerts */
.alert .btn-outline-light {
    color: #0F5F3A !important;
    border-color: #1F7A4D !important;
    background: transparent !important;
}

.alert .btn-outline-light:hover {
    background: #1F7A4D !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .alert .btn-outline-light {
    color: #35A86B !important;
    border-color: #35A86B !important;
}

[data-bs-theme="dark"] .alert .btn-outline-light:hover {
    background: #35A86B !important;
    color: #0B4A2E !important;
}

/* Icons in alerts */
.alert i.fa-lg,
.alert i.me-3 {
    opacity: 0.85;
}

/* ==========================================================================
   TRANSPORT UI - GREEN THEME OVERRIDES
   Override blue colors from transport-ui.css
   ========================================================================== */

:root {
    --tracking-primary: #1F7A4D !important;
    --tracking-secondary: #168C5A !important;
    --tracking-accent: #35A86B !important;
    --tracking-bg: rgba(31, 122, 77, 0.10) !important;
    --tracking-bg-dark: rgba(31, 122, 77, 0.20) !important;
    --route-color: #1F7A4D !important;
}

.tracking-title {
    color: #1F7A4D !important;
}

.sidebar-header {
    background: rgba(31, 122, 77, 0.12) !important;
}

.vehicle-list-item:hover {
    background: rgba(31, 122, 77, 0.08) !important;
}

.vehicle-list-item.active {
    background: rgba(31, 122, 77, 0.18) !important;
    border-left: 3px solid #1F7A4D !important;
}

.stat-badge {
    background: rgba(31, 122, 77, 0.12) !important;
}

.vehicle-popup h6 {
    color: #1F7A4D !important;
}

.tracking-stats {
    background: rgba(31, 122, 77, 0.12) !important;
}

.trip-item {
    background-color: #1F7A4D !important;
}

/* ==========================================================================
   LEAFLET MAP - DARK MODE SUPPORT
   ========================================================================== */

[data-bs-theme="dark"] .leaflet-popup-content-wrapper {
    background: #152621 !important;
    color: #d1e1de !important;
}

[data-bs-theme="dark"] .leaflet-popup-tip {
    background: #152621 !important;
}

[data-bs-theme="dark"] .leaflet-container {
    background: #0b1a16 !important;
}

/* Darken map tiles in dark mode using CSS filter */
[data-bs-theme="dark"] .leaflet-tile-pane {
    filter: brightness(0.8) contrast(1.1) saturate(0.9) !important;
}

/* Alternative: invert and adjust for true dark mode feel */
[data-bs-theme="dark"] .leaflet-layer {
    filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9) !important;
}

/* Control styling */
[data-bs-theme="dark"] .leaflet-control-zoom a {
    background: #152621 !important;
    color: #d1e1de !important;
    border-color: rgba(52, 211, 153, 0.2) !important;
}

[data-bs-theme="dark"] .leaflet-control-zoom a:hover {
    background: #243933 !important;
}

[data-bs-theme="dark"] .route-overlay {
    background: rgba(21, 38, 33, 0.95) !important;
    color: #d1e1de !important;
}

/* ==========================================================================
   CSV DROP ZONE - DARK THEME
   ========================================================================== */

.csv-drop-zone {
    border: 2px dashed rgba(31, 122, 77, 0.3);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    background: rgba(31, 122, 77, 0.04);
    transition: all 0.2s ease;
}

.csv-drop-zone:hover,
.csv-drop-zone.dragover {
    border-color: #1F7A4D;
    background: rgba(31, 122, 77, 0.08);
}

[data-bs-theme="dark"] .csv-drop-zone {
    background: rgba(31, 122, 77, 0.08) !important;
    border-color: rgba(53, 168, 107, 0.3) !important;
}

[data-bs-theme="dark"] .csv-drop-zone:hover,
[data-bs-theme="dark"] .csv-drop-zone.dragover {
    background: rgba(31, 122, 77, 0.15) !important;
    border-color: #35A86B !important;
}

[data-bs-theme="dark"] .csv-drop-zone .text-muted {
    color: #7ea199 !important;
}

[data-bs-theme="dark"] .csv-drop-zone i {
    color: #517369 !important;
}

/* ==========================================================================
   JOURNEY CARD - DARK THEME
   For booking page trip results
   ========================================================================== */

.journey-card {
    border: 1px solid rgba(31, 122, 77, 0.15);
    border-radius: 12px;
    transition: all 0.2s ease;
    background: var(--card-bg, #fff);
    cursor: pointer;
}

.journey-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(31, 122, 77, 0.12);
    border-color: rgba(31, 122, 77, 0.3);
}

.journey-card.selected {
    border: 2px solid #1F7A4D !important;
    background: rgba(31, 122, 77, 0.04) !important;
}

[data-bs-theme="dark"] .journey-card {
    background: #152621 !important;
    border-color: rgba(53, 168, 107, 0.2) !important;
}

[data-bs-theme="dark"] .journey-card:hover {
    background: #243933 !important;
    border-color: rgba(53, 168, 107, 0.4) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .journey-card.selected {
    border: 2px solid #35A86B !important;
    background: rgba(53, 168, 107, 0.1) !important;
}

.journey-time {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

[data-bs-theme="dark"] .journey-time {
    color: #e8f2f0 !important;
}

[data-bs-theme="dark"] .journey-card .text-muted {
    color: #7ea199 !important;
}

/* Segment dots */
.segment-dot {
    height: 10px;
    width: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-start {
    background-color: #1F7A4D;
}

.dot-end {
    background-color: #ef4444;
}

.dot-transfer {
    background-color: #f59e0b;
}

/* Journey line */
[data-bs-theme="dark"] .journey-card div[style*="background: #dee2e6"] {
    background: #344e47 !important;
}

/* ==========================================================================
   BG-LIGHT CARDS IN DARK MODE
   Fix for Quick Self Check-in section and similar nested cards
   ========================================================================== */

[data-bs-theme="dark"] .card.bg-light {
    background: rgba(31, 122, 77, 0.08) !important;
    border-color: rgba(53, 168, 107, 0.2) !important;
}

[data-bs-theme="dark"] .card.bg-light .card-title {
    color: #e8f2f0 !important;
}

[data-bs-theme="dark"] .card.bg-light .text-muted {
    color: #7ea199 !important;
}

/* Nested cards inside bg-light (like check-in booking cards) */
[data-bs-theme="dark"] .card.bg-light .card {
    background: #152621 !important;
    border-color: rgba(53, 168, 107, 0.3) !important;
}

[data-bs-theme="dark"] .card.bg-light .card .card-body {
    background: #152621 !important;
}

[data-bs-theme="dark"] .card.bg-light .card.border-success {
    border-color: rgba(53, 168, 107, 0.5) !important;
}

[data-bs-theme="dark"] .card.bg-light .card strong.text-primary {
    color: #35A86B !important;
}

/* ==========================================================================
   ROUTES PAGE - FULL WIDTH TABLE
   ========================================================================== */

.routes-page .card {
    max-width: 100% !important;
}

.routes-page .table-responsive {
    width: 100% !important;
}

.routes-page .table {
    width: 100% !important;
}

/* ==========================================================================
   DARK MODE - CARD FOOTER & PAGINATION  
   ========================================================================== */

[data-bs-theme="dark"] .card-footer.bg-white,
[data-bs-theme="dark"] .card-footer {
    background: #152621 !important;
    border-color: rgba(53, 168, 107, 0.2) !important;
}

[data-bs-theme="dark"] .card-footer .text-muted {
    color: #7ea199 !important;
}

/* Pagination in dark mode */
[data-bs-theme="dark"] .pagination .page-link {
    background: #152621 !important;
    border-color: rgba(53, 168, 107, 0.2) !important;
    color: #d1e1de !important;
}

[data-bs-theme="dark"] .pagination .page-link:hover {
    background: rgba(31, 122, 77, 0.2) !important;
    border-color: rgba(53, 168, 107, 0.4) !important;
    color: #35A86B !important;
}

[data-bs-theme="dark"] .pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #1F7A4D 0%, #0F5F3A 100%) !important;
    border-color: #1F7A4D !important;
    color: white !important;
}

[data-bs-theme="dark"] .pagination .page-item.disabled .page-link {
    background: #0b1a16 !important;
    border-color: rgba(53, 168, 107, 0.1) !important;
    color: #344e47 !important;
}

/* ==========================================================================
   DARK MODE - BG-WHITE & BG-LIGHT BACKGROUNDS
   ========================================================================== */

[data-bs-theme="dark"] .bg-white {
    background: #152621 !important;
}

[data-bs-theme="dark"] .bg-light:not(.btn):not(.badge) {
    background: #152621 !important;
}

[data-bs-theme="dark"] .border.rounded.bg-light {
    background: #152621 !important;
    border-color: rgba(53, 168, 107, 0.2) !important;
}

/* Card headers with bg-white/bg-light */
[data-bs-theme="dark"] .card-header.bg-white,
[data-bs-theme="dark"] .card-header.bg-light {
    background: #152621 !important;
    border-color: rgba(52, 211, 153, 0.2) !important;
}

/* ==========================================================================
   DARK MODE - FORM CHECKBOXES & LABELS
   ========================================================================== */

[data-bs-theme="dark"] .form-check-label {
    color: #d1e1de !important;
}

[data-bs-theme="dark"] .form-check-input {
    background-color: #243933 !important;
    border-color: rgba(53, 168, 107, 0.3) !important;
}

[data-bs-theme="dark"] .form-check-input:checked {
    background-color: #1F7A4D !important;
    border-color: #1F7A4D !important;
}

[data-bs-theme="dark"] .form-check-input:focus {
    border-color: #35A86B !important;
    box-shadow: 0 0 0 0.25rem rgba(31, 122, 77, 0.25) !important;
}

/* Form switch in dark mode */
[data-bs-theme="dark"] .form-switch .form-check-input {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%237ea199'/%3e%3c/svg%3e") !important;
}

[data-bs-theme="dark"] .form-switch .form-check-input:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e") !important;
}

/* Table header in dark mode */
[data-bs-theme="dark"] .table-light th,
[data-bs-theme="dark"] .table-light td,
[data-bs-theme="dark"] thead.table-light {
    background: #152621 !important;
    color: #d1e1de !important;
    border-color: rgba(52, 211, 153, 0.2) !important;
}


/* ==========================================================================
   AUTH PAGES STYLES - CONSOLIDATED (Green Theme + Dark Mode Support)
   ========================================================================== */

/* Backgrounds */

.auth-page-body,
.login-background,
.register-background {
    background: var(--bg-body) !important;
    min-height: 100vh;
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}


/* Animations (keep original logic but ensure variables don't conflict) */
.login-background::before,
.register-background::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    /* Use theme primary color with low opacity for the rotating background */
    background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.03) 50%, transparent 100%);
    animation: auth-rotate 60s linear infinite;
    z-index: -1;
}

@keyframes auth-rotate { 0%{transform:rotate(0)} 100%{transform:rotate(360deg)} }



/* Cards */
.login-card,
.register-card { 
    background: var(--card-bg); 
    border: 1px solid var(--card-border); 
    border-radius: 20px; 
    overflow: hidden; 
    box-shadow: var(--card-shadow); 
    transition: transform 0.3s ease, box-shadow 0.3s ease; 
}

.login-card:hover,
.register-card:hover { 
    transform: translateY(-5px); 
    box-shadow: var(--card-shadow-hover); 
}

.login-container,
.register-container {
    margin-top: calc(var(--navbar-height, 68px) + 2rem) !important;
    margin-bottom: 3rem;
}

@media (max-width: 991.98px) {
    .login-container,
    .register-container {
        margin-top: calc(var(--navbar-mobile-height, 60px) + 1.5rem) !important;
    }
}

/* ==========================================================================
   DRIVER LOGIN PREMIUM STYLES (Adapted for Green Theme & Dark Mode)
   ========================================================================== */
    :root {
     --driver-primary: var(--rehlati-primary, #1F7A4D);
     --driver-primary-dark: var(--rehlati-primary-dark, #0F5F3A);
    --driver-accent: var(--rehlati-accent, #f59e0b);
    --driver-success: var(--rehlati-success, #1F7A4D);
    --driver-danger: var(--rehlati-danger, #ef4444);
    
    /* Mapped to Theme Variables for Dark Mode Support */
    --driver-surface: var(--card-bg, #ffffff);
    --driver-surface-alt: var(--bg-secondary, #f1f7f6);
    --driver-border: var(--border-secondary, #d1e1de);
    --driver-text: var(--text-primary, #0b1a16);
    --driver-text-muted: var(--text-muted, #517369);
    
    --driver-shadow: var(--card-shadow);
    --driver-shadow-sm: 0 4px 6px -1px rgba(31, 122, 77, 0.1);
    --driver-radius: 20px;
    --driver-radius-sm: 12px;
    --driver-radius-xs: 8px;
}

.driver-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    margin-top: var(--navbar-height) !important;
    background: var(--bg-body); /* Use theme background */
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}


/* Background floating elements - keeping them subtle */
.driver-login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 80%;
    height: 150%;
    background: radial-gradient(ellipse, rgba(16, 185, 129, 0.08) 0%, transparent 60%);
    animation: driver-bg-float 20s ease-in-out infinite;
    z-index: -1;
}

.driver-login-page::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -20%;
    width: 60%;
    height: 100%;
    background: radial-gradient(ellipse, rgba(245, 158, 11, 0.06) 0%, transparent 60%);
    animation: driver-bg-float 25s ease-in-out infinite reverse;
    z-index: -1;
}

/* HIDE GLOBAL FOOTER ON DRIVER LOGIN PAGE
   The fixed positioning of the page causes the footer to collapse to the top.
   Since this is a full-screen app-like page, we hide the main footer.
*/
.driver-login-page ~ .rehlati-footer,
.driver-login-page + footer,
footer.rehlati-footer:has(~ .driver-login-page), /* In case structure differs */
body:has(.driver-login-page) .rehlati-footer { 
    display: none !important; 
}

@keyframes driver-bg-float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(20px, 20px) rotate(5deg); }
}

.driver-login-container {
    max-width: 420px;
    width: 100%;
    position: relative;
    z-index: 10;
    margin-top: 4rem; /* Additional spacing from navbar */
    margin-bottom: 2rem;
}


.driver-login-card {
    background: var(--driver-surface);
    border-radius: var(--driver-radius);
    box-shadow: var(--driver-shadow);
    overflow: hidden;
    border: 1px solid var(--driver-border);
    backdrop-filter: blur(10px);
}

/* Header Section */
.driver-login-header {
    background: var(--rehlati-gradient-primary);
    padding: 1.5rem 1rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.driver-login-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.driver-login-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    backdrop-filter: blur(8px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    z-index: 2;
}

.driver-login-icon i {
    font-size: 1.5rem;
    color: white;
}

.driver-header-text {
    text-align: left;
    z-index: 2;
}

.driver-login-header h2 {
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    line-height: 1.2;
}

.driver-login-header p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    margin: 0;
}

/* Step Progress Indicator */
.step-progress {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: var(--driver-surface-alt);
    border-bottom: 1px solid var(--driver-border);
}

.step-progress-item {
    display: flex;
    align-items: center;
    position: relative;
}

.step-progress-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--driver-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--driver-text-muted);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

.step-progress-item.active .step-progress-dot {
    background: var(--rehlati-gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
    transform: scale(1.1);
}

.step-progress-item.completed .step-progress-dot {
    background: var(--driver-success);
    color: white;
}

.step-progress-line {
    width: 40px;
    height: 3px;
    background: var(--driver-border);
    margin: 0 8px;
    border-radius: 2px;
    transition: background 0.4s ease;
}

.step-progress-item.completed + .step-progress-item .step-progress-line,
.step-progress-item.completed .step-progress-line {
    background: var(--driver-success);
}

/* Body and Inputs */
.driver-login-body {
    padding: 2rem 1.5rem;
    background: var(--driver-surface);
    color: var(--driver-text);
}

.step-instruction {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--driver-text);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.step-instruction i {
    color: var(--driver-primary);
}

.step-container {
    display: none;
}

.step-container.active {
    display: block;
    animation: step-slide-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes step-slide-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.driver-input-group { margin-bottom: 1.5rem; }

.driver-input-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--driver-text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.driver-input-field {
    width: 100%;
    padding: 1.25rem;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.75rem;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    background: var(--driver-surface-alt);
    border: 2px solid var(--driver-border);
    border-radius: var(--driver-radius-sm);
    color: var(--driver-text);
    transition: all 0.3s ease;
    caret-color: transparent;
}

.driver-input-field:focus {
    outline: none;
    border-color: var(--driver-primary);
    background: var(--driver-surface);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

.driver-input-field.has-value {
    background: var(--driver-surface-alt);
    border-color: var(--driver-primary);
}

.pin-dots-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 1rem;
}

.pin-dot {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--driver-border);
    transition: all 0.2s ease;
}

.pin-dot.filled {
    background: var(--driver-primary);
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

/* Info Card */
.driver-info-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--driver-radius-sm);
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.driver-info-card::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
    animation: info-card-glow 4s ease-in-out infinite;
}

@keyframes info-card-glow {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(10%, 10%); }
}

.driver-info-icon {
    width: 60px; height: 60px;
    background: var(--rehlati-gradient-primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
    position: relative;
}
.driver-info-icon i { font-size: 1.5rem; color: white; }

.driver-info-label {
    font-size: 0.75rem;
    color: var(--driver-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
    position: relative;
}

.driver-info-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--driver-text);
    margin-bottom: 0.25rem;
    position: relative;
}

.driver-info-subvalue {
    font-size: 0.9rem;
    color: var(--driver-text-muted);
    position: relative;
}

/* Buttons */
.confirmation-buttons {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}

.confirm-btn {
    padding: 1rem 1.5rem; border-radius: var(--driver-radius-sm);
    font-weight: 600; font-size: 0.95rem; border: none; cursor: pointer;
    transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}

.confirm-btn-secondary {
    background: var(--driver-surface);
    border: 2px solid var(--driver-border);
    color: var(--driver-text-muted);
}
.confirm-btn-secondary:hover {
    border-color: var(--driver-danger);
    color: var(--driver-danger);
    background: var(--driver-surface-alt);
}

.confirm-btn-primary {
    background: var(--rehlati-gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.confirm-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}


/* Keyboards */
.alphanumeric-keyboard,
.numeric-keypad {
    background: var(--driver-surface-alt);
    border-radius: var(--driver-radius-sm);
    border: 1px solid var(--driver-border);
}

.alphanumeric-keyboard {
    display: flex; flex-direction: column; gap: 6px; margin-top: 1.5rem; padding: 10px;
}

.keyboard-row { display: flex; justify-content: space-between; gap: 4px; }
.keyboard-row-numbers { margin-bottom: 4px; }
.keyboard-row-actions { margin-top: 8px; }

.keyboard-btn {
    min-width: 0; 
    height: 44px; 
    padding: 0 4px; /* Reduced side padding */
    font-size: 0.9rem; /* Slightly smaller font */
    font-weight: 600; border-radius: 8px; border: none;
    background: var(--driver-surface);
    color: var(--driver-text);
    cursor: pointer; transition: all 0.15s ease;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    flex: 1; 
    max-width: none; /* Allow full flex */
}

.keyboard-btn:hover {
    background: var(--bg-secondary);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
}

.keyboard-btn:active { transform: scale(0.95); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }

.keyboard-btn-clear {
    flex: 2; max-width: none;
    background: rgba(239, 68, 68, 0.1);
    color: var(--driver-danger);
    gap: 6px;
}
.keyboard-btn-clear:hover { background: rgba(239, 68, 68, 0.2); }

.keyboard-btn-submit {
    flex: 3; /* Give more weight to proceed button */
    max-width: none;
    background: var(--rehlati-gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
    gap: 6px;
}

/* Numeric Keypad */
.numeric-keypad {
    display: none; grid-template-columns: repeat(3, 1fr); gap: 10px;
    margin-top: 1.5rem; padding: 12px;
}
.numeric-keypad .keyboard-btn {
    height: 64px; 
    font-size: 1.5rem; 
    max-width: none;
    background: var(--driver-surface);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* Footer */
.driver-login-footer {
    padding: 1.25rem 1.5rem;
    background: var(--driver-surface-alt);
    border-top: 1px solid var(--driver-border);
    text-align: center;
}
.driver-login-footer a {
    color: var(--driver-primary);
    font-weight: 600; text-decoration: none; font-size: 0.9rem;
    display: inline-flex; align-items: center; gap: 0.5rem; transition: all 0.3s ease;
}
.driver-login-footer a:hover { color: var(--driver-primary-dark); gap: 0.75rem; }

/* Modals */
.driver-modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px);
    z-index: 2000; align-items: center; justify-content: center; padding: 1rem;
    animation: modal-fade-in 0.3s ease;
}
.driver-modal-overlay.open { display: flex; }

.driver-modal {
    background: var(--driver-surface);
    border-radius: var(--driver-radius);
    width: 100%; max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: modal-slide-up 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--driver-border);
}

.driver-modal-header {
    background: var(--bg-tertiary);
    padding: 1.5rem; text-align: center;
    border-bottom: 1px solid var(--driver-primary-light);
}

.driver-modal-header-icon {
    width: 56px; height: 56px;
    background: var(--rehlati-gradient-accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.35);
}

.driver-modal-details {
    background: var(--driver-surface-alt);
    border-radius: var(--driver-radius-xs);
    padding: 1rem; margin-bottom: 1.25rem;
}

.driver-modal-detail-row {
    display: flex; justify-content: space-between; padding: 0.5rem 0;
    border-bottom: 1px solid var(--driver-border);
    font-size: 0.9rem;
}
.driver-modal-detail-row:last-child { border-bottom: none; }

.driver-modal-detail-label { color: var(--driver-text-muted); font-weight: 500; }
.driver-modal-detail-value { color: var(--driver-text); font-weight: 600; }

.driver-modal-btn-cancel {
    background: var(--driver-surface);
    border: 2px solid var(--driver-border);
    color: var(--driver-text-muted);
}
.driver-modal-btn-cancel:hover {
    background: var(--driver-surface-alt);
}

/* Animations */
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes modal-slide-up { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Loading State */
.driver-loading {
    position: relative;
    pointer-events: none;
}
.driver-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 10;
}
[data-bs-theme="dark"] .driver-loading::after {
    background: rgba(15, 23, 42, 0.8);
}




/* Headers */
.login-header,
.register-header { 
    background: var(--rehlati-gradient-primary); 
    color: var(--text-on-primary); 
    padding: 2rem; 
    text-align: center; 
    position: relative; 
    overflow: hidden; 
}

.login-header h3,
.register-header h3 {
    color: var(--text-on-primary);
    position: relative;
    z-index: 2;
    margin: 0;
    font-weight: 700;
}

.login-header p,
.register-header p {
    color: rgba(255, 255, 255, 0.9);
}

/* Forms */
.login-form,
.register-form { 
    padding: 2.5rem; 
    background: var(--card-bg); 
    color: var(--text-primary);
}

.input-group-custom { margin-bottom: 1.5rem; }

.login-form .form-label,
.register-form .form-label {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
}

.login-form .form-label i,
.register-form .form-label i {
    color: var(--rehlati-primary);
    margin-right: .5rem;
}

.login-form .form-control,
.login-form .form-select,
.register-form .form-control,
.register-form .form-select { 
    background: var(--input-bg); 
    border: 2px solid var(--border-secondary); 
    border-radius: 12px; 
    padding: 1rem 1.25rem; 
    color: var(--text-primary); 
    transition: all .3s ease; 
}

.login-form .form-control:focus,
.login-form .form-select:focus,
.register-form .form-control:focus,
.register-form .form-select:focus { 
    background: var(--input-bg); 
    border-color: var(--rehlati-primary); 
    box-shadow: 0 0 0 4px var(--input-focus-ring); 
    color: var(--text-primary); 
}

/* Dropdown options */
.login-form .form-select option,
.register-form .form-select option {
    background-color: var(--input-bg);
    color: var(--text-primary);
}

/* Auth Links and Text */
.login-link,
.register-link { color: var(--rehlati-primary); text-decoration: none; font-weight: 600; }
.login-link:hover,
.register-link:hover { color: var(--rehlati-primary-dark); }

/* Password Toggle */
.password-toggle {
    color: var(--text-muted);
    background: none;
    border: none;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}
.password-toggle:hover { color: var(--rehlati-primary); }

/* Footers */
.login-footer,
.register-footer { 
    background: var(--bg-secondary); 
    padding: 1.5rem; 
    text-align: center; 
    border-top: 1px solid var(--border-secondary); 
}
.login-footer p,
.register-footer p { color: var(--text-muted); }

/* Contractor Section and Details */
.contractor-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.contract-dropdown {
    background: var(--card-bg);
    border: 1px solid var(--border-secondary);
    box-shadow: var(--card-shadow);
}

.contract-item {
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-secondary);
}

.contract-item:hover {
    background: var(--interactive-subtle);
}

.company-details-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
}

.company-details-card h6 {
    color: var(--rehlati-primary-dark);
    border-bottom: 1px solid var(--border-primary);
}

.company-details-card strong { color: var(--text-muted); }

/* ========================================================================== */
/* DRIVER PORTAL & TABLET OPTIMIZATIONS */
/* ========================================================================== */

/* Driver Dashboard Icons */
.dashboard-icon-lg {
    width: 60px;
    height: 60px;
    font-size: 1.75rem;
    transition: all 0.3s ease;
}

/* Quick Action Buttons */
.quick-action-btn {
    padding: 1.5rem 1rem;
    font-size: 1.1rem;
    border-width: 2px;
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 600;
}
.quick-action-btn:active {
    transform: scale(0.98);
}
.quick-action-btn i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
}

/* Stats */
.stat-value {
    font-size: 2rem;
    font-weight: 800;
}

/* Card Titles */
.card-title-lg {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Status Badges */
.badge-lg {
    font-size: 0.9rem;
    padding: 0.5rem 0.8rem;
}

/* Action Buttons */
.btn-action-lg {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    min-width: 100px;
}

/* Tablet Optimizations (Landscape & Portrait: 768px - 1199px) */
@media (min-width: 768px) and (max-width: 1199px) {
    /* Larger Icons & Text for Touch */
    .dashboard-icon-lg {
        width: 70px !important;
        height: 70px !important;
        font-size: 2rem !important;
    }
    
    .stat-value {
        font-size: 2.25rem !important;
    }
    
    .quick-action-btn {
        padding: 2rem 1.5rem !important;
        font-size: 1.25rem !important;
    }
    
    .quick-action-btn i {
        font-size: 2.5rem !important;
        margin-bottom: 1rem !important;
    }

    /* Taller Rows for Table Touch Targets */
    .table td, .table th {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
        font-size: 1.1rem !important;
    }

    /* Larger Buttons */
    .btn-action-lg, .btn-lg-tablet {
        padding: 0.75rem 1.5rem !important;
        font-size: 1.1rem !important;
        min-width: 120px;
    }
    
    /* Inputs */
    .form-select-lg-tablet, .form-control-lg-tablet {
        padding: 0.75rem 1rem !important;
        font-size: 1.1rem !important;
        height: auto !important;
    }
}

/* Specific Fix for Driver Footer Overlap handled by hiding footer in driver login */
/* (Already implemented in previous sessions) */
