/* --- HEADER --- */
header { display: flex; align-items: center; gap: 20px; padding: 0 40px; height: 80px; background: var(--glass-bg); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(0,0,0,0.05); position: fixed; width: 100%; top: 0; z-index: 1000; justify-content: space-between; }
.logo { display: flex; align-items: center; text-decoration: none; gap: 10px; cursor: pointer; min-width: 140px; }
.site-logo { height: 45px; width: auto; object-fit: contain; }

.header-account-btn { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 50px; background: #F1F5F9; color: var(--dark); font-weight: 600; font-size: 13px; cursor: pointer; transition: 0.3s; margin-right: 10px; text-decoration: none; }
.header-account-btn:hover { background: #E2E8F0; color: var(--primary); }

.mode-switch-container { display: flex; align-items: center; gap: 12px; margin-left: 20px; background: #EFF6FF; padding: 6px 16px; border-radius: 50px; border: 1px solid #DBEAFE; }
.mode-label { font-size: 12px; font-weight: 700; color: #94A3B8; text-transform: uppercase; transition: 0.3s; }
.mode-label.active { color: var(--primary); }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #CBD5E1; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

.refresh-btn { width: 40px; height: 40px; border-radius: 50%; background: #F1F5F9; border: 1px solid #E2E8F0; display: flex; align-items: center; justify-content: center; color: var(--secondary); cursor: pointer; transition: 0.3s; margin-right: 10px; }
.refresh-btn:hover { background: #E2E8F0; color: var(--primary); }
.refresh-btn i.spinning { animation: spin 1s linear infinite; }

.header-search-bar { flex: 1; max-width: 350px; background: #F1F5F9; border-radius: 12px; padding: 12px 20px; display: flex; align-items: center; gap: 12px; color: #64748B; cursor: pointer; transition: 0.3s; margin-left: 20px; border: 1px solid transparent; }
.header-search-bar:hover { background: #fff; border-color: var(--primary-light); box-shadow: var(--shadow-lg); }
.header-search-text { font-size: 14px; font-weight: 500; }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 16px; }

.user-menu-container { position: relative; }
.user-menu { width: 45px; height: 45px; border-radius: 50%; background: #F1F5F9; display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--primary); cursor: pointer; transition: 0.3s; border: 2px solid transparent; }
.user-menu:hover { background: var(--primary-light); border-color: var(--primary); }
.user-menu.logged-in { background: var(--primary); color: white; font-weight: 700; font-size: 16px; }

.profile-popup { display: none; position: absolute; top: 60px; right: 0; background: white; width: 260px; border-radius: 20px; box-shadow: 0 20px 40px rgba(0,0,0,0.15); border: 1px solid #F1F5F9; z-index: 1100; overflow: hidden; animation: fadeIn 0.2s ease-out; padding: 20px; }
.profile-popup.active { display: block; }
.popup-header { text-align: center; margin-bottom: 20px; border-bottom: 1px solid #F1F5F9; padding-bottom: 15px; }
.popup-header h4 { margin: 0; color: var(--dark); font-size: 18px; }
.popup-header p { margin: 5px 0 0; color: var(--secondary); font-size: 13px; }
.popup-btn { display: block; width: 100%; padding: 12px; margin-bottom: 10px; border-radius: 12px; text-align: center; font-weight: 600; font-size: 14px; cursor: pointer; transition: 0.2s; text-decoration: none; border: none; }
.popup-btn-outline { background: white; border: 2px solid var(--primary); color: var(--primary); }
.popup-btn-outline:hover { background: #F3E8FF; }
.popup-btn-solid { background: var(--primary); color: white; }
.popup-btn-solid:hover { background: var(--primary-dark); }
.popup-item { display: flex; align-items: center; gap: 10px; padding: 12px; color: var(--dark); font-size: 14px; cursor: pointer; border-radius: 8px; transition: 0.2s; }
.popup-item:hover { background: #F8FAFC; color: var(--primary); }

/* =========================================
    📱 MOBILE RESPONSIVE HEADER FIXES 
========================================= */
@media screen and (max-width: 768px) {
    header { 
        display: grid !important; 
        grid-template-columns: 1fr auto; 
        gap: 10px; 
        height: auto; 
        padding: 10px 15px; 
        align-content: center;
    }
    .logo { grid-column: 1; grid-row: 1; align-self: center; }
    .nav-actions { grid-column: 2; grid-row: 1; display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-left: auto; }
    .user-menu { width: 40px; height: 40px; font-size: 18px; margin: 0; }
    
    /* 1. PASSENGER VIEW CONFIGURATION */
    .header-search-bar { 
        display: flex !important; /* Force Show "Where to?" */
        grid-column: 1 / -1; 
        grid-row: 2; 
        margin: 5px 0 0 0; 
        width: 100%; 
        max-width: 100%;
        z-index: 100;
    }
    
    .btn-header.driver-only { 
        display: none !important; /* Force Hide "Publish Ride" */
    }

    /* 2. DRIVER VIEW CONFIGURATION (When body has .driver-mode) */
    body.driver-mode .header-search-bar {
        display: none !important; /* Hide "Where to?" */
    }

    body.driver-mode .btn-header.driver-only { 
        display: flex !important; /* Force Show "Publish Ride" */
        position: absolute; 
        left: 15px; 
        right: 15px; 
        top: 65px; 
        height: 48px; 
        justify-content: center; 
        z-index: 1001; /* High Z-Index to ensure it's clickable */
        margin: 0; 
        width: auto;
    }
    
    /* 3. TOGGLE SWITCH POSITIONING */
    .mode-switch-container { 
        grid-column: 1 / -1; 
        grid-row: 3; 
        margin: 5px 0 0 0; 
        width: 100%; 
        justify-content: center; 
    }
    
    /* Push toggle down ONLY when in Driver mode to make room for the Publish button */
    body.driver-mode .mode-switch-container { 
        margin-top: 60px; 
    } 
    
    /* 4. GENERAL CLEANUP */
    .refresh-btn, .header-account-btn, .btn-header.passenger-only { display: none !important; }
    
    /* 🟢 FIX: Dynamically adjust top gap based on Passenger vs Driver mode to eliminate white space! */
    .page-section { padding-top: 130px !important; } /* Passenger mode height */
    body.driver-mode .page-section { padding-top: 75px !important; } /* Driver mode shorter height */

    .split-layout { padding-top: 0 !important; height: calc(100vh - 130px) !important; }
    body.driver-mode .split-layout { height: calc(100vh - 75px) !important; }
    
    /* 🟢 FIX: Corrected the 105% overlap issue (55% Map + 45% Sidebar = 100%) */
    .ride-map-container { top: 0 !important; height: 55% !important; }
    .ride-sidebar { bottom: 0 !important; height: 45% !important; border-top: 1px solid #E2E8F0; }
}
