/* Transcriber UI */
:root {
    --bg: #f6f7f9;
    --card: #ffffff;
    --text: #1a2029;
    --muted: #6b7280;
    --border: #e3e6ea;
    --primary: #2563eb;
    --primary-dark: #1e50c8;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
}

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

.container { max-width: 960px; margin: 0 auto; padding: 24px 16px 80px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- nav ---------- */
.topnav { background: #101623; color: #fff; }
.topnav-inner {
    max-width: 960px; margin: 0 auto; padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between; height: 56px;
}
.topnav .brand { color: #fff; font-weight: 700; font-size: 1.05rem; }
.topnav .brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 18px; align-items: center; }
.nav-links a { color: #cbd5e1; }
.nav-links a:hover { color: #fff; text-decoration: none; }
.nav-user { color: #94a3b8; font-size: 0.9rem; }

/* ---------- cards / forms ---------- */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 28px;
}
h1 { font-size: 1.5rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }

label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
    display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
    border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem;
    background: #fff; color: var(--text);
}
input:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.form-row-inline { display: flex; gap: 24px; align-items: end; flex-wrap: wrap; }
.form-row-inline label { margin-bottom: 12px; }
.form-row-inline input[type=number] { width: 110px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.checkbox-label input { margin: 0; }
.engine-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.radio-label { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 0; }
.radio-label input { margin: 0; }

.btn {
    display: inline-block; border: 1px solid var(--border); background: #fff;
    color: var(--text); padding: 8px 16px; border-radius: 8px; font-size: 0.92rem;
    cursor: pointer; font-weight: 600;
}
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-small { padding: 4px 10px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: default; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.93rem; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* ---------- auth ---------- */
.auth-box {
    max-width: 380px; margin: 9vh auto 0; background: var(--card);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 32px;
    text-align: center;
}
.auth-box h1 { margin-bottom: 4px; }
.auth-box form { text-align: left; margin-top: 20px; }

/* ---------- upload ---------- */
.dropzone {
    position: relative; border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 28px; text-align: center; margin-bottom: 16px; transition: border-color 0.15s;
}
.dropzone.drag { border-color: var(--primary); background: #eff6ff; }
.dropzone input[type=file] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.dropzone p { margin: 4px 0; }
.file-chosen { font-weight: 600; color: var(--primary); }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.93rem; vertical-align: top; }
.table th { background: #f8fafc; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.row-actions { text-align: right; white-space: nowrap; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.badge-pending { background: #fef9c3; color: #854d0e; }
.badge-processing { background: #dbeafe; color: #1d4ed8; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-failed { background: #fee2e2; color: #b91c1c; }
.badge-cancelled { background: #e2e8f0; color: #475569; }

/* ---------- transcript editor ---------- */
.transcript-head { margin-bottom: 18px; }
.back-link { font-size: 0.9rem; }
#transcript-title {
    outline: none; border-radius: 6px; padding: 2px 6px; margin-left: -6px;
}
#transcript-title:hover { background: #eef2f7; }
#transcript-title:focus { background: #fff; box-shadow: 0 0 0 2px #bfdbfe; }
.transcript-meta { font-size: 0.88rem; margin-bottom: 10px; }
.export-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.speakers-panel { padding: 14px 16px; margin-bottom: 16px; }
.speakers-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.speaker-chip { display: inline-flex; border-radius: 999px; padding: 3px 6px; }
.speaker-name-input {
    border: none; background: transparent; font-weight: 700; font-size: 0.88rem;
    padding: 2px 6px; margin: 0; width: auto; color: inherit;
}
.speaker-name-input:focus { outline: none; background: rgba(255,255,255,0.6); border-radius: 6px; }

.player-bar {
    position: sticky; top: 0; z-index: 20; background: var(--bg);
    padding: 10px 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.player-bar audio { width: 100%; }

.segments { display: flex; flex-direction: column; gap: 2px; }
.segment {
    display: flex; gap: 14px; padding: 8px 10px; border-radius: 8px;
    border-left: 3px solid transparent;
}
.segment.active { background: #eff6ff; border-left-color: var(--primary); }
.segment-side { flex: 0 0 150px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.segment-time {
    border: none; background: none; color: var(--muted); font-size: 0.78rem;
    cursor: pointer; padding: 0; font-variant-numeric: tabular-nums;
}
.segment-time:hover { color: var(--primary); text-decoration: underline; }
.segment-speaker {
    border: none; border-radius: 999px; padding: 2px 10px; font-size: 0.8rem;
    font-weight: 700; cursor: pointer; max-width: 150px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.segment-text {
    flex: 1; outline: none; border-radius: 6px; padding: 2px 6px; min-height: 1.4em;
}
.segment-text:hover { background: #f1f5f9; }
.segment-text:focus { background: #fff; box-shadow: 0 0 0 2px #bfdbfe; }

.speaker-menu {
    position: absolute; z-index: 50; background: #fff; border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 6px;
    display: flex; flex-direction: column; gap: 4px; min-width: 140px;
}
.speaker-menu-item {
    border: none; text-align: left; border-radius: 999px; padding: 5px 12px;
    font-size: 0.85rem; font-weight: 700; cursor: pointer;
}
.speaker-menu-item:hover { filter: brightness(0.93); }

.save-indicator {
    position: fixed; bottom: 18px; right: 18px; background: #101623; color: #fff;
    padding: 8px 16px; border-radius: 999px; font-size: 0.85rem; z-index: 100;
}
.save-indicator.save-error { background: var(--danger); }

/* speaker colors (8-color palette, dark text on light chips) */
.speaker-color-0 { background: #dbeafe; color: #1e40af; }
.speaker-color-1 { background: #dcfce7; color: #166534; }
.speaker-color-2 { background: #fef3c7; color: #92400e; }
.speaker-color-3 { background: #fce7f3; color: #9d174d; }
.speaker-color-4 { background: #ede9fe; color: #5b21b6; }
.speaker-color-5 { background: #ffedd5; color: #9a3412; }
.speaker-color-6 { background: #cffafe; color: #155e75; }
.speaker-color-7 { background: #e2e8f0; color: #334155; }

/* ---------- admin ---------- */
.admin-tabs { display: flex; gap: 14px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.admin-tabs a { padding: 8px 4px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.admin-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-tabs a:hover { text-decoration: none; color: var(--text); }

@media (max-width: 640px) {
    .segment { flex-direction: column; gap: 4px; }
    .segment-side { flex-direction: row; align-items: center; gap: 10px; flex-basis: auto; }
}
