/* Transcriber
   Lightweight, mobile-first. System fonts, minimal custom CSS. */

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

:root {
    /* Brand palette, inherited from the Heard baseline (it was sampled
       from that product's logo; the source file is not in this repo).
       Primary orange = CTAs, buttons, topbar accent. Secondary purple =
       brand mark + active-state highlights. Grey is wired via
       --text-muted below; --brand-grey exists for non-text uses. */
    --brand-orange:       #E96424;
    --brand-orange-hover: #C75015;  /* darker shade for button hover */
    --brand-orange-tint:  #FDE8D9;  /* light tint for subtle fills */
    --brand-purple:       #613079;
    --brand-purple-hover: #4D2560;
    --brand-purple-tint:  #F0E8F5;
    --brand-grey:         #727272;

    --primary:       var(--brand-orange);
    --primary-hover: var(--brand-orange-hover);
    --secondary:     var(--brand-purple);
    --secondary-hover: var(--brand-purple-hover);

    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

/* ── Layout ─────────────────────────────────────────────────────── */

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1rem;
}

/* ── Topbar ─────────────────────────────────────────────────────── */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 2px solid var(--primary);
    box-shadow: var(--shadow);
}

.topbar .logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--secondary);
    text-decoration: none;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
}

.topbar nav a {
    color: var(--text);
    text-decoration: none;
}

.topbar nav a:hover {
    color: var(--primary);
}

/* ── Cards ──────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

/* ── Login Card ─────────────────────────────────────────────────── */

.login-card {
    max-width: 400px;
    margin: 4rem auto;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.login-card h1 {
    font-size: 1.5rem;
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

.login-card p {
    margin-bottom: 1.5rem;
}

/* ── Headings ───────────────────────────────────────────────────── */

h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

/* ── Buttons ────────────────────────────────────────────────────── */

.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

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

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ── Alerts ─────────────────────────────────────────────────────── */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ── Badges ─────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
    text-transform: capitalize;
}

/* Queued (grey — waiting for concurrency pool slot) */
.badge-queued {
    background: #f1f5f9;
    color: #475569;
}

/* Needs confirmation (orange — matches orange "Available" tiles on confirm page) */
.badge-pending_confirm {
    background: #ffedd5;
    color: #9a3412;
}

/* Waiting for GPU capacity (purple — matches purple "Queue" tiles on confirm page) */
.badge-capacity_queued {
    background: #f3e8ff;
    color: #6b21a8;
}

/* In-progress states (blue) */
.badge-pending,
.badge-provisioning,
.badge-transferring,
.badge-transcribing {
    background: #dbeafe;
    color: #1e40af;
}

/* Install states (purple — visually distinct from general progress) */
.badge-installing,
.badge-installing_whisper {
    background: #ede9fe;
    color: #5b21b6;
}

/* QA / retry states (amber) */
.badge-qa,
.badge-retrying {
    background: #fef3c7;
    color: #92400e;
}

/* Complete (green) */
.badge-complete {
    background: #dcfce7;
    color: #166534;
}

/* Failed / terminal-negative states (red) */
.badge-failed,
.badge-capacity_queue_cancelled,
.badge-capacity_queue_expired {
    background: #fee2e2;
    color: #991b1b;
}

/* Warning (amber) — used for QA warnings on otherwise-complete jobs */
.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

/* ── Tables ─────────────────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: #f1f5f9;
}

tbody a {
    color: var(--primary);
    text-decoration: none;
}

tbody a:hover {
    text-decoration: underline;
}

/* ── Forms ──────────────────────────────────────────────────────── */

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

input[type="text"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(205, 20, 23, 0.1);
}

/* ── Detail Table ───────────────────────────────────────────────── */

.detail-table {
    width: auto;
}

.detail-table td {
    padding: 0.35rem 0.75rem 0.35rem 0;
    border: none;
    vertical-align: top;
}

.detail-table td:first-child {
    white-space: nowrap;
    padding-right: 1.5rem;
}

/* ── Transcript ─────────────────────────────────────────────────── */

.transcript-area {
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    font-size: 0.875rem;
    line-height: 1.6;
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Turn-grouped diarized transcript. Each <p class="transcript-turn">
   holds: [MM:SS] **Speaker Name:** text — blank line between turns
   via paragraph margin. Timestamp uses tabular-nums so speaker names
   line up across rows, and is tinted muted to recede visually. */
.transcript-turns {
    white-space: normal;  /* paragraphs, not pre-wrap */
}

.transcript-turn {
    margin: 0 0 0.9em 0;
}

.transcript-turn:last-child {
    margin-bottom: 0;
}

.transcript-ts {
    display: inline-block;
    min-width: 4.5rem;
    margin-right: 0.5rem;
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 0.8rem;
}

/* ── Small text ─────────────────────────────────────────────────── */

small {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ── Utility ────────────────────────────────────────────────────── */

.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

/* ── Admin ──────────────────────────────────────────────────────── */

.admin-nav {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.admin-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
}

.admin-nav a:hover {
    color: var(--text);
    background: #f1f5f9;
}

.admin-nav a.active {
    color: var(--secondary);
    background: var(--brand-purple-tint);
}

.flash {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.btn-small {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.row-warning {
    background: #fffbeb;
}

/* ── Admin footer ───────────────────────────────────────────────── */

.admin-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
}

/* ── Tier picker ────────────────────────────────────────────────── */

.tier-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

/* ── Upload-confirm: three-bucket GPU row ───────────────────────────
   Each GPU section (Accurate-Fast, Speaker-labelled) renders its three
   distance buckets (same-region / same-continent / other) side-by-side.
   Collapses to a single column on narrow screens via auto-fit.
   Each bucket holds its own heading + 0..N tiles stacked vertically. */
.tier-bucket-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
}

.tier-bucket {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tier-bucket-heading {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tier-bucket-heading .sub {
    font-weight: normal;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.85em;
}

.tier-bucket-empty {
    padding: 0.75rem;
    font-size: 0.85em;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
}

/* ── Per-(GPU SKU, jurisdiction) grid ───────────────────────────────
   One row per jurisdiction (UK / EU / USA / Canada / AP), one column
   per enabled SKU + a trailing "Any in jurisdiction" column. Each cell
   holds either a selectable tile, a Queue button, or "—". The wrapping
   .table-wrap allows horizontal scroll on narrow screens. */
.gpu-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
}

.gpu-grid th {
    text-align: left;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0 0.25rem;
}

.gpu-grid td {
    vertical-align: top;
    width: 200px;
    height: 1px; /* enables height:100% on inner content */
    padding: 0;
}

.gpu-grid td:first-child {
    width: 130px;
    vertical-align: middle;
    font-size: 0.95rem;
    height: auto;
}

/* Uniform sizing: every cell's direct child fills a fixed-min box so
   status pills and "—" placeholders align row-by-row. */
.gpu-grid td > .gpu-cell-empty {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    min-height: 140px;
    box-sizing: border-box;
}

.gpu-cell-empty {
    text-align: center;
    color: var(--text-muted);
    opacity: 0.5;
}

/* Read-only GPU availability grid (admin). Uses the same orange/purple
   palette as the confirm-page tiles so operators recognise the states,
   but without radio inputs — just coloured status pills. */
.gpu-grid-readonly td.gpu-avail {
    text-align: center;
    padding: 0.6rem 0.5rem;
    vertical-align: middle;
}

.gpu-avail-pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 4px;
    color: #fff;
}

.gpu-avail-pill-live { background: #ea580c; }
.gpu-avail-pill-queue { background: #a855f7; }
.gpu-avail-pill-stale { background: #a1a1aa; }

/* Stale-queue cell shading — greyed to say the SKU hasn't been seen in
   STALE_QUEUE_TILE_SECONDS (12 h), or was never observed at all. */
.gpu-grid-readonly td.gpu-avail-stale {
    background: #f4f4f5;
}

.gpu-avail-region {
    margin-top: 0.3rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Legend dots in the header */
.gpu-avail-dot {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 0.15rem;
}

.gpu-avail-dot-live { background: #ea580c; }
.gpu-avail-dot-queue { background: #a855f7; }
.gpu-avail-dot-stale { background: #a1a1aa; }
.gpu-avail-dot-none {
    background: transparent;
    border: 1px dashed var(--text-muted);
}

/* Speaker-count fieldset: horizontal row of three options (Auto / Exact /
   Range). Wraps to new line on narrow screens rather than overflowing. */
.speaker-fieldset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: center;
    margin-top: 0.5rem;
}

.speaker-fieldset-row label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.tier-card {
    display: block;
    cursor: pointer;
    position: relative;
}

.tier-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tier-card-inner {
    background: #fff;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    height: 100%;
    position: relative;
    transition: border-color 0.1s, box-shadow 0.1s;
}

.tile-status-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 4px;
}

.tile-status-badge-live {
    color: #fff;
    background: #ea580c;
}

.tile-status-badge-queue {
    color: #fff;
    background: #a855f7;
}

.tier-card:hover .tier-card-inner {
    border-color: var(--primary, #2563eb);
}

.tier-card input[type="radio"]:checked + .tier-card-inner {
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.tier-card h2,
.tier-card h3 {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
}

/* Definition-list summary blocks (batch detail "Batch summary" panel,
   etc.). Default browser dl spacing leaves dt+dd stacked and jumbled;
   laying them out as a 2-column grid (label | value) makes the panel
   scannable even when it's constrained to a narrow aside. */
dl.kv {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1rem;
    row-gap: 0.35rem;
    margin: 0;
}
dl.kv dt {
    font-weight: 600;
    color: var(--text-muted);
}
dl.kv dd {
    margin: 0;
    min-width: 0;
    word-break: break-word;
}

/* 1-to-2 two-column layout used on the dashboard (in-progress tab)
   and the batch detail page. Left column is one third, right column is
   two thirds. Collapses to a single stacked column on narrow screens so
   the left aside doesn't squeeze to unreadable widths. */
.split-1-2 {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
    align-items: start;
}
.split-1-2 > * { min-width: 0; }
@media (max-width: 900px) {
    .split-1-2 { grid-template-columns: 1fr; }
}

/* Recipient type-ahead picker (Phase 3 confirm pages). */
.recipient-picker {
    position: relative;
    margin: 0.5rem 0;
}

.picker-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.picker-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 0.25rem;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.picker-result {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}

.picker-result:last-child {
    border-bottom: none;
}

.picker-result:hover,
.picker-result.active {
    background: #f1f5f9;
}

.picker-result .name {
    font-weight: 500;
}

.picker-result .real-name {
    color: var(--text-muted);
    margin-left: 0.5rem;
    font-size: 0.8rem;
}

.picker-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.5rem 0;
}

.picker-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 999px;
    font-size: 0.8rem;
}

.picker-chip button {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
}

.picker-chip button:hover {
    color: var(--danger);
}

.picker-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 0.35rem;
    min-height: 1em;
}

/* Recipient delivery-status badges (job detail page, Phase 3). */
.recipient-status {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
}

.recipient-status-pending {
    background: #dbeafe;
    color: #1e40af;
}

.recipient-status-delivered {
    background: #dcfce7;
    color: #166534;
}

.recipient-status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.recipient-status-notsent {
    background: #f1f5f9;
    color: #64748b;
    text-decoration: line-through;
}

.recipient-row.notsent {
    color: var(--text-muted);
}

/* ── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .container {
        padding: 0.75rem;
    }

    .topbar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .topbar nav {
        gap: 0.75rem;
    }
}

/* Guest badge in the recipient picker's results. Guests are eligible
   recipients, so the person adding one should see that the transcript is
   about to leave the org. */
.picker-guest {
    margin-left: 0.4rem;
    padding: 0 0.35rem;
    border: 1px solid #c9ab63;
    border-radius: 3px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #7a5f14;
    background: #fdf6e0;
}
