/* =====================================================
   Bus Stop Alert – Stylesheet
   Vibrant transit-orange + deep navy palette
   ===================================================== */

/* ── Tokens ── */
:root {
    --bsa-orange:       #FF6B35;
    --bsa-orange-dark:  #E55A26;
    --bsa-navy:         #0D1B2A;
    --bsa-navy-mid:     #1A2E45;
    --bsa-teal:         #17C3B2;
    --bsa-green:        #2ECC71;
    --bsa-red:          #E74C3C;
    --bsa-amber:        #F39C12;
    --bsa-bg:           #F5F7FA;
    --bsa-surface:      #FFFFFF;
    --bsa-border:       #DDE3EC;
    --bsa-text:         #1A2E45;
    --bsa-muted:        #6B7C93;
    --bsa-radius:       14px;
    --bsa-shadow:       0 4px 20px rgba(13,27,42,0.10);
    --bsa-shadow-lg:    0 8px 40px rgba(13,27,42,0.18);
    --bsa-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Wrapper ── */
.bsa-app {
    font-family: var(--bsa-font);
    color: var(--bsa-text);
    max-width: 540px;
    margin: 0 auto;
    position: relative;
    min-height: 500px;
}

/* ── Screens ── */
.bsa-screen {
    display: none;
    animation: bsa-fadeIn 0.35s ease;
}
.bsa-screen--active {
    display: block;
}
@keyframes bsa-fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Brand hero ── */
.bsa-brand {
    text-align: center;
    padding: 40px 20px 28px;
    background: linear-gradient(135deg, var(--bsa-navy) 0%, var(--bsa-navy-mid) 100%);
    border-radius: var(--bsa-radius) var(--bsa-radius) 0 0;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.bsa-brand::after {
    content: '';
    position: absolute;
    bottom: -20px; left: 0; right: 0;
    height: 40px;
    background: var(--bsa-bg);
    border-radius: 50% 50% 0 0 / 40px 40px 0 0;
}
.bsa-bus-icon {
    font-size: 52px;
    line-height: 1;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}
.bsa-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0 0 6px;
    color: #fff;
}
.bsa-tagline {
    font-size: 14px;
    color: rgba(255,255,255,0.70);
    margin: 0;
}

/* ── Cards ── */
.bsa-card {
    background: var(--bsa-surface);
    border: 1px solid var(--bsa-border);
    border-radius: var(--bsa-radius);
    padding: 24px;
    box-shadow: var(--bsa-shadow);
}
.bsa-setup-card {
    margin: 28px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ── Label ── */
.bsa-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--bsa-text);
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}
.bsa-label-icon { font-size: 18px; }

/* ── Search input ── */
.bsa-search-wrap {
    position: relative;
}
.bsa-input {
    width: 100%;
    padding: 13px 42px 13px 16px;
    border: 2px solid var(--bsa-border);
    border-radius: 10px;
    font-size: 15px;
    font-family: var(--bsa-font);
    color: var(--bsa-text);
    background: var(--bsa-bg);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.bsa-input:focus {
    border-color: var(--bsa-orange);
    box-shadow: 0 0 0 3px rgba(255,107,53,0.15);
    background: #fff;
}
.bsa-clear-btn {
    position: absolute;
    right: 12px; top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--bsa-muted);
    font-size: 15px;
    padding: 4px;
    line-height: 1;
}
.bsa-clear-btn:hover { color: var(--bsa-red); }

/* Google autocomplete dropdown style override */
.pac-container {
    border-radius: 10px !important;
    box-shadow: var(--bsa-shadow-lg) !important;
    border: 1px solid var(--bsa-border) !important;
    margin-top: 4px;
    font-family: var(--bsa-font) !important;
}
.pac-item { padding: 10px 14px !important; cursor: pointer; }
.pac-item:hover { background: #FFF3EF !important; }
.pac-icon { margin-right: 10px !important; }

/* ── Selected place chip ── */
.bsa-selected-place {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #F0FDF4;
    border: 1px solid #86EFAC;
    border-radius: 10px;
    padding: 12px 14px;
}
.bsa-place-icon { font-size: 20px; line-height: 1.4; }
.bsa-place-info { display: flex; flex-direction: column; gap: 2px; }
.bsa-place-info strong { font-size: 14px; color: var(--bsa-text); }
.bsa-place-info small  { font-size: 12px; color: var(--bsa-muted); }

/* ── Slider ── */
.bsa-distance-row { display: flex; flex-direction: column; gap: 8px; }
.bsa-label-small { font-size: 13px; color: var(--bsa-muted); }
.bsa-label-small strong { color: var(--bsa-orange); font-size: 15px; }
.bsa-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--bsa-orange) 0%, var(--bsa-orange) 40%, var(--bsa-border) 40%);
    outline: none;
    cursor: pointer;
}
.bsa-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--bsa-orange);
    box-shadow: 0 2px 8px rgba(255,107,53,0.45);
    border: 3px solid #fff;
    cursor: pointer;
    transition: transform 0.15s;
}
.bsa-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.bsa-slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--bsa-muted);
}

/* ── Buttons ── */
.bsa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 22px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--bsa-font);
    cursor: pointer;
    transition: all 0.18s;
    letter-spacing: 0.01em;
    width: 100%;
}
.bsa-btn--primary {
    background: linear-gradient(135deg, var(--bsa-orange) 0%, var(--bsa-orange-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(255,107,53,0.40);
}
.bsa-btn--primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255,107,53,0.50);
}
.bsa-btn--primary:active:not(:disabled) { transform: translateY(0); }
.bsa-btn--primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}
.bsa-btn--stop {
    background: rgba(231,76,60,0.12);
    color: var(--bsa-red);
    border: 1.5px solid var(--bsa-red);
    width: auto;
    padding: 10px 18px;
    font-size: 14px;
}
.bsa-btn--stop:hover { background: var(--bsa-red); color: #fff; }
.bsa-btn-icon { font-size: 18px; }

/* ── Permission note ── */
.bsa-permission-note {
    text-align: center;
    font-size: 12px;
    color: var(--bsa-muted);
    margin: 16px 16px 24px;
}

/* ── Tracking screen ── */
.bsa-track-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--bsa-navy);
    border-radius: var(--bsa-radius) var(--bsa-radius) 0 0;
    color: #fff;
}
.bsa-track-pulse {
    position: relative;
    width: 44px; height: 44px;
    flex-shrink: 0;
}
.bsa-pulse-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2.5px solid var(--bsa-teal);
    animation: bsa-pulse 1.6s infinite;
}
.bsa-pulse-dot {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
@keyframes bsa-pulse {
    0%   { transform: scale(0.85); opacity: 1; }
    70%  { transform: scale(1.25); opacity: 0; }
    100% { transform: scale(0.85); opacity: 0; }
}
.bsa-track-title {
    font-size: 16px; font-weight: 700;
    margin: 0 0 2px; color: #fff;
}
.bsa-track-dest {
    font-size: 13px; color: var(--bsa-teal);
    margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 220px;
}

/* ── Map ── */
.bsa-map {
    height: 260px;
    background: #e8ecf0;
    border-left: 1px solid var(--bsa-border);
    border-right: 1px solid var(--bsa-border);
}

/* ── Stats row ── */
.bsa-stats-row {
    display: flex;
    background: var(--bsa-surface);
    border: 1px solid var(--bsa-border);
    border-top: none;
}
.bsa-stat {
    flex: 1;
    text-align: center;
    padding: 14px 8px;
    border-right: 1px solid var(--bsa-border);
}
.bsa-stat:last-child { border-right: none; }
.bsa-stat-value {
    font-size: 20px; font-weight: 800;
    color: var(--bsa-orange);
    line-height: 1.1;
}
.bsa-stat-label {
    font-size: 11px; color: var(--bsa-muted);
    margin-top: 3px;
}

/* ── Status bar ── */
.bsa-status-bar {
    padding: 12px 20px;
    border-radius: 0 0 var(--bsa-radius) var(--bsa-radius);
    font-size: 13px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
    border: 1px solid var(--bsa-border);
    border-top: none;
    transition: background 0.3s;
}
.bsa-status-bar--info    { background: #EFF6FF; color: #1D4ED8; }
.bsa-status-bar--warning { background: #FFFBEB; color: #92400E; }
.bsa-status-bar--success { background: #F0FDF4; color: #166534; }
.bsa-status-bar--error   { background: #FEF2F2; color: var(--bsa-red); }

/* ── Alert overlays ── */
.bsa-alert-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13,27,42,0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    animation: bsa-fadeIn 0.25s ease;
}
.bsa-alert-box {
    background: #fff;
    border-radius: 20px;
    padding: 40px 36px;
    text-align: center;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    position: relative;
}
.bsa-alert-box h2 { font-size: 22px; margin: 12px 0 8px; color: var(--bsa-text); }
.bsa-alert-box p  { font-size: 14px; color: var(--bsa-muted); margin: 0 0 24px; line-height: 1.5; }
.bsa-alert-emoji  { font-size: 56px; line-height: 1; }

/* Warning overlay accent */
.bsa-alert-overlay--warning .bsa-alert-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
    background: var(--bsa-amber);
    border-radius: 20px 20px 0 0;
}
.bsa-alert-overlay--arrived .bsa-alert-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
    background: var(--bsa-green);
    border-radius: 20px 20px 0 0;
}
.bsa-alert-overlay--error .bsa-alert-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
    background: var(--bsa-red);
    border-radius: 20px 20px 0 0;
}

/* Bounce animation for arrived */
.bsa-bounce {
    display: inline-block;
    animation: bsa-bounce 0.8s infinite alternate;
}
@keyframes bsa-bounce {
    from { transform: translateY(0);    }
    to   { transform: translateY(-12px);}
}

/* ── Error block (no API key) ── */
.bsa-error {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: 10px;
    padding: 16px 20px;
    font-size: 14px;
    color: var(--bsa-red);
    margin: 20px 0;
}

/* ── Mobile ── */
@media (max-width: 480px) {
    .bsa-setup-card { margin: 20px 8px 0; padding: 18px; }
    .bsa-brand { border-radius: var(--bsa-radius); }
    .bsa-track-dest { max-width: 140px; }
    .bsa-map { height: 200px; }
    .bsa-stat-value { font-size: 16px; }
    .bsa-alert-box { padding: 28px 22px; }
}

/* =====================================================
   Bus Stop Alert v2 — ADDITIONS
   Full-screen tracking · History · Pins · Loud alert
   ===================================================== */

/* ── Pin button on selected place chip ── */
.bsa-pin-btn {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    transition: transform 0.15s;
    flex-shrink: 0;
}
.bsa-pin-btn:hover { transform: scale(1.25); }

/* ── Tab bar ── */
.bsa-tabs {
    display: flex;
    margin: 18px 16px 0;
    border-bottom: 2px solid var(--bsa-border);
}
.bsa-tab {
    flex: 1;
    padding: 11px 8px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--bsa-font);
    color: var(--bsa-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.18s, border-color 0.18s;
}
.bsa-tab--active {
    color: var(--bsa-orange);
    border-bottom-color: var(--bsa-orange);
}

/* ── Panels (history / pins) ── */
.bsa-panel {
    display: none;
    margin: 0 16px 16px;
}
.bsa-panel--active { display: block; }

/* ── Place list (shared by history and pins) ── */
.bsa-place-list {
    background: var(--bsa-surface);
    border: 1px solid var(--bsa-border);
    border-top: none;
    border-radius: 0 0 var(--bsa-radius) var(--bsa-radius);
    overflow: hidden;
    min-height: 60px;
}
.bsa-list-empty {
    padding: 22px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--bsa-muted);
}
.bsa-place-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--bsa-border);
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}
.bsa-place-row:last-child { border-bottom: none; }
.bsa-place-row:hover { background: #FFF8F5; }
.bsa-place-row-icon {
    font-size: 22px;
    flex-shrink: 0;
    width: 30px;
    text-align: center;
}
.bsa-place-row-info {
    flex: 1;
    min-width: 0;
}
.bsa-place-row-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--bsa-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bsa-place-row-addr {
    font-size: 12px;
    color: var(--bsa-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.bsa-place-row-meta {
    font-size: 11px;
    color: var(--bsa-muted);
    flex-shrink: 0;
}
.bsa-place-row-del {
    background: none;
    border: none;
    font-size: 15px;
    color: var(--bsa-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.bsa-place-row:hover .bsa-place-row-del { opacity: 1; }
.bsa-place-row-del:hover { color: var(--bsa-red); }

/* ── Full-screen tracking screen ── */
.bsa-screen--fullscreen {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: var(--bsa-navy);
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.bsa-screen--fullscreen.bsa-screen--active {
    display: flex;
}

/* Floating header over the map */
.bsa-fs-header {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(to bottom, rgba(13,27,42,0.92) 70%, transparent);
    color: #fff;
}
.bsa-fs-dest-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.bsa-fs-dest-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.55);
    line-height: 1;
    margin-bottom: 2px;
}

/* Full-screen map (fills the entire viewport) */
.bsa-map--fullscreen {
    position: absolute;
    inset: 0;
    height: 100% !important;
    width: 100%;
    border: none !important;
}

/* Floating stats bottom sheet */
.bsa-fs-bottom {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 10;
    background: var(--bsa-surface);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 24px rgba(13,27,42,0.25);
    overflow: hidden;
}
.bsa-fs-bottom .bsa-stats-row {
    border: none;
    background: var(--bsa-surface);
}
.bsa-fs-bottom .bsa-status-bar {
    border: none;
    border-top: 1px solid var(--bsa-border);
    border-radius: 0;
    padding: 10px 20px 14px;
}

/* Re-centre FAB */
.bsa-fab {
    position: absolute;
    right: 16px;
    bottom: 140px;          /* above stats sheet */
    z-index: 11;
    width: 50px; height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--bsa-surface);
    box-shadow: 0 4px 16px rgba(13,27,42,0.30);
    font-size: 22px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s;
}
.bsa-fab:hover { transform: scale(1.1); }

/* ── Pin modal ── */
.bsa-pin-modal-box {
    max-width: 360px;
}
.bsa-pin-modal-name {
    font-weight: 700;
    font-size: 15px !important;
    color: var(--bsa-text) !important;
    margin: 0 0 12px !important;
}
.bsa-pin-modal-label {
    font-size: 13px;
    color: var(--bsa-muted);
    margin: 0 0 10px !important;
}
.bsa-emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-bottom: 20px;
}
.bsa-emoji-btn {
    font-size: 24px;
    padding: 6px;
    border: 2px solid var(--bsa-border);
    border-radius: 10px;
    background: var(--bsa-bg);
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.2;
}
.bsa-emoji-btn:hover,
.bsa-emoji-btn--active {
    border-color: var(--bsa-orange);
    background: #FFF3EF;
    transform: scale(1.12);
}
.bsa-pin-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.bsa-btn--ghost {
    background: transparent;
    color: var(--bsa-muted);
    border: 1.5px solid var(--bsa-border);
    box-shadow: none;
}
.bsa-btn--ghost:hover { background: var(--bsa-bg); color: var(--bsa-text); }

/* ── Safe area support (iPhone notch/home bar) ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bsa-fs-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }
    .bsa-fs-header {
        padding-top: calc(14px + env(safe-area-inset-top));
    }
}

/* ── Mobile overrides for v2 additions ── */
@media (max-width: 480px) {
    .bsa-fab { bottom: 160px; right: 12px; width: 44px; height: 44px; font-size: 18px; }
    .bsa-emoji-grid { grid-template-columns: repeat(6, 1fr); gap: 4px; }
    .bsa-emoji-btn  { font-size: 20px; padding: 5px; }
    .bsa-pin-modal-box { padding: 24px 18px; }
    .bsa-tabs { margin: 14px 8px 0; }
    .bsa-panel { margin: 0 8px 12px; }
}
