/* ==========================================================================
   CheckMyTrain — Shared Design System  (components.css)
   Loaded by every page. Defines CSS custom properties and reusable component
   classes. Page-specific files provide only genuinely unique overrides.
   ========================================================================== */

/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
    /* Backgrounds */
    --bg:            #001f5b;
    --bg-panel:      #00174a;
    --bg-input:      rgba(0,0,0,0.30);
    --bg-card:       rgba(255,255,255,0.04);
    --bg-row-even:   rgba(255,255,255,0.02);
    --bg-row-hover:  rgba(255,255,255,0.06);

    /* Borders */
    --border:        rgba(255,255,255,0.08);
    --border-input:  rgba(255,255,255,0.18);
    --border-strong: rgba(255,255,255,0.12);

    /* Text */
    --text:          #ffffff;
    --text-muted:    rgba(255,255,255,0.50);
    --text-dim:      rgba(255,255,255,0.35);

    /* Brand blues */
    --blue-primary:  #1466d6;
    --blue-dark:     #0c56bf;
    --blue-darker:   #003b8e;
    --blue-col:      #0050c8;
    --blue-header:   rgba(0,50,160,0.35);

    /* Status colours */
    --clr-success:   #8cf0a8;
    --clr-warning:   #ffd54a;
    --clr-danger:    #ff8b8b;
    --clr-live:      #4cff91;
    --clr-info:      #6bbfff;

    /* Shape */
    --r-sm:  6px;
    --r-md:  8px;
    --r-lg:  12px;

    /* Layout */
    --sidebar-w:   280px;
    --topbar-h:    56px;
    --input-h:     36px;
    --shadow-card: 0 2px 8px rgba(0,0,0,0.25);
}

/* ── Page header card ─────────────────────────────────────────────────────── */
/* The blue gradient header card that appears at the top of content pages.    */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, var(--blue-dark) 0%, var(--blue-darker) 100%);
    padding: 16px 20px;
    border-radius: var(--r-md);
    margin-bottom: 14px;
    box-shadow: var(--shadow-card);
    gap: 16px;
}

.page-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

.page-subtitle {
    font-size: 16px;
    opacity: 0.85;
    margin-top: 2px;
}

.page-clock {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* ── Content card ─────────────────────────────────────────────────────────── */
/* Bordered card block — used to group route bars, tables, panels.            */
.card {
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 14px;
}

.card-heading {
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    background: var(--blue-header);
    border-bottom: 1px solid var(--border);
}

/* ── Data table ───────────────────────────────────────────────────────────── */
/* Card wrapper + scrollable inner + table with consistent header/row style.  */
.data-table-wrap {
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    overflow: hidden;
}

.data-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    text-align: left;
    padding: 9px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-dim);
    white-space: nowrap;
    background: var(--blue-header);
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.data-table tbody tr:nth-child(even) { background: var(--bg-row-even); }
.data-table tbody tr:hover           { background: var(--bg-row-hover); }
.data-table tbody tr:last-child      { border-bottom: none; }

.data-table td {
    padding: 10px 12px;
    vertical-align: middle;
    white-space: nowrap;
}

/* ── Status badges ────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-ontime    { background: rgba(140,240,168,0.12); color: var(--clr-success); }
.badge-delayed   { background: rgba(255,213,74, 0.12); color: var(--clr-warning); }
.badge-severe    { background: rgba(255,100,60, 0.12); color: #ff9a75; }
.badge-cancelled { background: rgba(255,139,139,0.12); color: var(--clr-danger); }
.badge-info      { background: rgba(107,191,255,0.12); color: var(--clr-info); }

/* ── Status text colours ──────────────────────────────────────────────────── */
.clr-success  { color: var(--clr-success); }
.clr-warning  { color: var(--clr-warning); }
.clr-danger   { color: var(--clr-danger); }
.clr-info     { color: var(--clr-info); }

/* ── Live pulsing dot ─────────────────────────────────────────────────────── */
.live-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--clr-live);
    flex-shrink: 0;
    animation: anim-blink 1.4s infinite;
}

@keyframes anim-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.25; }
}

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spin {
    display: inline-block;
    animation: anim-spin 1.2s linear infinite;
}

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

/* ── Summary stats bar ────────────────────────────────────────────────────── */
.stat-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: var(--r-md);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 90px;
}

.stat-num {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
}

.stat-card.cancelled .stat-num { color: var(--clr-danger); }
.stat-card.delayed   .stat-num { color: var(--clr-warning); }
.stat-card.ontime    .stat-num { color: var(--clr-success); }

/* ── State panels ─────────────────────────────────────────────────────────── */
/* Centred panels for loading / empty / error states.                         */
.state-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    gap: 10px;
    text-align: center;
}

.state-panel[hidden] { display: none; }

.state-icon  { font-size: 40px; opacity: 0.5; line-height: 1; }
.state-title { font-size: 18px; font-weight: 700; color: rgba(255,255,255,0.7); }
.state-sub   { font-size: 14px; color: var(--text-muted); max-width: 380px; }
.state-note  { font-size: 12px; color: var(--text-dim);   max-width: 380px; margin-top: 4px; }

/* ── Placeholder (no results / initial state) ─────────────────────────────── */
.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    opacity: 0.3;
    gap: 12px;
    text-align: center;
}

.placeholder-icon { font-size: 48px; }
.placeholder-text { font-size: 16px; }

/* ── Live service banner ──────────────────────────────────────────────────── */
.live-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(0,60,180,0.30);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: var(--r-md);
    font-size: 14px;
    margin-bottom: 14px;
}

/* ── Responsive page-header ───────────────────────────────────────────────── */
@media (max-width: 700px) {
    .page-header   { padding: 14px 16px; }
    .page-title    { font-size: 22px; }
    .page-subtitle { font-size: 14px; }
    .page-clock    { font-size: 22px; }
}

@media (max-width: 440px) {
    .page-header   { padding: 10px 12px; margin-bottom: 10px; border-radius: var(--r-sm); }
    .page-title    { font-size: 18px; }
    .page-subtitle { font-size: 12px; }
    .page-clock    { font-size: 18px; }
}
