/*
 * cx-stt.css — SmaTTer (control-stt.html)
 * B.2.1: settings in one wrapping row; stats inside the status line; one
 * button row for both modes; Save as / Download as row; mode, speaker and
 * live-only parts shown from #sttPage's data-mode and .speakers-on.
 * Requires cx-base.css and a theme file loaded before this.
 * Layout and component styles only — colours via cx variables.
 */

:root { --cx-stt-version: 'B.2.1'; }

/* ── Body ── */
body {
    height: auto;
    overflow: auto;
    padding: 1.5rem 1rem 4rem;
}

@media (min-width: 768px) {
    body { padding: 2rem 2rem 6rem; }
}

/* ── Container ── */
.container {
    max-width: 1000px;
    margin: 0 auto;
}

/* ── Header ── */
header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--cx-border);
}

@media (min-width: 768px) {
    header { margin-bottom: 2rem; padding-bottom: 1.5rem; }
}

h1 {
    font-family: var(--cx-font-serif-title);
    font-size: 1.6rem;
    font-weight: 400;
    color: var(--cx-text-strong);
    margin-bottom: 0.4rem;
}

@media (min-width: 768px) {
    h1 { font-size: 2rem; }
}

header p {
    font-size: 0.85rem;
    color: var(--cx-text-dim);
}

@media (min-width: 768px) {
    header p { font-size: 0.9rem; }
}

/* ── Mode selector ── */
.mode-selector {
    display: flex;
    padding-top: 1rem;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

@media (min-width: 768px) {
    .mode-selector { gap: 1rem; margin-bottom: 1.5rem; }
}

.mode-btn {
    padding: 0.5rem 1rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    color: var(--cx-text-dim);
    cursor: pointer;
    transition: background var(--cx-transition-fast), color var(--cx-transition-fast);
    font-size: 0.85rem;
    font-family: var(--cx-font-body);
    border-radius: var(--cx-radius);
}

@media (min-width: 768px) {
    .mode-btn { padding: 0.6rem 1.5rem; font-size: 0.9rem; }
}

.mode-btn.active,
.mode-btn:hover {
    background: var(--cx-surface-mid);
    color: var(--cx-text-strong);
    border-color: var(--cx-brand);
}

/* ── Which parts show ──
 * #sttPage carries data-mode="stream" or "upload", and .speakers-on while
 * Identify speakers is ticked (cx-stt.js). */
#sttPage[data-mode="upload"] .stream-only,
#sttPage[data-mode="stream"] .upload-only,
#sttPage:not(.speakers-on) .speakers-only { display: none; }

/* ── Settings: one row that wraps ── */
.settings {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem 1rem;
    background: var(--cx-surface);
    padding: 0.75rem;
    border-radius: var(--cx-radius);
    margin-bottom: 1rem;
    border: 1px solid var(--cx-border);
}

@media (min-width: 768px) {
    .settings { padding: 1rem; }
}

.setting {
    flex: 1 1 11rem;
    min-width: 0;
}

.setting small {
    display: block;
    margin-top: 0.3rem;
    color: var(--cx-text-dim);
    font-size: 0.75rem;
    line-height: 1.35;
}

/* The checkbox and its words sit level with the neighbours' inputs, below
   where their labels are, so the hints below line up too. */
.setting-check label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    min-height: 2.3rem;
    margin-bottom: 0;
    cursor: pointer;
}

input[type="checkbox"] {
    width: auto;
    margin: 0;
    padding: 0;
}

/* ── The file box ── */
.file-box { margin-bottom: 1rem; }

.file-upload-note {
    font-size: 0.75rem;
    color: var(--cx-text-dim);
    margin-top: 0.3rem;
}

label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--cx-text-dim);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

@media (min-width: 768px) {
    label { font-size: 0.82rem; }
}

input, select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    background: var(--cx-bg);
    border: 1px solid var(--cx-border);
    color: var(--cx-text-strong);
    font-size: 0.9rem;
    border-radius: var(--cx-radius);
    transition: border-color var(--cx-transition-fast);
}

@media (min-width: 768px) {
    input, select { padding: 0.5rem 0.65rem; }
}

input:focus, select:focus {
    border-color: var(--cx-accent-dim);
    outline: none;
}

/* ── File upload ── */
.file-upload {
    border: 1px dashed var(--cx-border);
    border-radius: var(--cx-radius);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--cx-transition-fast), background var(--cx-transition-fast);
    background: var(--cx-surface);
}

@media (min-width: 768px) {
    .file-upload { padding: 1.5rem; }
}

.file-upload:hover,
.file-upload.dragover {
    border-color: var(--cx-brand);
    background: var(--cx-focus-bg);
}

.file-upload input[type="file"] { display: none; }

.file-info {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    border-left: 3px solid var(--cx-brand);
    border-radius: var(--cx-radius);
    display: none;
    font-size: 0.85rem;
}

@media (min-width: 768px) {
    .file-info { margin-top: 1rem; padding: 1rem; }
}

.file-info.visible { display: block; }

/* ── Button group ── */
.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (min-width: 768px) {
    .button-group { gap: 0.75rem; }
}

/* ── Save as / Download as ── */
.keep-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.5rem;
    margin: 0.75rem 0 1rem;
}

.keep-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 20rem;
    min-width: 0;
}

.keep-group label {
    margin: 0;
    white-space: nowrap;
}

.keep-group input,
.keep-group select {
    flex: 1 1 8rem;
    width: auto;
    min-width: 0;
}

.keep-group button {
    flex: 0 0 auto;
    min-width: 0;
}

.save-hint {
    flex-basis: 100%;
    min-height: 1.1em;
    font-size: 0.78rem;
    color: var(--cx-text-dim);
}

.save-hint.warn { color: var(--cx-negative); }

button {
    flex: 1;
    min-width: 120px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    border-radius: var(--cx-radius);
    cursor: pointer;
    transition: background var(--cx-transition-fast), opacity var(--cx-transition-fast);
    font-family: var(--cx-font-body);
}

@media (min-width: 768px) {
    button { padding: 0.6rem 1rem; font-size: 0.9rem; }
}

button:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary {
    background: var(--cx-accent);
    color: var(--cx-on-accent);
    border: 1px solid var(--cx-accent);
    font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--cx-accent-dim); }

.btn-danger {
    background: transparent;
    color: var(--cx-negative);
    border: 1px solid var(--cx-negative-dim);
}
.btn-danger:hover:not(:disabled) { background: var(--cx-red-bg); color: var(--cx-red-color); }

.btn-secondary {
    background: var(--cx-surface-mid);
    color: var(--cx-text);
    border: 1px solid var(--cx-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--cx-surface-high); }

/* ── Progress bar ── */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--cx-surface-mid);
    border-radius: 2px;
    margin-top: 0.75rem;
    overflow: hidden;
    display: none;
}

@media (min-width: 768px) {
    .progress-bar { margin-top: 1rem; }
}

.progress-bar.visible { display: block; }

.progress-fill {
    height: 100%;
    background: var(--cx-brand);
    width: 0%;
    transition: width 0.3s;
}

/* ── Transcript container ── */
.transcript-container {
    background: var(--cx-surface);
    border-radius: var(--cx-radius);
    padding: 1rem;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--cx-border);
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .transcript-container {
        padding: 1.5rem;
        min-height: 300px;
        max-height: 500px;
    }
}

.transcript-item {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--cx-bg);
    border-radius: var(--cx-radius);
    border-left: 3px solid var(--cx-brand);
    animation: slideIn 0.3s ease;
}

@media (min-width: 768px) {
    .transcript-item { margin-bottom: 1rem; padding: 1rem; }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.transcript-time {
    color: var(--cx-brand);
    font-size: 0.72rem;
    font-family: var(--cx-font-mono);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

@media (min-width: 768px) {
    .transcript-time { font-size: 0.78rem; }
}

.transcript-text {
    color: var(--cx-text-strong);
    font-size: 0.95rem;
    line-height: 1.6;
}

@media (min-width: 768px) {
    .transcript-text { font-size: 1rem; line-height: 1.7; }
}

/* ── Status ── */
.status {
    padding: 0.75rem 1rem;
    background: var(--cx-surface);
    border-radius: var(--cx-radius);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--cx-border);
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.85rem;
}

@media (min-width: 768px) {
    .status { padding: 0.75rem 1.25rem; }
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cx-text-muted);
    flex-shrink: 0;
}

.status-dot.active {
    background: var(--cx-ok);
    animation: pulse 2s infinite;
}

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

/* ── Stats, small, in the status line ── */
.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-size: 0.78rem;
    color: var(--cx-text-dim);
}

.stat { white-space: nowrap; }

.stat b {
    font-family: var(--cx-font-mono);
    font-weight: 400;
    color: var(--cx-text-strong);
}

/* ── Error ── */
.error {
    background: var(--cx-red-bg);
    color: var(--cx-red-color);
    padding: 0.75rem 1rem;
    border-radius: var(--cx-radius);
    margin-bottom: 1rem;
    font-size: 0.88rem;
    border: 1px solid var(--cx-brand);
}

@media (min-width: 768px) {
    .error { padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
}

/* ── Keyboard shortcut badge ── */
.key {
    font-family: var(--cx-font-mono);
    font-size: 0.72em;
    color: var(--cx-text-dim);
    background: var(--cx-bg-high);
    border: 1px solid var(--cx-border);
    border-radius: 3px;
    padding: 0.05em 0.35em;
    display: inline-block;
    vertical-align: middle;
}

/* ── Utility ── */
.hidden { display: none; }
