/* MBTA Live Transit Map */
/* Covers: map layout, legend, stats panel, route search panel,
   info panel, and route history chart section. */

body { margin: 0; font-family: sans-serif; }
#map { height: 100vh; width: 100%; }

/* ── Legend (bottom-left) ─────────────────────────────────────── */
#legend {
    position: absolute; bottom: 20px; left: 20px; z-index: 1000;
    background: white; padding: 12px; border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3); font-size: 13px;
}
#legend h4 { margin: 0 0 8px 0; }
#legend div { margin: 3px 0; }
#legend .dot {
    display: inline-block; width: 12px; height: 12px;
    border-radius: 50%; margin-right: 6px; vertical-align: middle;
}
#legend .line {
    display: inline-block; width: 20px; height: 3px;
    margin-right: 6px; vertical-align: middle; border-radius: 2px;
}

/* ── Stats panel (top-right) ──────────────────────────────────── */
#stats {
    position: absolute; top: 10px; right: 10px; z-index: 1000;
    background: white; padding: 10px 14px; border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3); font-size: 12px;
    line-height: 1.6;
}
#stats .stale { color: #e74c3c; font-weight: bold; }
#stats .fresh { color: #27ae60; }

/* ── Route search button + panel ──────────────────────────────── */
#route-search-btn {
    position: absolute; top: 130px; left: 10px; z-index: 1000;
    width: 36px; height: 36px; border-radius: 50%;
    background: white; border: none; cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    font-size: 18px; color: #555;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s;
}
#route-search-btn:hover { background: #f0f0f0; color: #222; }
#route-search-btn.active { background: #333; color: #fff; }

#route-search-panel {
    position: absolute; top: 130px; left: 10px; z-index: 1000;
    background: white; border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    display: none; width: 320px; overflow: hidden;
}
#route-search-panel.open { display: block; }

.search-header {
    display: flex; align-items: center;
    padding: 8px 10px; gap: 6px;
    border-bottom: 1px solid #eee;
}
.search-header input {
    flex: 1; border: none; outline: none;
    font-size: 14px; padding: 6px 4px;
    background: transparent; color: #333;
}
.search-header input::placeholder { color: #999; }
.search-close-btn {
    background: none; border: none; cursor: pointer;
    font-size: 18px; color: #888; padding: 0 4px;
    line-height: 1;
}
.search-close-btn:hover { color: #333; }

#route-search-results {
    padding: 12px 14px; font-size: 13px; line-height: 1.6;
    display: none;
}
#route-search-results.open { display: block; }
#route-search-error {
    color: #e74c3c; font-size: 13px;
}

/* ── Route performance stats (inside search results) ──────────── */
.route-perf-title {
    font-size: 15px; font-weight: bold; color: #111;
    margin: 0 0 10px 0;
}
.route-perf-section {
    margin-bottom: 10px;
}
.route-perf-section h5 {
    margin: 0 0 4px 0; font-size: 12px; color: #888;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.route-perf-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 2px 12px; font-size: 13px;
}
.route-perf-grid .label { color: #666; }
.route-perf-grid .value { font-weight: 600; color: #222; text-align: right; }

/* ── Info toggle + panel ──────────────────────────────────────── */
#info-toggle {
    position: absolute; top: 90px; left: 10px; z-index: 1000;
    width: 32px; height: 32px; border-radius: 50%;
    background: white; border: none; cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    font-size: 16px; font-weight: bold; color: #555;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s;
}
#info-toggle:hover { background: #f0f0f0; color: #222; }
#info-toggle.active { background: #333; color: #fff; }

#info-panel {
    position: absolute; top: 174px; left: 10px; z-index: 1000;
    background: white; padding: 16px 18px; border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25); font-size: 13px;
    line-height: 1.55; max-width: 340px; color: #333;
    display: none;
}
#info-panel h3 { margin: 0 0 10px 0; font-size: 14px; color: #111; }
#info-panel p { margin: 0 0 10px 0; }
#info-panel p:last-child { margin-bottom: 0; }
#info-panel .flow-step {
    display: inline-block; background: #f5f5f5; border-radius: 4px;
    padding: 1px 6px; font-size: 12px; white-space: nowrap;
}
#info-panel .flow-arrow { color: #aaa; margin: 0 2px; }

/* ── Route history (inside the search panel) ──────────────────── */
.route-history-section {
    margin-top: 12px; padding-top: 10px;
    border-top: 1px solid #eee;
}
.history-toggle-btn {
    background: none; border: 1px solid #ddd; border-radius: 6px;
    padding: 7px 12px; cursor: pointer; font-size: 13px;
    color: #333; width: 100%; text-align: left;
    transition: background 0.15s;
}
.history-toggle-btn:hover { background: #f5f5f5; }
.history-toggle-btn.active { background: #333; color: #fff; border-color: #333; }
.history-content {
    margin-top: 10px;
}
.history-chart-wrap {
    position: relative; height: 160px; margin-bottom: 10px;
}
.history-summary {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 4px 12px; font-size: 12px; margin-bottom: 10px;
}
.history-summary .label { color: #666; }
.history-summary .value { font-weight: 600; color: #222; text-align: right; }
.history-days {
    display: flex; gap: 6px;
}
.day-btn {
    flex: 1; padding: 5px 0; border: 1px solid #ddd; border-radius: 4px;
    background: none; cursor: pointer; font-size: 12px; color: #555;
    text-align: center; transition: background 0.15s, color 0.15s;
}
.day-btn:hover { background: #f0f0f0; }
.day-btn.active { background: #333; color: #fff; border-color: #333; }
.history-empty {
    color: #888; font-size: 12px; padding: 8px 0;
}
