/* Cyrano Admin — Design System */

:root {
  --color-bg: #fafcfb;
  --color-surface: #ffffff;
  --color-nav: #0F2F23;
  --color-nav-text: #F1F7F0;
  --color-primary: #2D6A4F;
  --color-primary-hover: #1B4332;
  --color-text: #1e293b;
  --color-muted: #64748b;
  --color-border: #e5e9e7;
  --color-success: #2D6A4F;
  --color-warning: #D4A574;
  --color-error: #E05252;
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.5;
  font-size: 0.9375rem;
}

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

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}
h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
}
h2:first-child {
  margin-top: 0;
}

/* Layout */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Nav */
.nav {
  background: var(--color-nav);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 48px;
  gap: 0;
}
.nav-brand {
  color: white;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  margin-right: 2rem;
}
.nav-brand:hover {
  text-decoration: none;
}
.nav-links {
  display: flex;
  gap: 0;
  height: 100%;
  align-items: stretch;
}
.nav-link {
  color: var(--color-nav-text);
  text-decoration: none;
  font-size: 0.8125rem;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  opacity: 0.7;
  border-bottom: 2px solid transparent;
}
.nav-link:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}
.nav-link.active {
  opacity: 1;
  border-bottom-color: var(--color-primary);
}
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.nav-user {
  color: var(--color-nav-text);
  font-size: 0.8125rem;
  opacity: 0.6;
}

/* Page header */
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header .subtitle {
  color: var(--color-muted);
  font-size: 0.875rem;
  margin-top: 0.125rem;
}

.island-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}
.card-body {
  padding: 1.25rem;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
}
.stat-label {
  color: var(--color-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* Tables */
.table-wrap {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  border-bottom: 2px solid var(--color-border);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  font-weight: 600;
  white-space: nowrap;
}
td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.8125rem;
}
tbody tr:hover td {
  background: #f1f5f9;
}
tbody tr:last-child td {
  border-bottom: none;
}

/* Detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.detail-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}
.detail-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  font-weight: 600;
  padding: 0.75rem 1rem 0;
  margin: 0;
}
.detail-list {
  padding: 0.5rem 1rem 0.75rem;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  font-size: 0.8125rem;
}
.detail-label {
  color: var(--color-muted);
}
.detail-value {
  font-weight: 500;
  text-align: right;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-success {
  background: #e8f5ee;
  color: var(--color-success);
}
.badge-warning {
  background: #fdf1e6;
  color: #b8865a;
}
.badge-error {
  background: #fdf0f0;
  color: var(--color-error);
}
.badge-info {
  background: #ecfdf5;
  color: var(--color-primary);
}
.badge-muted {
  background: #f1f5f9;
  color: var(--color-muted);
}

/* Forms */
.form-card {
  max-width: 400px;
  margin: 4rem auto;
}
.form-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1.5rem;
  text-align: center;
}
.form-group {
  margin-bottom: 1rem;
}
.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}
.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}
.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(45, 106, 79, 0.15);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  transition: background 0.15s;
}
.btn:hover {
  background: #f1f5f9;
  text-decoration: none;
}
.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover {
  background: var(--color-primary-hover);
}
.btn-block {
  display: flex;
  width: 100%;
}
.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
}
.btn-ghost {
  background: none;
  color: var(--color-muted);
  border: none;
  padding: 0.25rem 0.5rem;
}
.btn-ghost:hover {
  color: var(--color-text);
}
.btn-danger {
  background: var(--color-error);
  color: white;
}
.btn-danger:hover {
  background: #c43e3e;
}

/* Flash messages */
.flash {
  padding: 0.625rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.8125rem;
}
.flash-alert {
  background: #fef2f2;
  color: var(--color-error);
  border: 1px solid #fecaca;
}
.flash-notice {
  background: #f0fdf4;
  color: var(--color-success);
  border: 1px solid #bbf7d0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-muted);
  font-size: 0.875rem;
}

/* Utilities */
.mono {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.muted {
  color: var(--color-muted);
}
.text-sm {
  font-size: 0.8125rem;
}
.text-right {
  text-align: right;
}
.nowrap {
  white-space: nowrap;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
  display: inline-block;
}
.mt-0 {
  margin-top: 0;
}
.mb-0 {
  margin-bottom: 0;
}
.mb-4 {
  margin-bottom: 1rem;
}
.mb-6 {
  margin-bottom: 1.5rem;
}
.flex {
  display: flex;
}
.items-center {
  align-items: center;
}
.items-baseline {
  align-items: baseline;
}
.justify-between {
  justify-content: space-between;
}
.gap-2 {
  gap: 0.5rem;
}
.gap-4 {
  gap: 1rem;
}
.inline-block {
  display: inline-block;
}

/* Transcript */
.transcript-list {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  padding: 0.5rem 0;
}
.transcript-entry {
  display: flex;
  gap: 0.75rem;
  padding: 0.3rem 1rem;
  font-size: 0.8125rem;
  align-items: baseline;
}
.transcript-entry:hover {
  background: #f1f5f9;
}
.transcript-entry.provisional {
  opacity: 0.5;
}
.transcript-ts {
  flex-shrink: 0;
  width: 4rem;
  color: var(--color-muted);
}
.transcript-speaker {
  flex-shrink: 0;
  width: 8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.transcript-text {
  flex: 1;
}

/* Speaker grid */
.speaker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.speaker-card { display: flex; flex-direction: column; align-items: center; padding: 1.25rem; border: 1px solid var(--color-border); border-radius: var(--radius); text-decoration: none; color: inherit; transition: border-color 0.15s; }
.speaker-card:hover { border-color: var(--color-primary); text-decoration: none; }
.speaker-avatar { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 14px; margin-bottom: 0.5rem; }
.speaker-name { font-weight: 600; margin-bottom: 0.25rem; }
.speaker-stats { font-size: 13px; color: var(--color-muted); }
.speaker-meta { font-size: 12px; color: var(--color-muted); margin-top: 0.25rem; }
.speaker-quality { display: inline-flex; gap: 2px; margin-left: 0.5rem; }

/* Speaker panel (transcript sidebar) */
.speaker-panel { margin-bottom: 1.5rem; padding: 1rem; border: 1px solid var(--color-border); border-radius: var(--radius); }
.speaker-panel h3 { margin: 0 0 0.5rem; font-size: 14px; }
.speaker-panel-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0; font-size: 14px; }
.speaker-panel-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.speaker-panel-local { font-family: var(--font-mono); color: var(--color-muted); }
.speaker-panel-arrow { color: var(--color-muted); }
.speaker-panel-label { font-weight: 500; }
.speaker-panel-conf { font-size: 12px; color: var(--color-muted); }

/* Inline edit */
.inline-edit-row { display: flex; align-items: center; gap: 8px; }
.inline-edit-form { display: none; }
.inline-edit-actions { display: none; }
.inline-edit-row.inline-edit--active .inline-edit-form { display: inline; }
.inline-edit-row.inline-edit--active .inline-edit-actions { display: inline-flex; gap: 4px; align-items: center; }
.inline-edit-row.inline-edit--active [data-inline-edit-target="display"],
.inline-edit-row.inline-edit--active .inline-edit-pencil { display: none; }
.inline-edit-input {
  font-size: 1.5rem; font-weight: 600; font-family: inherit;
  padding: 2px 6px; border: 1px solid var(--color-primary);
  border-radius: var(--radius); outline: none;
  box-shadow: 0 0 0 2px rgba(45, 106, 79, 0.15);
  background: var(--color-surface); color: var(--color-text);
  width: 16rem;
}
.inline-edit-input--error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 2px rgba(224, 82, 82, 0.2);
}
.inline-edit-pencil {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--color-muted); padding: 4px; border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.inline-edit-pencil:hover { color: var(--color-primary); background: rgba(45, 106, 79, 0.08); }
.inline-edit-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius);
  border: 1px solid var(--color-border); background: var(--color-surface);
  cursor: pointer; transition: all 0.15s; color: var(--color-muted);
}
.inline-edit-btn:hover { border-color: var(--color-muted); }
.inline-edit-btn--accept:hover { color: var(--color-success); border-color: var(--color-success); background: rgba(22, 163, 74, 0.08); }
.inline-edit-btn--cancel:hover { color: var(--color-error); border-color: var(--color-error); background: rgba(224, 82, 82, 0.08); }

/* Merge panel */
.merge-panel { margin-top: 1.5rem; padding: 1rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); }
.merge-panel h3 { margin: 0 0 0.5rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-muted); font-weight: 600; }
.merge-panel p { font-size: 0.8125rem; color: var(--color-muted); margin: 0 0 0.75rem; }
.merge-form { display: flex; gap: 0.5rem; align-items: center; }
.merge-select { flex: 1; padding: 0.375rem 0.5rem; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: 0.8125rem; font-family: inherit; background: var(--color-surface); color: var(--color-text); }

/* Conversation layout */
.conversation {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  padding: 1rem;
  max-height: 70vh;
  overflow-y: auto;
}
.conv-turn {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.conv-turn--continuation {
  padding-top: 0;
}
.conv-turn--provisional {
  opacity: 0.55;
}
.conv-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.8125rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}
.conv-avatar-spacer {
  width: 32px;
  flex-shrink: 0;
}
.conv-body {
  flex: 1;
  min-width: 0;
}
.conv-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.125rem;
}
.conv-speaker {
  font-weight: 600;
  font-size: 0.8125rem;
}
.conv-ts {
  color: var(--color-muted);
  font-size: 0.6875rem;
}
.conv-bubble {
  font-size: 0.875rem;
  line-height: 1.6;
}

/* Word-level styles */
.word {
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.1s;
  padding: 0 1px;
}
.word:hover {
  background: rgba(45, 106, 79, 0.08);
}
.word--active {
  background: rgba(45, 106, 79, 0.2);
}
.word--provisional {
  font-style: italic;
}

/* Confidence visualization */
.word--low-confidence {
  text-decoration: underline dotted var(--color-warning);
  text-underline-offset: 3px;
}
.word--very-low-confidence {
  text-decoration: underline wavy var(--color-error);
  text-underline-offset: 3px;
  opacity: 0.85;
}

/* Interpretation switcher */
.interpretation-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
}
.interpretation-switcher label {
  color: var(--color-muted);
  font-weight: 500;
  white-space: nowrap;
}
.interpretation-switcher select {
  flex: 1;
  max-width: 400px;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}

/* Shared animations */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
