:root {
    /* Material Design 3 Tokens - Light Palette */
    --md-sys-color-primary: #4F46E5;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #E0E7FF;
    --md-sys-color-on-primary-container: #312E81;
    --md-sys-color-secondary: #7C3AED;
    --md-sys-color-tertiary: #10B981;
    --md-sys-color-error: #EF4444;
    --md-sys-color-background: #F8FAFC;
    --md-sys-color-on-background: #0F172A;
    --md-sys-color-surface: #FFFFFF;
    --md-sys-color-on-surface: #0F172A;
    --md-sys-color-surface-variant: #F1F5F9;
    --md-sys-color-on-surface-variant: #64748B;
    --md-sys-color-outline: #CBD5E1;
    --md-sys-color-outline-variant: #E2E8F0;
    --md-sys-color-shadow: rgba(0, 0, 0, 0.08);
    --sidebar-width: 280px;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] {
    --md-sys-color-primary: #818CF8;
    --md-sys-color-on-primary: #1E1B4B;
    --md-sys-color-primary-container: #312E81;
    --md-sys-color-on-primary-container: #E0E7FF;
    --md-sys-color-background: #0F172A;
    --md-sys-color-on-background: #F8FAFC;
    --md-sys-color-surface: #1E293B;
    --md-sys-color-on-surface: #F8FAFC;
    --md-sys-color-surface-variant: #334155;
    --md-sys-color-on-surface-variant: #94A3B8;
    --md-sys-color-outline: #475569;
    --md-sys-color-outline-variant: #334155;
    --md-sys-color-shadow: rgba(0, 0, 0, 0.3);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* Elevated Cards with Soft Shadows */
.card, .login-card, .stat-card {
    background-color: var(--md-sys-color-surface);
    border: none;
    border-radius: 24px;
    box-shadow: 0 4px 6px var(--md-sys-color-shadow), 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px var(--md-sys-color-shadow);
}

/* Modern Sidebar - Light Theme */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    border-right: 1px solid var(--md-sys-color-outline-variant);
    padding: 24px 16px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--md-sys-color-outline-variant) transparent;
}

#sidebar::-webkit-scrollbar {
    width: 4px;
}

#sidebar::-webkit-scrollbar-thumb {
    background: var(--md-sys-color-outline-variant);
    border-radius: 10px;
}

.sidebar-section-title {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--md-sys-color-on-surface-variant);
    margin: 24px 0 8px 20px;
    opacity: 0.7;
}

#content {
    margin-left: var(--sidebar-width);
    padding: 32px;
}

.nav-link {
    color: var(--md-sys-color-on-surface-variant);
    padding: 12px 20px;
    border-radius: 12px;
    margin: 4px 0;
    display: flex;
    align-items: center;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}

.nav-link i {
    width: 24px;
    font-size: 18px;
    margin-right: 12px;
}

.nav-link:hover {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-primary);
}

.nav-link.active {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-primary);
}

.nav-link.text-danger:hover {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-error);
}

/* Floating Label Animation */
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: var(--md-sys-color-primary);
    transform: scale(0.85) translateY(-0.75rem) translateX(0.15rem);
}

.form-control {
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 12px;
    padding: 12px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 4px var(--md-sys-color-primary-container);
    outline: none;
}

/* Pill Shaped Buttons with Ripple Mock */
.btn {
    border-radius: 9999px;
    padding: 10px 24px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.btn-primary:hover {
    background-color: #4338CA;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

/* Material Switch */
.form-switch .form-check-input {
    width: 52px;
    height: 32px;
    border-radius: 16px;
    background-color: var(--md-sys-color-outline);
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.form-switch .form-check-input:checked {
    background-color: var(--md-sys-color-primary);
}

/* Dashboard Utils */
.stat-card .icon-box {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.transition-up:hover {
    transform: translateY(-8px);
}

/* Map Style Overlay */
#map {
    border-radius: 24px;
    border: 1px solid var(--md-sys-color-outline-variant);
}

/* Mobile Toggle */
#sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    padding: 0;
    margin-right: 15px;
    flex-shrink: 0 !important;
}

/* Responsive Adjustments */
@media (max-width: 991.98px) {
    :root {
        --sidebar-width: 0px;
    }

    #sidebar {
        left: -280px;
        transition: left 0.3s ease;
        width: 280px;
        box-shadow: 20px 0 50px rgba(0,0,0,0.1);
    }

    #sidebar.show {
        left: 0;
    }

    #content {
        margin-left: 0;
        padding: 20px 15px;
    }

    #sidebar-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        flex-shrink: 0 !important;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }

    .sidebar-overlay.show {
        display: block;
    }

    header h2 {
        font-size: 1.5rem;
    }

    .stat-card {
        margin-bottom: 10px;
    }
}

@media (max-width: 575.98px) {
    header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 15px;
    }

    header .d-flex {
        width: 100%;
        justify-content: space-between;
    }

    .health-pill {
        font-size: 0.6rem;
        padding: 4px 10px;
    }
}

/* Firebase Search Dropdown */
.firebase-search-dropdown {
    position: absolute;
    left: 0;
    width: 100%;
    z-index: 2000;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--md-sys-color-outline-variant);
    max-height: 300px;
    overflow-y: auto;
    margin-top: 4px;
}

.firebase-search-dropdown .dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    transition: background-color 0.2s;
}

.firebase-search-dropdown .dropdown-item:last-child {
    border-bottom: none;
}

.firebase-search-dropdown .dropdown-item:hover {
    background-color: var(--md-sys-color-surface-variant);
}

/* Toast System (Material 3 Style) */
#live-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.live-toast {
    pointer-events: auto;
    width: 350px;
    background: var(--md-sys-color-surface);
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
    padding: 16px;
    position: relative;
    overflow: hidden;
    animation: slideInRight 0.4s cubic-bezier(0, 0, 0.2, 1);
    transition: transform 0.3s, opacity 0.3s;
}

.live-toast.fade-out {
    opacity: 0;
    transform: translateX(20px);
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.live-toast-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    flex-shrink: 0;
}

.toast-ride .live-toast-icon { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-primary); }
.toast-booking .live-toast-icon { background: #DCFCE7; color: #166534; }
.toast-chat .live-toast-icon { background: #F0E6FF; color: #7C3AED; }
.toast-success .live-toast-icon { background: #DCFCE7; color: #166534; }
.toast-danger .live-toast-icon { background: #FEE2E2; color: #991B1B; }

.live-toast-content {
    flex-grow: 1;
    cursor: pointer;
}

.live-toast-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
    color: var(--md-sys-color-on-surface);
}

.live-toast-message {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.4;
}

.live-toast-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    padding: 0 0 0 12px;
    line-height: 1;
}

.live-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: var(--md-sys-color-primary);
    transform-origin: left;
    animation: progressLinear linear forwards;
}

.toast-danger .live-toast-progress { background: #EF4444; }
.toast-booking .live-toast-progress { background: #22C55E; }

@keyframes progressLinear {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Sidebar Badges */
.nav-link {
    position: relative;
}

.badge-count {
    background-color: var(--md-sys-color-error);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 15px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Dashboard Enhancements */
.health-pill {
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}
.health-online { background: #DCFCE7; color: #166534; }
.health-offline { background: #FEE2E2; color: #991B1B; }
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: dotPulse 1.5s infinite;
}
@keyframes dotPulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

.activity-feed {
    height: 500px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--md-sys-color-outline) transparent;
}
.activity-feed::-webkit-scrollbar { width: 6px; }
.activity-feed::-webkit-scrollbar-thumb { background: var(--md-sys-color-outline); border-radius: 10px; }

.feed-item {
    padding: 14px;
    border-radius: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface);
    transition: all 0.2s;
}
.feed-item:hover {
    background: var(--md-sys-color-surface-variant);
    transform: translateX(4px);
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

.glass-card {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border) !important;
}

/* Copilot UI */
#copilot-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(79, 70, 229, 0.4);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#copilot-trigger:hover {
    transform: scale(1.1) rotate(5deg);
}

#copilot-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 500px;
    display: none;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
    animation: slideUpFade 0.4s cubic-bezier(0, 0, 0.2, 1);
}

@keyframes slideUpFade {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.copilot-header {
    background: var(--md-sys-color-primary);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.copilot-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg {
    max-width: 85%;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 0.9rem;
}

.msg-ai {
    align-self: flex-start;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
    border-bottom-left-radius: 4px;
}

.msg-user {
    align-self: flex-end;
    background: var(--md-sys-color-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.copilot-input {
    padding: 15px;
    background: var(--md-sys-color-surface);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    gap: 10px;
}

.search-box-container {
    position: relative;
}
.search-box-container i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-sys-color-on-surface-variant);
}
.search-box-container .form-control {
    padding-left: 40px;
}

/* Document Previews */
.doc-preview {
    cursor: pointer;
    background-color: var(--md-sys-color-surface-variant);
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cursor-zoom {
    cursor: zoom-in;
}

.doc-preview:hover {
    background-color: var(--md-sys-color-outline-variant);
}

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

.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.doc-preview:hover .preview-overlay {
    opacity: 1;
}

#lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

