/* ============================================================
   Fix The District - Styles
   Mobile-first, vanilla CSS, District line green branding
   ============================================================ */

:root {
    --district-green: #00843D;
    --district-dark: #006B31;
    --district-light: #E8F5EE;
    --red: #DC3545;
    --amber: #F0AD4E;
    --bg: #F5F6FA;
    --card: #FFFFFF;
    --text: #1A1A2E;
    --text-muted: #6C757D;
    --border: #DEE2E6;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ---- Reset & base ---- */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
}

/* ---- Header ---- */

.header {
    background: var(--district-green);
    color: white;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header h1 {
    font-size: 18px;
    font-weight: 700;
}

.line-badge {
    display: inline-block;
    background: white;
    color: var(--district-green);
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    vertical-align: middle;
    margin-left: 6px;
}

/* ---- Navigation ---- */

.nav {
    background: var(--district-dark);
    position: sticky;
    top: 54px;
    z-index: 99;
}

.nav-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
}

.nav a {
    flex: 1;
    padding: 12px 8px;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    transition: color 0.2s, background 0.2s;
    position: relative;
}

.nav a:hover {
    color: white;
}

.nav a.active {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav a.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: white;
    border-radius: 3px 3px 0 0;
}

/* ---- Layout ---- */

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* ---- Cards ---- */

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
}

/* ---- Banner ---- */

.banner {
    background: linear-gradient(135deg, var(--district-green), var(--district-dark));
    color: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    text-align: center;
}

.banner h2 {
    font-size: 17px;
    margin-bottom: 6px;
}

.banner p {
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.5;
}

/* ---- TfL live status chip ---- */

.tfl-status {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    margin: 12px auto 0;
    width: fit-content;
    max-width: 100%;
}

.tfl-status.good {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.tfl-status.minor {
    background: var(--amber);
    color: #333;
}

.tfl-status.severe {
    background: var(--red);
    color: white;
}

.tfl-status .pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- Form ---- */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-group .hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: white;
    color: var(--text);
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236C757D' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--district-green);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, opacity 0.2s;
}

.btn-primary {
    background: var(--district-green);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--district-dark);
}

.btn-primary:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* ---- Toast notification ---- */

.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    z-index: 200;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
}

.toast.success {
    background: var(--district-green);
    color: white;
}

.toast.error {
    background: var(--red);
    color: white;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---- TfL discrepancy callout ---- */

.discrepancy-note {
    margin-top: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
}

.discrepancy-note.mismatch {
    background: #FFF3CD;
    border: 1px solid #FFECB5;
    color: #856404;
}

.discrepancy-note.match {
    background: var(--district-light);
    color: var(--district-dark);
}

/* ---- Spinner ---- */

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Footer ---- */

.footer {
    text-align: center;
    padding: 24px 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.footer a {
    color: var(--district-green);
    text-decoration: none;
}

/* ---- Upvote button ---- */

.upvote-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.upvote-btn:hover { border-color: #999; color: #555; }

.upvote-btn.voted {
    border-color: var(--district-green);
    color: var(--district-green);
    background: var(--district-light);
    cursor: pointer;
}

.upvote-btn.voted:hover { background: #d0e8d8; }

/* ---- Edit button ---- */

.edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.edit-btn:hover { border-color: var(--amber); color: var(--amber); }

/* ---- Delete button ---- */

.delete-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.delete-btn:hover { border-color: var(--red); color: var(--red); }

/* ---- Edit modal ---- */

.edit-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.edit-modal {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    max-width: 500px; width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    color: var(--text);
    margin-top: 40px;
}

.edit-modal h3 { font-size: 16px; margin-bottom: 16px; }

.edit-modal .form-group { margin-bottom: 12px; }

.edit-modal .btn-row {
    display: flex; gap: 8px; margin-top: 16px;
}

.edit-modal .btn-save {
    flex: 1; padding: 10px; background: var(--district-green); color: white;
    border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit;
}

.edit-modal .btn-save:hover { background: var(--district-dark); }

.edit-modal .btn-cancel {
    flex: 1; padding: 10px; background: var(--bg); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit;
}

.edit-modal .btn-cancel:hover { background: var(--border); }

/* ---- Time lost hero ---- */

.time-lost-hero {
    background: linear-gradient(135deg, #1A1A2E, #2D2D44);
    color: white;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    text-align: center;
}

.time-lost-hero .big-number { font-size: 48px; font-weight: 800; line-height: 1.1; color: #FF6B6B; }
.time-lost-hero .big-label { font-size: 13px; opacity: 0.8; margin-top: 4px; font-weight: 600; }

.time-lost-hero .sub-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.time-lost-hero .sub-stat-value { font-size: 22px; font-weight: 700; }
.time-lost-hero .sub-stat-label { font-size: 11px; opacity: 0.7; }

/* ---- Info modal ---- */

.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 11px; font-weight: 700;
    border: none; cursor: pointer;
    vertical-align: middle;
    margin-left: 4px;
}

.info-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}

.info-modal {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    max-width: 400px; width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    color: var(--text);
}

.info-modal h3 { font-size: 16px; margin-bottom: 12px; }
.info-modal p { font-size: 14px; line-height: 1.6; margin-bottom: 8px; color: var(--text-muted); }

.info-modal .close-modal {
    display: block; margin-top: 16px; padding: 8px 16px;
    background: var(--district-green); color: white;
    border: none; border-radius: 8px;
    font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit; width: 100%;
}

/* ---- CSS Bar charts ---- */

.bar-chart { display: flex; flex-direction: column; gap: 8px; }

.bar-row { display: flex; align-items: center; gap: 8px; }

.bar-label {
    width: 80px; font-size: 12px; font-weight: 600;
    text-align: right; flex-shrink: 0; color: var(--text);
}

.bar-track {
    flex: 1; height: 24px;
    background: var(--bg); border-radius: 4px; overflow: hidden;
}

.bar-fill {
    height: 100%; border-radius: 4px;
    transition: width 0.6s ease; min-width: 2px;
}

.bar-fill.green { background: var(--district-green); }
.bar-fill.red { background: var(--red); }
.bar-fill.amber { background: var(--amber); }

.bar-value { width: 52px; font-size: 12px; font-weight: 700; color: var(--text); flex-shrink: 0; }

/* ---- Stats grid ---- */

.stats-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 12px; margin-bottom: 16px;
}

.stat-card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px; text-align: center;
}

.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--district-green); line-height: 1.2; }
.stat-card .stat-value.danger { color: var(--red); }
.stat-card .stat-value.warn { color: var(--amber); }
.stat-card .stat-label {
    font-size: 11px; color: var(--text-muted); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px;
}

/* ---- Site footer sections ---- */

.site-footer { max-width: 600px; margin: 0 auto; padding: 20px 16px 32px; }

.footer-section {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 12px;
}

.footer-section h4 { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.footer-section p { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.footer-section a { color: var(--district-green); text-decoration: none; }

/* ---- Context / info box ---- */

.context-box {
    background: #EDF4FE;
    border: 1px solid #BDD5F5;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.context-box h4 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #1A56A8;
}

.context-box p {
    font-size: 13px;
    line-height: 1.6;
    color: #3A5F8F;
    margin-bottom: 6px;
}

.context-box p:last-child { margin-bottom: 0; }

.context-box .source {
    font-size: 11px;
    font-style: italic;
    opacity: 0.8;
    margin-top: 8px;
}

/* ---- Toggle button ---- */

.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    color: var(--text);
    transition: background 0.2s;
}

.toggle-btn:hover { background: var(--border); }

/* ---- Rate limit notice ---- */

.rate-limit-notice {
    background: #FFF3CD; border: 1px solid #FFECB5; color: #856404;
    padding: 10px 14px; border-radius: 8px; font-size: 13px;
    margin-bottom: 16px; display: none;
}

/* ---- Demo mode toggle ---- */

.demo-toggle-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.demo-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
    -webkit-user-select: none;
}

.demo-toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--district-green);
    cursor: pointer;
}

.demo-banner {
    background: #E8F5EE;
    border: 2px dashed var(--district-green);
    color: var(--district-dark);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    padding: 8px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
}

/* ---- Responsive ---- */

@media (min-width: 600px) {
    .container { padding: 24px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .bar-label { width: 100px; }
}
