/* ── Design tokens ─────────────────────────────────────────── */
:root {
    --c-primary:    #16a34a;
    --c-primary-dk: #15803d;
    --c-primary-lt: #f0fdf4;
    --c-bg:         #f1f5f9;
    --c-surface:    #ffffff;
    --c-border:     #e2e8f0;
    --c-text:       #1e293b;
    --c-muted:      #64748b;
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
    --radius:       10px;

    /* Type scale (Tailwind-aligned) */
    --fs-2xs:  0.6875rem;  /* 11px — sub-text inside compact elements */
    --fs-xs:   0.75rem;    /* 12px — dense data, footnotes, badges     */
    --fs-sm:   0.875rem;   /* 14px — controls, labels, table headers   */
    --fs-base: 1rem;       /* 16px — body default                      */
    --fs-lg:   1.125rem;   /* 18px — page titles                       */
}

/* ── Base ───────────────────────────────────────────────────── */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 'PingFang TC', 'Noto Sans TC', sans-serif;
    background-color: var(--c-bg);
    color: var(--c-text);
    margin: 0;
    padding: 12px;
}

/* ── Table shell ────────────────────────────────────────────── */
table {
    border-collapse: collapse;
    width: 100%;
    background: var(--c-surface);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--c-border);
    letter-spacing: 0.2px;
    font-family: inherit;
}

thead {
    background-color: var(--c-primary);
    color: #fff;
}

tfoot {
    background-color: var(--c-bg);
    color: var(--c-muted);
    font-size: 0.8em;
}

tbody {
    background-color: var(--c-surface);
}

table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

/* ── Cells ──────────────────────────────────────────────────── */
td, th {
    border: none;
    border-bottom: 1px solid var(--c-border);
    text-align: center;
}

thead td, thead th {
    border-bottom: 2px solid var(--c-primary-dk);
    font-weight: 600;
}

tfoot td, tfoot th {
    border-bottom: none;
    border-top: 1px solid var(--c-border);
}

td.left {
    text-align: left;
}

/* ── Route search: compact first column, wide destination column */
#station_address_table.route-mode #col-main { width: 27%; }
#station_address_table.route-mode #col-sub  { width: 73%; }

/* ── Direction arrow rows (route page) ──────────────────────── */
tr.directionInfo td {
    padding: 1px 0;
    background-color: #f8fafc;
    color: var(--c-muted);
    border-bottom: none;
}

/* ── Route name cell ────────────────────────────────────────── */
.routeName {
    font-weight: 600;
    overflow-wrap: break-word;
    word-break: break-all;
}


/* ── Direction-only stop name cell (route page) ─────────────── */
td.stop-d0-only { background-color: #eff6ff; }
td.stop-d1-only { background-color: #fef2f2; }
td.stop-d0-only a { color: #1d4ed8; }
td.stop-d1-only a { color: #b91c1c; }

/* ── Highlighted ETA cell (from station page) ───────────────── */
td.highlighted {
    background-color: #fef9c3 !important;
    border: 2px solid #f59e0b !important;
}

/* ── Station group header (stop page) ──────────────────────── */
tr.station-group-header td {
    background-color: var(--c-primary-lt);
    padding: 5px 14px;
    border-top: 2px solid var(--c-primary);
}

tr.station-group-header.first-group td {
    border-top: none;
}

.group-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-city {
    color: var(--c-primary-dk);
    font-weight: 600;
    font-size: 0.85em;
    white-space: nowrap;
}

.group-desc {
    color: var(--c-muted);
    font-size: 0.82em;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-map-link {
    color: var(--c-primary-dk);
    font-size: 0.82em;
    white-space: nowrap;
    text-decoration: none;
}

.group-map-link:hover {
    text-decoration: underline;
}

/* ── Pin / favourite button ─────────────────────────────────── */
.pin-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--c-border);
    padding: 0 6px 0 0;
    font-size: 0.9em;
    float: right;
    line-height: 1.6;
    transition: color 0.15s;
}

.pin-btn:hover,
.pin-btn.pinned {
    color: #f59e0b;
}

/* ── Alert banner ───────────────────────────────────────────── */
.alerts-container {
    display: none;
    margin-bottom: 8px;
}

.alert-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.alert-item::before {
    content: '⚠';
    flex-shrink: 0;
}

.alert-title {
    flex: 1;
    color: #92400e;
    font-weight: 500;
}

.alert-time {
    color: #b45309;
    white-space: nowrap;
    font-size: 0.8rem;
}

/* ── Last-updated timestamp ─────────────────────────────────── */
.eta-updated {
    font-size: 0.75rem;
    color: var(--c-muted);
    text-align: right;
    padding: 4px 2px;
}

/* ── Utility ────────────────────────────────────────────────── */
.nopadding { padding: 0; margin: 0; }

/* ── Responsive — mobile ────────────────────────────────────── */
@media screen and (max-width: 700px) {
    body {
        font-size: 15px;
        padding: 8px;
    }

    td, th {
        padding: 8px 5px;
        white-space: normal;
    }

    table {
        font-size: 15px;
    }

    .routeName { font-size: 1.1em; }

    .smallpadding { padding: 3px 2px; }
}

/* ── Responsive — desktop ───────────────────────────────────── */
@media screen and (min-width: 700px) {
    body {
        font-size: 16px;
        padding: 20px;
    }

    td, th {
        padding: 11px 14px;
        white-space: normal;
    }

    table { font-size: 1rem; }

    .routeName { font-size: 1.2em; }

    .smallpadding { padding: 5px 3px; }
}
