:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #687082;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --bubble-bot: #eef1f6;
  --danger: #c93636;
  --ok: #1d7a46;
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* Oscuro: el del sistema, salvo que se haya elegido claro con el botón (data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b;
    --surface: #1b2029;
    --text: #e7e9ee;
    --muted: #9aa2b1;
    --accent: #5b8cff;
    --bubble-bot: #262c38;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b;
  --surface: #1b2029;
  --text: #e7e9ee;
  --muted: #9aa2b1;
  --accent: #5b8cff;
  --bubble-bot: #262c38;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Altura fija de pantalla: solo hacen scroll los mensajes y el campo de escribir queda
   siempre visible abajo. */
.chat-page { max-width: 560px; margin: 0 auto; padding: 16px; height: 100dvh;
  display: flex; flex-direction: column; gap: 12px; }
.biz h1 { margin: 8px 0 4px; font-size: 1.5rem; }
.biz p { margin: 2px 0; color: var(--muted); }

.chat { flex: 1; display: flex; flex-direction: column; background: var(--surface);
  border-radius: var(--radius); box-shadow: 0 2px 12px rgb(0 0 0 / 8%); overflow: hidden;
  min-height: 0; }
.chat-title { display: flex; align-items: center; gap: 10px; padding: 8px 14px 10px;
  font-weight: 600; background: var(--accent); color: var(--accent-text); }
.chat-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: rgb(255 255 255 / 22%); font-weight: 700; }
.chat-name { display: flex; flex-direction: column; line-height: 1.2; }
.chat-name small { font-weight: 400; font-size: .75rem; opacity: .85; }
.chat-name small::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px;
  border-radius: 50%; background: #4ade80; vertical-align: 1px; }
.messages { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { border-radius: 3px; background: color-mix(in srgb, var(--muted) 45%, transparent); }
.messages { list-style: none; margin: 0; padding: 16px; flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; }
.messages li { max-width: 85%; padding: 10px 14px; border-radius: 18px; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: anywhere; }
.messages .bot { background: var(--bubble-bot); align-self: flex-start;
  border-bottom-left-radius: 4px; }
.messages .user { background: var(--accent); color: var(--accent-text); align-self: flex-end;
  border-bottom-right-radius: 4px; }
.messages .user a { color: inherit; }
.messages .typing { color: var(--muted); font-style: italic; }

.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--bubble-bot); }
.composer input { flex: 1; font: inherit; padding: 12px 14px; border-radius: 24px;
  border: 1px solid var(--bubble-bot); background: var(--bg); color: var(--text); min-width: 0; }
.composer button, .button, .danger { font: inherit; border: 0; border-radius: 24px;
  padding: 12px 18px; background: var(--accent); color: var(--accent-text); cursor: pointer;
  text-decoration: none; display: inline-block; }
.composer button:disabled { opacity: .5; cursor: wait; }
.legal { margin: 0; padding: 0 16px 12px; font-size: .75rem; color: var(--muted); }

body.embed .chat-page { padding: 0; max-width: none; }
body.embed .chat-page { height: 100dvh; }
body.embed .chat { border-radius: 0; box-shadow: none; }
body.embed .legal { padding-bottom: 18px; }  /* deja sitio al indicador de inicio del móvil */

.card { max-width: 480px; margin: 40px auto; padding: 24px; background: var(--surface);
  border-radius: var(--radius); box-shadow: 0 2px 12px rgb(0 0 0 / 8%); }
.danger { background: var(--danger); }
.error { color: var(--danger); }
.ok { color: var(--ok); font-weight: 600; }
.muted { color: var(--muted); }

/* Horas pulsables y confirmación */
.messages .choices { align-self: stretch; max-width: none; padding: 4px 0; white-space: normal; }
.choices p { margin: 0; }
.choices-title { font-size: .9rem; color: var(--muted); margin-bottom: 6px !important; }
.choices-day { font-weight: 600; font-size: .9rem; margin: 10px 0 6px !important; }
.choices-day::first-letter { text-transform: uppercase; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: .95rem; padding: 8px 14px; border-radius: 999px;
  border: 1.5px solid var(--accent); background: var(--surface); color: var(--accent);
  cursor: pointer; min-height: 40px; }
.chip:hover { background: var(--bubble-bot); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.chip:focus-visible, .confirm .button:focus-visible { outline: 3px solid var(--accent);
  outline-offset: 2px; }
.confirm { margin-top: 12px; padding: 14px; border-radius: 14px; background: var(--bubble-bot);
  display: flex; flex-direction: column; gap: 8px; }
.confirm-title { font-weight: 600; }
.confirm-summary { line-height: 1.5; }
.confirm input { font: inherit; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--muted); background: var(--surface); color: var(--text); }
.confirm-error { color: var(--danger); font-size: .9rem; }
.confirm-error:empty { display: none; }
.confirm-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.confirm .button { padding: 10px 18px; }
.confirm .button:disabled { opacity: .6; cursor: wait; }
.button.secondary { background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent); }

/* Días como botones grandes (día de la semana, número y mes) y debajo sus horas. */
.chips.days { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.days::-webkit-scrollbar { display: none; }
.day-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 58px; padding: 6px 10px; border-radius: 14px; line-height: 1.1; }
.dc-week, .dc-month { font-size: .72rem; text-transform: capitalize; opacity: .85; }
.dc-num { font-size: 1.15rem; font-weight: 700; }
.times:empty { display: none; }

/* Negocio en pausa (suspendido): sin chat, solo el teléfono. */
.paused { flex: 1; display: grid; place-content: center; gap: 16px; text-align: center;
  padding: 32px 24px; color: var(--muted); }
.paused p { margin: 0; max-width: 28ch; }
.paused .button { justify-self: center; }

/* Botón de modo claro / oscuro */
.theme-toggle { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
  margin: 0; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  background: transparent; color: var(--text); font-size: 1.05rem; line-height: 1; cursor: pointer;
  transition: background .15s, transform .15s; }
.theme-toggle:hover { background: color-mix(in srgb, var(--muted) 14%, transparent); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
