/*
 * BusPlus shared styles, loaded on every page (including the admin page).
 * Holds the colour/spacing variables, the page shell, the buttons and pop-up
 * window used by the admin page, and the look of everything google_maps_helper.js
 * draws on a map (bus markers, GPS dot, Home dot, popups, layer buttons).
 */

:root {
    --bg-primary: #f8fafc;
    --bg-muted: #f1f5f9;
    --border-subtle: #e2e8f0;
    --border-focus: #cbd5e1;

    --text-primary: var(--bp-text);
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --brand-primary: #1e40af;       /* University deep blue */

    --accent-emerald: #059669;      /* success */
    --accent-amber: #d97706;        /* warning */

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.03);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Page shell from base.html: <div class="app-container"><main class="app-main"> */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;   /* phones: the visible height, without the browser's bars */
}

/* The page content fills the height left over (lets full-screen maps use height: 100%) */
.app-main {
    flex: 1;
}

/* ==========================================================================
   Buttons and pop-up window (used by the admin page)
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    line-height: 1.25;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--brand-primary);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: #1d4ed8;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.25);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--text-primary);
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

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

.btn-amber {
    background-color: var(--accent-amber);
    color: #ffffff;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

/* Dimmed full-screen layer; add .active to show it and its .modal-card */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #ffffff;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-subtle);
    padding: 1.75rem;
    transform: translateY(10px);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

/* ==========================================================================
   Map pieces drawn by google_maps_helper.js
   ========================================================================== */

/* Map / Satellite / Traffic: a compact stack of icon buttons on the right, under the top bar */
.gmap-layer-selector {
    position: absolute;
    top: 68px;
    right: 12px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
}

.gmap-layer-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    border-radius: 10px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.gmap-layer-btn.active {
    background: var(--bp-brand);
    color: #ffffff;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--bp-brand) 35%, transparent);
}

.gmap-layer-btn:hover:not(.active) {
    background: #f1f5f9;
    color: var(--bp-text);
}

.gmap-layer-ico {
    width: 19px;
    height: 19px;
}

/* Small "Google Maps · Khulna Transit" label in the bottom-right corner
   (three classes so its margin beats leaflet.css's corner spacing) */
.leaflet-container .leaflet-control.gmap-attrib-pill {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    color: #334155;
    margin: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* Live bus marker: circle in the bus's colour (--bus-color), pulse ring, heading arrow, speed tag */
.gmap-bus-container {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gmap-bus-pulse-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--bus-color, var(--bp-brand));
    animation: gmapPulse 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    pointer-events: none;
}

@keyframes gmapPulse {
    0% { transform: scale(0.7); opacity: 0.9; }
    100% { transform: scale(2.2); opacity: 0; }
}

.gmap-bus-body {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bus-color, var(--bp-brand));
    border: 2.5px solid #ffffff;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--bus-color, var(--bp-brand)) 45%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 0;
    position: relative;
    z-index: 2;
    transition: transform 0.4s ease;
}

/* Turns with the bus (the script sets rotate(heading)); only the arrow moves, the icon stays upright */
.gmap-bus-heading {
    position: absolute;
    inset: 0;
    pointer-events: none;
    /* turned every frame by google_maps_helper.js: no CSS transition */
}

.gmap-bus-heading-arrow {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 7px solid var(--bus-color, var(--bp-brand));
    filter: drop-shadow(0 -1px 2px rgba(0, 0, 0, 0.25));
}

.gmap-bus-speed-tag {
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bp-text);
    color: #ffffff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 6px;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    z-index: 3;
}

/* Rider's own GPS position ("Locate Me"): blue dot with a pulsing halo */
.gmap-student-beacon {
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gmap-student-beacon-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #0284c7;
    border: 2.5px solid #ffffff;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.5);
    z-index: 2;
}

.gmap-student-beacon-wave {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: rgba(2, 132, 199, 0.3);
    animation: gmapStudentPulse 1.8s ease-out infinite;
    z-index: 1;
}

@keyframes gmapStudentPulse {
    0% { transform: scale(0.6); opacity: 1; }
    100% { transform: scale(2.0); opacity: 0; }
}

/* Home on the map: just a small dark dot */
.gmap-home-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #111827;
    border: 3px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

/* Popups (bus details on the driver map, "Your Live Location"); .leaflet-container beats leaflet.css */
.leaflet-container .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: 14px;
    box-shadow: 0 12px 30px -4px rgba(15, 23, 42, 0.18), 0 4px 10px -2px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(226, 232, 240, 0.85);
    padding: 0;
    overflow: hidden;
}

.leaflet-container .leaflet-popup-content {
    margin: 12px 14px;
    line-height: 1.4;
}

.leaflet-container .leaflet-popup-tip {
    background: #ffffff;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.15);
}

.gmap-card-popup {
    font-family: var(--font-sans);
}

.gmap-card-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.gmap-card-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--bp-text);
    margin: 0;
}

.gmap-badge-live {
    background: #ecfdf5;
    color: #059669;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 9999px;
    border: 1px solid #a7f3d0;
}

/* Bus name line under the popup title (two classes so it beats leaflet.css's "popup p" margin) */
.gmap-card-popup .gmap-card-sub {
    margin: 2px 0 6px;
    font-weight: 700;
    color: #1e40af;
    font-size: 0.875rem;
}

.gmap-card-metric {
    font-size: 0.775rem;
    color: #475569;
}

/* ---- BusPlus logo (templates/_ui.html: logo) and line icons (icon) ---- */
.bp-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    background: var(--bp-brand);
    border-radius: 28%;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}
.bp-logo-bus { line-height: 1; }
.bp-logo-sm { width: 36px; height: 36px; }
.bp-logo-sm .bp-logo-bus { font-size: 21px; }
.bp-logo-md { width: 48px; height: 48px; }
.bp-logo-md .bp-logo-bus { font-size: 28px; }
.bp-logo-lg { width: 88px; height: 88px; border-radius: 24px; }
.bp-logo-lg .bp-logo-bus { font-size: 52px; }

.bp-icon {
    width: 20px;
    height: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* A live bus whose phone has sent nothing for a while (google_maps_helper.js: STALE_S) */
.gmap-bus-container.is-stale {
    filter: grayscale(1);
    opacity: 0.55;
}
.gmap-bus-container.is-stale .gmap-bus-pulse-ring {
    display: none;
}
