/* Tipografía, componentes y utilidades CSS estáticas.
   Antes usábamos Tailwind Play CDN; en producción generaba warning en consola.
   Estas utilidades cubren las clases usadas por index.html/app.js sin runtime. */

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, p { margin: 0; }
button, input, select { font: inherit; }
button, select { text-transform: none; }
svg { display: block; }

.hidden { display: none !important; }
.block { display: block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.flex-1 { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: .25rem; }
.gap-1\.5 { gap: .375rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.space-y-5 > * + * { margin-top: 1.25rem; }
.sticky { position: sticky; }
.top-0 { top: 0; }
.top-\[60px\] { top: 60px; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.min-h-screen { min-height: 100vh; }
.min-w-0 { min-width: 0; }
.h-1\.5 { height: .375rem; }
.h-7 { height: 1.75rem; }
.h-9 { height: 2.25rem; }
.h-full { height: 100%; }
.w-7 { width: 1.75rem; }
.w-9 { width: 2.25rem; }
.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-4xl { max-width: 56rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.mt-0\.5 { margin-top: .125rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-1 { padding: .25rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-10 { padding: 2.5rem; }
.px-0 { padding-left: 0; padding-right: 0; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-1 { padding-top: .25rem; padding-bottom: .25rem; }
.py-2 { padding-top: .5rem; padding-bottom: .5rem; }
.py-2\.5 { padding-top: .625rem; padding-bottom: .625rem; }
.py-3 { padding-top: .75rem; padding-bottom: .75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-10 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.py-16 { padding-top: 4rem; padding-bottom: 4rem; }
.rounded-md { border-radius: .375rem; }
.rounded-lg { border-radius: .5rem; }
.rounded-xl { border-radius: .75rem; }
.rounded-full { border-radius: 9999px; }
.border { border: 1px solid; }
.border-0 { border-width: 0; }
.border-b { border-bottom: 1px solid; }
.border-b-2 { border-bottom: 2px solid; }
.border-stone-200 { border-color: #e7e5e4; }
.border-stone-300 { border-color: #d6d3d1; }
.border-red-200 { border-color: #fecaca; }
.bg-white { background: #fff; }
.bg-white\/70 { background: rgba(255,255,255,.7); }
.bg-transparent { background: transparent; }
.bg-stone-200 { background: #e7e5e4; }
.bg-stone-200\/60 { background: rgba(231,229,228,.6); }
.bg-red-50 { background: #fef2f2; }
.text-center { text-align: center; }
.text-xs { font-size: .75rem; line-height: 1rem; }
.text-sm { font-size: .875rem; line-height: 1.25rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.uppercase { text-transform: uppercase; }
.tracking-tight { letter-spacing: -.025em; }
.tracking-wider { letter-spacing: .05em; }
.text-stone-400 { color: #a8a29e; }
.text-stone-500 { color: #78716c; }
.text-stone-700 { color: #44403c; }
.text-stone-800 { color: #292524; }
.text-stone-900 { color: #1c1917; }
.text-red-800 { color: #991b1b; }
.placeholder\:text-stone-400::placeholder { color: #a8a29e; }
.cursor-pointer { cursor: pointer; }
.overflow-hidden { overflow: hidden; }
.backdrop-blur { backdrop-filter: blur(8px); }
.transition { transition-property: color, background-color, border-color, transform, opacity, box-shadow; transition-duration: .15s; }
.transition-all { transition-property: all; }
.duration-700 { transition-duration: .7s; }
.focus\:border-orange-500:focus { border-color: #f97316; }
.focus\:outline-none:focus { outline: 2px solid transparent; outline-offset: 2px; }
.focus\:ring-1:focus { box-shadow: 0 0 0 1px #f97316; }
.focus\:ring-orange-500:focus { box-shadow: 0 0 0 1px #f97316; }

.app-shell,
.app-main,
.app-footer {
  width: calc(100% - 260px);
  margin-left: 260px;
  margin-right: 0;
}
.app-shell {
  max-width: none;
}
.app-main > section,
.app-footer {
  max-width: 1120px;
}
.app-main > section {
  margin-left: auto;
  margin-right: auto;
}
.app-footer {
  margin-left: calc(260px + max(1.5rem, (100% - 260px - 1120px) / 2));
  width: min(1120px, calc(100% - 260px - 3rem));
}

@media (min-width: 640px) {
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  .md\:flex-row { flex-direction: row; }
  .md\:items-end { align-items: flex-end; }
  .md\:justify-between { justify-content: space-between; }
  .md\:p-8 { padding: 2rem; }
}

:root {
  --color-paper: #fbf8f3;       /* fondo cálido crema */
  --color-ink: #2a2a2a;
  --color-muted: #6b6b6b;
  --color-accent: #b46a4a;      /* terracota suave */
  --color-accent-soft: #f0d9cc;
  --color-success: #4a7c59;
  --color-danger: #b04848;
}

html, body {
  background-color: var(--color-paper);
  color: var(--color-ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Tipografía ideal para leer transcripciones largas */
.transcript-body {
  font-family: 'Lora', 'Georgia', 'Times New Roman', serif;
  font-size: 1.075rem;
  line-height: 1.75;
  color: #1f1f1f;
}

/* Etiqueta de hablante */
.speaker-tag {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.15rem 0.65rem;
  border-radius: 9999px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.speaker-tag:hover {
  background: var(--color-accent);
  color: #fff;
}
.speaker-tag[data-editing="true"] {
  background: #fff;
  color: var(--color-ink);
  outline: 2px solid var(--color-accent);
  padding: 0.1rem 0.5rem;
}

/* Inputs limpios */
input[type="text"], textarea {
  font-family: 'Inter', sans-serif;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed #d6cfc4;
  background: #fff;
  transition: all 0.2s ease;
}
.drop-zone.is-dragover {
  border-color: var(--color-accent);
  background: #fff7f0;
}
.drop-zone.is-uploading {
  border-style: solid;
  border-color: var(--color-accent);
  background: #fff7f0;
}

/* Toggle switch (interruptor) */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 3.25rem;
  height: 1.75rem;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #d6cfc4;
  transition: 0.25s;
  border-radius: 9999px;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 1.35rem;
  width: 1.35rem;
  left: 0.2rem;
  top: 0.2rem;
  background-color: #fff;
  transition: 0.25s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch input:checked + .toggle-slider {
  background-color: var(--color-accent);
}
.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(1.5rem);
}

/* Spinner suave */
.spinner-soft {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 2.5px solid #e8dfd4;
  border-top-color: var(--color-accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Botón principal */
.btn-primary {
  background-color: var(--color-accent);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: all 0.15s ease;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}
.btn-primary:hover:not(:disabled) {
  background-color: #9a5638;
  transform: translateY(-1px);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: #fff;
  color: var(--color-ink);
  padding: 0.6rem 1.1rem;
  border-radius: 0.5rem;
  font-weight: 500;
  border: 1px solid #d6cfc4;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.15s ease;
}
.btn-secondary:hover {
  background-color: #f5f0e8;
  border-color: var(--color-accent);
}

.btn-ghost {
  background: transparent;
  color: var(--color-muted);
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
  border-radius: 0.4rem;
  transition: all 0.15s ease;
}
.btn-ghost:hover {
  background: #f0ebe2;
  color: var(--color-ink);
}

/* Tarjeta de hablante renombrado */
.speaker-card {
  background: #fff;
  border: 1px solid #e8dfd4;
  border-radius: 0.6rem;
  padding: 0.7rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.speaker-toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #fff8ee;
  border: 1px solid #efd8c7;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
}
.speaker-toolbar-title {
  font-weight: 700;
  color: var(--color-ink);
}
.speaker-toolbar-hint {
  color: var(--color-muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}
.speaker-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}
.speaker-merge-target,
.segment-speaker-select {
  border: 1px solid #d6cfc4;
  border-radius: 0.4rem;
  background: #fff;
  color: var(--color-ink);
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
}
.speaker-action,
.speaker-action-primary {
  border: 1px solid #d6cfc4;
  border-radius: 0.4rem;
  background: #fff;
  color: var(--color-ink);
  cursor: pointer;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.speaker-action-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
  white-space: nowrap;
}
.speaker-action:hover,
.speaker-action-primary:hover {
  background: #f5f0e8;
  border-color: var(--color-accent);
  color: var(--color-ink);
}
.speaker-action.danger:hover {
  background: #fbe5e0;
  border-color: #f4c7bd;
  color: var(--color-danger);
}
.speaker-action:disabled,
.speaker-merge-target:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.speaker-card-color {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 9999px;
  flex-shrink: 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(2rem);
  background: #1f1f1f;
  color: #fff;
  padding: 0.7rem 1.2rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 100;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =====================================================================
   Reproductor de audio (sticky)
   ===================================================================== */
.audio-player {
  background: #ffffff;
  border: 1px solid #e8dfd4;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  box-shadow: 0 6px 24px -10px rgba(60, 40, 20, 0.18);
  /* top coincide aprox con la altura del header sticky (h-16 + border) */
}
.audio-player-inner {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.audio-btn-play {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 9999px;
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}
.audio-btn-play:hover {
  background: #9a5638;
  transform: scale(1.04);
}
.audio-timeline {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.audio-timeline input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #e8dfd4;
  border-radius: 9999px;
  outline: none;
  cursor: pointer;
}
.audio-timeline input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--color-accent);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.audio-timeline input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--color-accent);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
}
.audio-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}
.audio-btn-skip {
  background: #fff;
  border: 1px solid #d6cfc4;
  color: var(--color-ink);
  border-radius: 0.4rem;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.audio-btn-skip:hover {
  background: #f5f0e8;
  border-color: var(--color-accent);
}
.audio-speed {
  background: #fff;
  border: 1px solid #d6cfc4;
  color: var(--color-ink);
  border-radius: 0.4rem;
  padding: 0.32rem 0.45rem;
  font-size: 0.82rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* =====================================================================
   Segmento de transcripción (intervención)
   ===================================================================== */
.segment {
  margin-bottom: 1.25rem;
  padding: 0.4rem 2.4rem 0.5rem 0.7rem;
  border-left: 3px solid transparent;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  position: relative;
}
.segment:last-child {
  margin-bottom: 0;
}
.segment:hover {
  background: #fbf6ee;
}
.segment.is-active {
  background: #fff3e8;
  border-left-color: var(--color-accent);
}
.segment-delete {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  width: 1.55rem;
  height: 1.55rem;
  border: 1px solid transparent;
  border-radius: 9999px;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.segment:hover .segment-delete,
.segment-delete:focus {
  opacity: 1;
}
.segment-delete:hover,
.segment-delete:focus {
  background: #fbe5e0;
  border-color: #f4c7bd;
  color: var(--color-danger);
  outline: none;
}
.segment .speaker-tag {
  /* hereda .speaker-tag ya definido arriba; agregamos margen */
  margin-right: 0.4rem;
}
.segment-speaker-select {
  margin-left: 0.25rem;
  vertical-align: middle;
}

/* =====================================================================
   Texto editable inline (contentEditable)
   ===================================================================== */
.text-display {
  display: block;
  margin-top: 0.35rem;
  outline: none;
  border-radius: 0.25rem;
  padding: 0.15rem 0.3rem;
  margin-left: -0.3rem;
  transition: background 0.12s ease;
  cursor: text;
}
.text-display:hover {
  background: rgba(180, 106, 74, 0.06);
}
.text-display:focus {
  background: #fff8ee;
  box-shadow: inset 0 0 0 2px var(--color-accent);
}
.text-display.is-edited {
  background: rgba(180, 106, 74, 0.04);
  position: relative;
}
.text-display.is-edited::before {
  content: "editado";
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--color-accent);
  padding: 0.05rem 0.4rem;
  border-radius: 9999px;
  margin-right: 0.5rem;
  vertical-align: middle;
  text-transform: uppercase;
}

/* =====================================================================
   Sidebar de transcripciones previas
   ===================================================================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background: #fdfaf5;
  border-right: 1px solid #e8dfd4;
  z-index: 40;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}
.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid #f0e8da;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.btn-new {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 0.4rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-new:hover {
  background: #9a5638;
}
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}
.sidebar-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--color-ink);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.sidebar-item:hover {
  background: #f5efe4;
}
.sidebar-item.is-active {
  background: #f0e8da;
  border-left-color: var(--color-accent);
}
.sidebar-item-title {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.25;
  margin-bottom: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-item-title.is-empty {
  font-style: italic;
  color: var(--color-muted);
  font-weight: 500;
}
.sidebar-item-meta {
  font-size: 0.72rem;
  color: var(--color-muted);
  display: flex;
  gap: 0.5rem;
}
.sidebar-item-meta .dot {
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: center;
}
.sidebar-item-meta .dot.no-audio {
  background: #d6cfc4;
}
.sidebar-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--color-muted);
  font-size: 0.85rem;
}
.sidebar-item-delete {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.3rem;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.sidebar-item {
  position: relative;
}
.sidebar-item:hover .sidebar-item-delete {
  opacity: 1;
}
.sidebar-item-delete:hover {
  background: #fbe5e0;
  color: var(--color-danger);
}
.sidebar-footer {
  padding: 0.7rem 1rem;
  border-top: 1px solid #f0e8da;
  color: var(--color-muted);
  font-size: 0.72rem;
}

/* Hamburger button (solo mobile) */
.hamburger {
  display: none;
  position: fixed;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 50;
  background: #fff;
  border: 1px solid #d6cfc4;
  border-radius: 0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 35;
}

/* En desktop: el main se corre a la derecha del sidebar */
.app-main {
  margin-left: 260px;
}

/* En mobile: sidebar oculta por default (drawer), hamburger visible */
@media (max-width: 768px) {
  .app-shell,
  .app-main,
  .app-footer {
    width: 100%;
    margin-left: 0;
  }
  .app-footer {
    max-width: none;
  }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .sidebar-overlay.is-open {
    display: block;
  }
  .hamburger {
    display: inline-flex;
  }
}
