/* DALILA — dark theme */

:root {
  --bg: #0b0f14;
  --bg-elev: #121821;
  --bg-input: #1a2230;
  --border: #232d3d;
  --text: #e8edf4;
  --text-dim: #8b98ab;
  --accent: #7c5cff;
  --accent-soft: rgba(124, 92, 255, 0.18);
  --user-bubble: #2a3447;
  --danger: #ff5c7a;
  --ok: #3ddc97;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#chat {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
}

/* ── Cabecera ─────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #4c9fff);
}

.brand-text h1 { font-size: 17px; letter-spacing: 1px; }

.status { font-size: 12px; color: var(--text-dim); }
.status[data-state="online"]  { color: var(--ok); }
.status[data-state="offline"] { color: var(--danger); }

/* ── Mensajes ─────────────────────────────── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.msg { display: flex; }
.msg.user { justify-content: flex-end; }

.bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.45;
  font-size: 15px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg.dalila .bubble {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.user .bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.error .bubble {
  background: rgba(255, 92, 122, 0.12);
  border: 1px solid rgba(255, 92, 122, 0.4);
  color: var(--danger);
}

/* Indicador "escribiendo" */
.typing .bubble { display: flex; gap: 5px; padding: 14px 16px; }
.typing .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-dim);
  animation: blink 1.2s infinite both;
}
.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ── Barra de entrada ─────────────────────── */
#input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
}

#message-input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
#message-input:focus { border-color: var(--accent); }
#message-input::placeholder { color: var(--text-dim); }

.icon-btn {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
.icon-btn:active { transform: scale(0.94); }

.icon-btn.send { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Micrófono grabando */
.icon-btn.mic.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 92, 122, 0.5); }
  70%  { box-shadow: 0 0 0 14px rgba(255, 92, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 92, 122, 0); }
}

/* TTS activado */
#tts-toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
#tts-toggle[aria-pressed="false"] .tts-waves { display: none; }

/* Scrollbar discreta */
#messages::-webkit-scrollbar { width: 8px; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
