/* VWFi – Design System */
:root {
    --vw-blue:       #1B3A6B;
    --vw-blue-light: #2557A7;
    --vw-silver:     #C0C0C0;
    --bg:            #F4F6FA;
    --surface:       #FFFFFF;
    --border:        #E2E8F0;
    --text:          #1A202C;
    --text-muted:    #718096;
    --success:       #38A169;
    --danger:        #E53E3E;
    --radius:        10px;
    --shadow:        0 2px 8px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }

/* ── Auth layout ── */
.auth-layout        { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1B3A6B 0%, #2557A7 100%); }
.auth-container     { width: 100%; max-width: 420px; padding: 1rem; }
.auth-card          { background: var(--surface); border-radius: var(--radius); padding: 2.5rem; box-shadow: 0 8px 32px rgba(0,0,0,.2); }
.auth-logo          { text-align: center; margin-bottom: 2rem; }
.auth-logo h1       { font-size: 1.8rem; font-weight: 700; color: var(--vw-blue); margin-top: .5rem; }
.auth-logo p        { color: var(--text-muted); margin-top: .25rem; }
.auth-link          { text-align: center; margin-top: 1.5rem; color: var(--text-muted); }
.auth-link a        { color: var(--vw-blue-light); text-decoration: none; font-weight: 600; }

/* ── Navbar ── */
.navbar             { display: flex; align-items: center; gap: 2rem; background: var(--vw-blue); color: white; padding: .75rem 1.5rem; position: sticky; top: 0; z-index: 200; }
.navbar-brand       { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: white; font-weight: 700; font-size: 1.1rem; flex-shrink: 0; }
.navbar-menu        { display: flex; gap: .25rem; list-style: none; flex: 1; }
.navbar-menu a      { color: rgba(255,255,255,.8); text-decoration: none; padding: .4rem .75rem; border-radius: 6px; transition: background .15s; }
.navbar-menu a:hover,
.navbar-menu a.active { background: rgba(255,255,255,.15); color: white; }
.navbar-user        { display: flex; align-items: center; gap: 1rem; flex-shrink: 0; }
.navbar-user span   { color: rgba(255,255,255,.8); font-size: .875rem; }
.nav-hamburger      { display: none; }
.nav-overlay        { display: none; }

/* ── App layout ── */
.main-content       { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* ── Forms ── */
.form-group         { margin-bottom: 1.25rem; }
.form-group label   { display: block; font-weight: 600; margin-bottom: .4rem; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: .6rem .875rem; border: 1.5px solid var(--border);
    border-radius: 7px; font-size: 14px; transition: border .15s;
    background: var(--surface);
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--vw-blue-light); box-shadow: 0 0 0 3px rgba(37,87,167,.15); }

/* ── Buttons ── */
.btn                { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.1rem; border-radius: 7px; font-size: .875rem; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: background .15s, transform .1s; }
.btn:active         { transform: scale(.98); }
.btn-primary        { background: var(--vw-blue); color: white; }
.btn-primary:hover  { background: var(--vw-blue-light); }
.btn-outline        { background: transparent; border: 1.5px solid rgba(255,255,255,.6); color: white; }
.btn-outline:hover  { background: rgba(255,255,255,.1); }
.btn-block          { width: 100%; justify-content: center; padding: .75rem; font-size: 1rem; }
.btn-sm             { padding: .35rem .75rem; font-size: .8rem; }

/* ── Alerts ── */
.alert              { padding: .75rem 1rem; border-radius: 7px; margin-bottom: 1rem; font-size: .875rem; }
.alert-error        { background: #FFF5F5; border: 1px solid #FED7D7; color: var(--danger); }
.alert-success      { background: #F0FFF4; border: 1px solid #C6F6D5; color: var(--success); }

/* ── Cards ── */
.card               { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header        { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-header h3     { font-size: 1rem; font-weight: 600; }

/* ── Stats grid ── */
.stats-grid         { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card          { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; text-align: center; box-shadow: var(--shadow); }
.stat-icon          { font-size: 1.75rem; margin-bottom: .5rem; }
.stat-value         { font-size: 1.75rem; font-weight: 700; color: var(--vw-blue); line-height: 1; }
.stat-label         { font-size: .8rem; color: var(--text-muted); margin-top: .4rem; }

/* ── Dashboard grid ── */
.dashboard-grid     { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }

/* ── Table ── */
.table              { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th           { font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: #F8FAFC; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td  { background: #F8FAFC; }

/* ── Info list ── */
.info-list          { display: grid; grid-template-columns: 1fr 2fr; gap: .5rem 1rem; padding: 1.25rem; }
.info-list dt       { font-weight: 600; color: var(--text-muted); font-size: .85rem; }
.info-list dd       { font-size: .9rem; }

/* ── Page header ── */
.page-header        { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h2     { font-size: 1.4rem; font-weight: 700; }
.vehicle-selector select { padding: .4rem .75rem; border: 1.5px solid var(--border); border-radius: 7px; font-size: .875rem; cursor: pointer; }

/* ── Empty state ── */
.empty-state        { text-align: center; padding: 4rem 2rem; }
.empty-state h3     { margin: 1rem 0 .5rem; font-size: 1.2rem; }
.empty-state p      { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Utility ── */
.text-muted         { color: var(--text-muted); }
.p-4                { padding: 1rem; }

/* ── Status card ── */
.status-card        { margin-bottom: 0; }
.status-inner       { display: flex; gap: 2rem; padding: 1.25rem 1.5rem; align-items: center; }
.status-battery     { display: flex; flex-direction: column; align-items: center; min-width: 110px; }
.batt-pct           { font-size: 2.5rem; font-weight: 800; line-height: 1; }
.batt-bar-wrap      { width: 100%; height: 10px; background: #E2E8F0; border-radius: 5px; margin: .5rem 0; overflow: hidden; }
.batt-bar-fill      { height: 100%; border-radius: 5px; transition: width .4s; }
.batt-range         { font-size: .875rem; color: var(--text-muted); }
.status-info        { flex: 1; }
.status-dl          { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; margin-top: .75rem; }
.status-dl dt       { color: var(--text-muted); font-size: .8rem; }
.status-dl dd       { font-weight: 600; font-size: .875rem; }
.status-updated     { padding: .5rem 1.5rem; border-top: 1px solid var(--border); font-size: .75rem; color: var(--text-muted); }

/* ── Badges ── */
.badge              { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .75rem; border-radius: 99px; font-size: .8rem; font-weight: 700; }
.badge-charging     { background: #F0FFF4; color: #276749; border: 1px solid #C6F6D5; }
.badge-plugged      { background: #EBF8FF; color: #2C5282; border: 1px solid #BEE3F8; }
.badge-idle         { background: #F7FAFC; color: var(--text-muted); border: 1px solid var(--border); }

/* ── Two-column dashboard row ── */
.dash-two-col       { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

/* ── Filter tabs ── */
.filter-tabs        { display: flex; gap: .35rem; }
.filter-tab         { padding: .4rem 1rem; border-radius: 7px; font-size: .875rem; font-weight: 600; text-decoration: none; color: var(--text-muted); border: 1.5px solid var(--border); background: var(--surface); transition: all .15s; }
.filter-tab.active,
.filter-tab:hover   { background: var(--vw-blue); color: white; border-color: var(--vw-blue); }

/* ── Utility ── */
.nowrap             { white-space: nowrap; }
.show-mobile        { display: none; }
.show-mobile-block  { display: none; }
.hide-mobile-block  { display: block; }

/* ── Live charging card ── */
.live-dot           { display:inline-block; width:10px; height:10px; background:#38A169; border-radius:50%; animation: livepulse 1.4s ease-in-out infinite; flex-shrink:0; }
@keyframes livepulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.3)} }
.live-charge-grid   { display:grid; grid-template-columns:repeat(4,1fr); gap:0; border-bottom:1px solid #C6F6D5; }
.live-stat          { padding:.9rem 1.25rem; border-right:1px solid #C6F6D5; }
.live-stat:last-child { border-right:none; }
.live-stat span     { display:block; font-size:.75rem; color:#276749; margin-bottom:.2rem; }
.live-stat strong   { font-size:1.1rem; font-weight:700; color:#1a202c; }
@media(max-width:600px) {
    .live-charge-grid { grid-template-columns:1fr 1fr; }
    .live-stat:nth-child(2n) { border-right:none; }
    .live-stat:nth-child(1),.live-stat:nth-child(2) { border-bottom:1px solid #C6F6D5; }
}

/* ── Charge session cards (mobile) ── */
.charge-cards       { display: none; flex-direction: column; gap: .75rem; }
.charge-card        { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.charge-card-active { background: #F0FFF4; border-color: #C6F6D5; }
.charge-card-head   { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.charge-card-time   { color: var(--text-muted); font-size: .85rem; margin-left: .5rem; }
.charge-card-stats  { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.charge-stat        { padding: .6rem 1rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.charge-stat:nth-child(2n) { border-right: none; }
.charge-stat:nth-last-child(-n+2) { border-bottom: none; }
.charge-stat span   { display: block; font-size: .75rem; color: var(--text-muted); margin-bottom: .15rem; }
.charge-stat strong { font-size: .9rem; }

/* ── Leaflet map isolation ──
   Contain Leaflet's internal z-indexes (400-600) so they never
   escape the map container and overlap the navbar/overlay.        */
#map,
.leaflet-container  { isolation: isolate; position: relative; z-index: 0; }

/* ── Mobile ── */
@media (max-width: 768px) {
    /* Navbar */
    .navbar             { padding: .7rem 1rem; gap: 0; justify-content: space-between; }
    .navbar-menu        {
        display: flex; flex-direction: column; list-style: none;
        position: fixed; top: 0; right: -260px; width: 260px; height: 100vh;
        background: var(--vw-blue); padding: 5rem 1.25rem 2rem;
        transition: right .25s ease; z-index: 190; gap: .25rem;
        box-shadow: -4px 0 20px rgba(0,0,0,.25);
    }
    .navbar-menu.nav-open { right: 0; }
    .navbar-menu a      { display: block; padding: .75rem 1rem; border-radius: 8px; font-size: 1rem; color: rgba(255,255,255,.85); }
    .navbar-menu a.active,
    .navbar-menu a:hover { background: rgba(255,255,255,.15); color: white; }
    .navbar-user        { display: none; }

    /* Hamburger button */
    .nav-hamburger {
        display: flex; flex-direction: column; justify-content: center; gap: 5px;
        background: none; border: none; cursor: pointer; padding: .4rem; z-index: 210;
    }
    .nav-hamburger span {
        display: block; width: 24px; height: 2px; background: white;
        border-radius: 2px; transition: transform .2s, opacity .2s;
        transform-origin: center;
    }
    .nav-hamburger.nav-toggle-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .nav-hamburger.nav-toggle-open span:nth-child(2) { opacity: 0; }
    .nav-hamburger.nav-toggle-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    /* Overlay */
    .nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 180; }
    .nav-overlay.nav-overlay-open { display: block; }

    /* Layout */
    .main-content       { padding: 1rem; }
    .stats-grid         { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
    .dash-two-col       { grid-template-columns: 1fr; }
    .status-inner       { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .page-header        { flex-wrap: wrap; gap: .5rem; }
    .filter-tabs        { flex-wrap: wrap; }
    .table th, .table td { padding: .5rem .65rem; font-size: .8rem; }
    .card-header        { flex-wrap: wrap; gap: .5rem; }
    .table .hide-mobile { display: none; }
    .show-mobile        { display: inline !important; }
    .hide-mobile        { display: none !important; }
    .show-mobile-block  { display: block !important; }
    .charge-cards       { display: flex !important; }
    .hide-mobile-block  { display: none !important; }
}
