/* Monibot - Paleta cálida y profesional */
:root {
  --bg: #f7f3ee;          /* beige cálido */
  --bg-2: #ede4d8;        /* beige más oscuro */
  --surface: #ffffff;
  --surface-2: #faf6f0;
  --border: #e2d6c4;
  --border-strong: #c9b89e;
  --text: #2d241c;        /* marrón oscuro */
  --text-soft: #5b4a3a;
  --muted: #8a7864;
  --primary: #a0512d;     /* terracota */
  --primary-hover: #8a4324;
  --accent: #d4a373;      /* arena */
  --success: #6b8e4e;     /* oliva suave */
  --warn: #c08552;
  --danger: #9b3d2f;
  --shadow: 0 2px 8px rgba(80, 50, 25, 0.06);
  --shadow-lg: 0 12px 32px rgba(80, 50, 25, 0.10);
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Auth ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 10%, #f1e3cf 0%, transparent 50%),
    radial-gradient(circle at 80% 90%, #e9d6bb 0%, transparent 50%),
    var(--bg);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.brand-mark {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 22px;
  letter-spacing: -0.5px;
}
.brand-mark.small { width: 36px; height: 36px; font-size: 16px; }
.brand h1 { margin: 0; font-size: 22px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  background: none; border: 0; padding: 10px 14px; cursor: pointer;
  font: inherit; color: var(--muted); border-bottom: 2px solid transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-soft); }
.form input, .form select, .form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  font: inherit;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(160, 81, 45, 0.12);
}

/* Estilo de los grupos de opciones en el select (Mis voces vs Sistema) */
select optgroup {
  font-weight: 700;
  color: var(--primary);
  background: var(--surface-2);
  font-style: normal;
}
select option {
  color: var(--text);
  font-weight: 400;
}

/* Slider de velocidad */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  outline: none;
  padding: 0;
  border: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.form textarea { resize: vertical; min-height: 90px; font-family: inherit; }
.error {
  background: #f7e2dc; color: var(--danger);
  border: 1px solid #e8c1b8;
  padding: 8px 12px; border-radius: 8px; font-size: 13px;
}
.footnote { text-align: center; margin-top: 18px; font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; font: inherit; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: all .15s;
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn.ghost:hover { background: var(--bg-2); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- App Layout ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 14px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand-name { font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  color: var(--text-soft); font-weight: 500;
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active { background: var(--bg-2); color: var(--primary); }
.ico { width: 18px; text-align: center; opacity: 0.8; }
#btn-logout { margin-top: 16px; }
.content { padding: 28px 36px; overflow-y: auto; }

/* ---------- Page sections ---------- */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.page-header h1 { margin: 0; font-size: 22px; }
.page-header p { margin: 4px 0 0; color: var(--muted); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card .desc { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Tables / Lists ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
}
.item .meta { flex: 1; min-width: 0; }
.item .meta b { display: block; font-size: 14px; }
.item .meta span { color: var(--muted); font-size: 12px; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--bg-2); color: var(--text-soft); font-size: 11px;
  border: 1px solid var(--border); margin-right: 4px;
}

/* ---------- Dashboard cards ---------- */
.stat {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px;
}
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; color: var(--text); }

/* ---------- Chat Preview ---------- */
.chat-window {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  height: 320px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.bubble {
  max-width: 80%; padding: 8px 12px; border-radius: 12px;
  font-size: 13px; line-height: 1.4;
  white-space: pre-wrap; word-break: break-word;
}
.bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 2px; }
.bubble.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 2px; }
.bubble.system { align-self: center; background: transparent; color: var(--muted); font-size: 12px; }
.bubble.typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.bubble.typing .dot-typing {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); opacity: 0.6;
  animation: dotBounce 1.2s infinite ease-in-out;
}
.bubble.typing .dot-typing:nth-child(2) { animation-delay: 0.15s; }
.bubble.typing .dot-typing:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.cursor {
  display: inline-block; width: 8px; height: 14px;
  background: var(--primary);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: cursorBlink 1s infinite step-end;
}
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ---------- Voice preview ---------- */
.voice-panel {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
.voice-status {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; width: fit-content;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--success); box-shadow: 0 0 0 4px rgba(107, 142, 78, 0.18); }
.dot.recording { background: var(--danger); box-shadow: 0 0 0 4px rgba(155, 61, 47, 0.18); }

.mic-button {
  width: 84px; height: 84px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; border: 0; cursor: pointer; font-size: 28px;
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
  transition: transform .1s;
}
.mic-button:hover { transform: scale(1.04); }
.mic-button.active { animation: pulse 1.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(160, 81, 45, 0.5); }
  70% { box-shadow: 0 0 0 18px rgba(160, 81, 45, 0); }
  100% { box-shadow: 0 0 0 0 rgba(160, 81, 45, 0); }
}

.transcript {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; min-height: 160px; max-height: 220px; overflow-y: auto;
  font-size: 13px;
}
.transcript .speaker { font-weight: 600; color: var(--primary); margin-right: 6px; }

.audio-player { width: 100%; margin-top: 8px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(45, 36, 28, 0.5);
  display: grid; place-items: center;
  z-index: 99;
  padding: 24px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 640px;
  padding: 24px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Helpers ---------- */
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code {
  background: var(--bg-2); padding: 1px 6px; border-radius: 4px;
  font-size: 12px; color: var(--text-soft);
}
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox input { width: auto; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .grid-2, .grid-3, .voice-panel { grid-template-columns: 1fr; }
}
