/* ============================================
   Dealer Stream Interface – Teleprompter Design
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Design Tokens ── */
:root {
    --accent: #60a5fa;
    --accent-rgb: 96, 165, 250;
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --transition-fast: 180ms ease;
    --transition-color: 350ms ease;
}

/* ── Stage Palettes ── */
body[data-stage="ready"] {
    --accent: #60a5fa;
    --accent-rgb: 96, 165, 250;
    --text-bg: rgba(96, 165, 250, 0.08);
    --text-border: rgba(96, 165, 250, 0.35);
    --status-bg: rgba(96, 165, 250, 0.15);
    --status-fg: #93c5fd;
}

body[data-stage="getready"] {
    --accent: #fb923c;
    --accent-rgb: 251, 146, 60;
    --text-bg: rgba(251, 146, 60, 0.10);
    --text-border: rgba(251, 146, 60, 0.45);
    --status-bg: rgba(251, 146, 60, 0.18);
    --status-fg: #fdba74;
}

body[data-stage="start"] {
    --accent: #4ade80;
    --accent-rgb: 74, 222, 128;
    --text-bg: rgba(74, 222, 128, 0.08);
    --text-border: rgba(74, 222, 128, 0.45);
    --status-bg: rgba(74, 222, 128, 0.18);
    --status-fg: #86efac;
}

body[data-stage="finished"] {
    --accent: #c084fc;
    --accent-rgb: 192, 132, 252;
    --text-bg: rgba(192, 132, 252, 0.08);
    --text-border: rgba(192, 132, 252, 0.40);
    --status-bg: rgba(192, 132, 252, 0.18);
    --status-fg: #d8b4fe;
}

body[data-stage="error"] {
    --accent: #f87171;
    --accent-rgb: 248, 113, 113;
    --text-bg: rgba(248, 113, 113, 0.10);
    --text-border: rgba(248, 113, 113, 0.45);
    --status-bg: rgba(248, 113, 113, 0.18);
    --status-fg: #fca5a5;
}

/* ── Body ── */
body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    transition: background var(--transition-color);
}

/* ── Container — full-height card layout ── */
#container {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 32px);
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
    box-shadow:
        0 0 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

/* ── Header — compact top bar ── */
header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

header h1 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ── Main — grows to fill space ── */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 24px;
    gap: 16px;
}

/* ── Status Badge — small indicator ── */
#status {
    align-self: center;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 8px 24px;
    border-radius: 999px;
    flex-shrink: 0;
    transition:
        background var(--transition-fast),
        color var(--transition-fast),
        box-shadow var(--transition-fast);
}

@keyframes statusPulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.05); }
    100% { transform: scale(1); }
}

#status.pulse {
    animation: statusPulse 350ms ease;
}

/* Status state classes */
.connecting {
    background: var(--status-bg, rgba(96, 165, 250, 0.15));
    color: var(--status-fg, #93c5fd);
    box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.15);
}

.ready {
    background: var(--status-bg);
    color: var(--status-fg);
    box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.15);
}

.getready {
    background: var(--status-bg);
    color: var(--status-fg);
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.20);
}

.start {
    background: var(--status-bg);
    color: var(--status-fg);
    box-shadow: 0 0 24px rgba(var(--accent-rgb), 0.25);
}

.finished {
    background: var(--status-bg);
    color: var(--status-fg);
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.18);
}

.error {
    background: var(--status-bg);
    color: var(--status-fg);
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.22);
}

/* ── TEXT AREA — the main attraction ── */
#text {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;

    font-size: clamp(28px, 4vw, 52px);
    font-weight: 700;
    line-height: 1.5;
    letter-spacing: 0.3px;
    white-space: pre-wrap;
    word-break: break-word;

    padding: 40px 36px;
    border-radius: 18px;
    min-height: 200px;

    /* State-driven styling */
    background: var(--text-bg);
    border: 2px solid var(--text-border);
    border-left: 6px solid var(--accent);
    color: var(--text-primary);

    box-shadow:
        0 0 40px rgba(var(--accent-rgb), 0.06),
        inset 0 0 60px rgba(var(--accent-rgb), 0.03);

    transition:
        background var(--transition-color),
        border-color var(--transition-color),
        box-shadow var(--transition-color);
}

/* ── Voice Progress Section ── */
#voiceProgressSection {
    flex-shrink: 0;
    padding: 14px 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
}

.voiceProgressHeader {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.voiceProgressTitle {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--accent);
    transition: color var(--transition-color);
}

.voiceProgressMeta {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.voiceProgressMeta .dot {
    margin: 0 6px;
    opacity: 0.35;
}

.voiceProgressTrack {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

.voiceProgressFill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), rgba(255, 255, 255, 0.30));
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4);
    transition: width 80ms linear;
}

/* ── Footer — minimal ── */
footer {
    flex-shrink: 0;
    text-align: center;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
    color: rgba(148, 163, 184, 0.35);
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid var(--border-subtle);
}

footer strong {
    color: rgba(148, 163, 184, 0.55);
    font-weight: 600;
}

/* ============================================
   Responsive — Large Screens
   ============================================ */
@media (min-width: 1200px) {
    #container {
        max-width: 1300px;
    }

    main {
        padding: 24px 32px;
    }

    #text {
        font-size: clamp(36px, 4.5vw, 64px);
        padding: 48px 44px;
        min-height: 300px;
    }

    #status {
        font-size: 15px;
        padding: 10px 28px;
    }
}

/* ── Extra Large (TV / Presentation displays) ── */
@media (min-width: 1920px) {
    body {
        padding: 24px;
    }

    #container {
        max-width: 1600px;
        min-height: calc(100vh - 48px);
    }

    main {
        padding: 28px 40px;
        gap: 20px;
    }

    #status {
        font-size: 16px;
        padding: 12px 32px;
        letter-spacing: 3px;
    }

    #text {
        font-size: clamp(48px, 5vw, 80px);
        padding: 56px 52px;
        min-height: 400px;
        border-left-width: 8px;
        border-radius: 24px;
    }

    .voiceProgressTrack {
        height: 12px;
    }

    .voiceProgressTitle,
    .voiceProgressMeta {
        font-size: 14px;
    }
}

/* ── Ultra-wide / 4K ── */
@media (min-width: 2560px) {
    #container {
        max-width: 2000px;
    }

    #text {
        font-size: 96px;
        padding: 72px 64px;
        min-height: 500px;
    }

    #status {
        font-size: 18px;
        padding: 14px 36px;
    }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}