/* «¿Dudas?», the assistant at the side of every page (templates/_assistant.html, static/assistant.js). Its own file,
   unlayered on purpose (it wins over app.css's layers) and every rule under .asst*, so nothing here touches the pages.
   The button: bottom right, clear of the notch and the home indicator; the script lifts it over the sticky action bar,
   the iPhone banner and any primary button under it, and hides it while a field is typed in on a phone or another
   window is open. The panel: a side sheet from 720 px, a bottom sheet on phones. */

.asst { --asst-lift: 0px; position: fixed; z-index: 45; right: max(20px, calc(env(safe-area-inset-right) + 12px));
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); display: flex; flex-direction: column; align-items: flex-end;
  transform: translateY(calc(-1 * var(--asst-lift))); transition: transform .2s ease, opacity .2s ease; pointer-events: none; }
.asst > * { pointer-events: auto; }
.asst.is-away { opacity: 0; transform: translateY(calc(16px - var(--asst-lift))); }
.asst.is-away > * { pointer-events: none; visibility: hidden; transition: visibility 0s .2s; }
html.splash-on .asst, html.asst-open .asst { visibility: hidden; }

.asst-fab { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; margin: 0;
  padding: 0 18px 0 13px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--grad-strong, linear-gradient(135deg, #6741d9, #c2255c)); color: #fff;
  font: 800 .98rem/1 var(--sans, Inter, system-ui, sans-serif); letter-spacing: .01em;
  box-shadow: 0 8px 22px rgba(103, 65, 217, .32), 0 2px 6px rgba(16, 24, 40, .12); }
.asst-fab:hover { filter: brightness(1.06); box-shadow: 0 10px 26px rgba(103, 65, 217, .4), 0 2px 6px rgba(16, 24, 40, .14); }
.asst-fab:focus-visible { outline: 3px solid #fff; outline-offset: 0; box-shadow: 0 0 0 6px #5b3fd9, 0 8px 22px rgba(103, 65, 217, .32); }
.asst-fab-icon { display: grid; place-items: center; width: 26px; height: 26px; }
.asst-fab-icon svg { width: 26px; height: 26px; }
/* the ring that pulses a few times when the page opens, then stays still */
.asst-fab::before { content: ""; position: absolute; inset: -3px; border-radius: inherit; border: 3px solid rgba(194, 37, 92, .55);
  opacity: 0; pointer-events: none; }
.asst-fab.is-pulsing::before { animation: asst-ring 1.7s ease-out 3; }
.asst-fab.is-pulsing-once::before { animation: asst-ring 1.7s ease-out 1; }
@keyframes asst-ring { 0% { opacity: .9; transform: scale(1); } 80%, 100% { opacity: 0; transform: scale(1.32, 1.5); } }

/* the one-time hint «¿Dudas? Preguntame lo que quieras»: small, right next to the button (to its left, on its line),
   gone by itself after 5 s; never on a page with a video player or a sticky action bar (QA 2026-11-20: it covered the
   player of a finished video and a card of the landing) */
.asst:has(> .asst-tip:not([hidden])) { flex-direction: row; align-items: center; }
.asst-tip { position: relative; display: flex; align-items: center; gap: 2px; margin: 0 10px 0 0; width: max-content;
  max-width: 172px; padding: 5px 2px 5px 11px; border-radius: 12px; background: #fff; color: var(--text, #1f2328);
  border: 1px solid var(--accent-line, #d4c9ff); box-shadow: 0 6px 18px rgba(16, 24, 40, .14);
  font: 600 .8rem/1.3 var(--sans, Inter, system-ui, sans-serif); white-space: normal; animation: asst-rise .25s ease; }
.asst-tip::after { content: ""; position: absolute; right: -6px; top: 50%; width: 10px; height: 10px; margin-top: -5px;
  background: #fff; border-right: 1px solid var(--accent-line, #d4c9ff); border-bottom: 1px solid var(--accent-line, #d4c9ff);
  transform: rotate(-45deg); }
.asst-tip-close { display: grid; place-items: center; flex: none; width: 28px; height: 28px; margin: 0; padding: 0; border: 0;
  border-radius: 50%; background: none; color: var(--soft, #4b5563); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.asst-tip-close:hover { background: var(--bg-2, #f1f1f6); }
@keyframes asst-rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------------------------------------- the panel */
.asst-panel { position: fixed; inset: 0 0 0 auto; width: min(420px, 100vw); height: 100vh; height: 100dvh; max-width: none;
  max-height: none; margin: 0; padding: 0; border: 0; border-left: 1px solid var(--line, #e6e6ee); background: #fff;
  color: var(--text, #1f2328); box-shadow: -16px 0 44px rgba(16, 24, 40, .18); overflow: hidden; }
.asst-panel[open] { display: flex; animation: asst-in-side .22s ease; }
.asst-panel::backdrop { background: rgba(17, 24, 39, .22); }
@keyframes asst-in-side { from { transform: translateX(24px); opacity: .4; } }
.asst-sheet { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0;
  font: 400 1rem/1.5 var(--sans, Inter, system-ui, sans-serif); }
.asst-sheet p { max-width: none; margin: 0; }

.asst-head { display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line, #e6e6ee); }
.asst-mark { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: var(--grad-strong, linear-gradient(135deg, #6741d9, #c2255c)); color: #fff; }
.asst-mark svg { width: 24px; height: 24px; }
.asst-head-text { flex: 1; min-width: 0; }
.asst-head h2 { margin: 0; font: 800 1.1rem/1.25 var(--sans, Inter, system-ui, sans-serif); }
.asst-head h2:focus { outline: none; }
.asst-head-text p { color: var(--soft, #4b5563); font-size: .86rem; line-height: 1.35; }
.asst-close { display: grid; place-items: center; flex: none; width: 44px; height: 44px; margin: 0; padding: 0; border: 0;
  border-radius: 12px; background: none; color: var(--text, #1f2328); cursor: pointer; }
.asst-close:hover { background: var(--bg-2, #f1f1f6); }
.asst-close svg { width: 22px; height: 22px; }

.asst-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column;
  gap: 12px; padding: 16px 18px; background: var(--bg, #f7f7fa); }
.asst-msg { display: grid; gap: 8px; max-width: 92%; padding: 11px 14px; border-radius: 16px; font-size: .97rem; line-height: 1.5;
  overflow-wrap: anywhere; }
.asst-bot { align-self: flex-start; background: #fff; border: 1px solid var(--line, #e6e6ee); border-top-left-radius: 6px; }
.asst-me { align-self: flex-end; background: var(--accent-soft, #f1edff); border: 1px solid var(--accent-line, #d4c9ff);
  border-top-right-radius: 6px; }
.asst-msg.is-thinking { color: var(--soft, #4b5563); font-weight: 600; }
.asst-dots { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.asst-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; animation: asst-dot 1s infinite; }
.asst-dots i:nth-child(2) { animation-delay: .15s; }
.asst-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes asst-dot { 50% { opacity: 1; } }
/* an error or the daily limit: big and red */
.asst-msg.is-error { max-width: 100%; background: #ffe8e8; border: 2px solid #e57373; border-left: 6px solid #d32f2f; color: #5f1111;
  font-size: 1.02rem; font-weight: 700; }

.asst-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.asst-action, .asst-show { display: inline-flex; align-items: center; min-height: 40px; margin: 0; padding: 8px 14px;
  border-radius: 999px; font: 700 .9rem/1.25 var(--sans, Inter, system-ui, sans-serif); text-decoration: none; cursor: pointer; text-align: left; }
.asst-action { background: var(--grad-strong, linear-gradient(135deg, #6741d9, #c2255c)); color: #fff; border: 0; }
.asst-action:hover { filter: brightness(1.06); }
.asst-show { background: #fff; color: var(--accent-text, #5b3fd9); border: 2px solid var(--accent-line, #d4c9ff); }
.asst-show:hover { border-color: var(--accent-text, #5b3fd9); }
.is-error .asst-action { background: #fff; color: #b42318; border: 2px solid #e57373; }

.asst-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.asst-chip { min-height: 40px; margin: 0; padding: 8px 13px; border: 1px solid var(--accent-line, #d4c9ff); border-radius: 999px;
  background: #fff; color: var(--accent-text, #5b3fd9); font: 600 .9rem/1.3 var(--sans, Inter, system-ui, sans-serif);
  text-align: left; cursor: pointer; }
.asst-chip:hover { border-color: var(--accent-text, #5b3fd9); background: #faf8ff; }
.asst-chip:disabled, .asst-send:disabled { opacity: .55; cursor: progress; }

.asst-form { display: flex; align-items: flex-end; gap: 8px; margin: 0; padding: 12px 14px 10px; border-top: 1px solid var(--line, #e6e6ee);
  background: #fff; }
.asst-form textarea { flex: 1; min-width: 0; width: auto; min-height: 48px; max-height: 140px; padding: 11px 14px; resize: none;
  border: 1px solid var(--field-line, #7d8290); border-radius: 14px; background: #fff; color: var(--text, #1f2328);
  font: 400 1rem/1.45 var(--sans, Inter, system-ui, sans-serif); }
.asst-form textarea:focus { outline: none; border-color: var(--accent-text, #5b3fd9); box-shadow: 0 0 0 3px rgba(91, 63, 217, .22); }
.asst-send { flex: none; min-height: 48px; margin: 0; padding: 0 18px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--grad-strong, linear-gradient(135deg, #6741d9, #c2255c)); color: #fff; font: 800 .95rem/1 var(--sans, Inter, system-ui, sans-serif); }
.asst-send:hover { filter: brightness(1.06); }
.asst-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 0 16px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom)); background: #fff; color: var(--soft, #4b5563); font-size: .8rem; line-height: 1.4; }
.asst-foot > span { flex: 1 1 100%; }
.asst-clear { min-height: 32px; margin: 0; padding: 0; border: 0; background: none; color: var(--accent-text, #5b3fd9);
  font: 600 .8rem/1.2 var(--sans, Inter, system-ui, sans-serif); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.asst-foot a { color: var(--accent-text, #5b3fd9); font-weight: 600; }

.asst-panel :focus-visible { outline: 3px solid var(--accent-text, #5b3fd9); outline-offset: 2px; box-shadow: none; }

/* «Mostrame dónde»: the field, outlined and pulsing for a moment */
.asst-spot { outline: 3px solid #d6336c !important; outline-offset: 6px; border-radius: 12px; animation: asst-spot 1s ease-in-out 3; }
@keyframes asst-spot { 0%, 100% { box-shadow: 0 0 0 0 rgba(214, 51, 108, .45); } 50% { box-shadow: 0 0 0 12px rgba(214, 51, 108, 0); } }

/* ---------------------------------------------------------------- phones: an icon button and a bottom sheet */
@media (max-width: 719px) {
  .asst { right: max(14px, calc(env(safe-area-inset-right) + 8px)); bottom: max(14px, calc(env(safe-area-inset-bottom) + 8px)); }
  .asst-fab { width: 54px; height: 54px; min-height: 54px; padding: 0; justify-content: center; }
  .asst-fab-icon, .asst-fab-icon svg { width: 28px; height: 28px; }
  .asst-fab-label { display: none; }
  .asst-panel { inset: auto 0 0 0; width: 100%; height: min(82vh, 680px); height: min(82dvh, 680px); border-left: 0;
    border-radius: 20px 20px 0 0; box-shadow: 0 -16px 44px rgba(16, 24, 40, .22); }
  .asst-panel[open] { animation: asst-in-up .24s ease; }
  .asst-panel::backdrop { background: rgba(17, 24, 39, .42); }
  .asst-head { padding-top: 14px; }
  .asst-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px;
    border-radius: 4px; background: var(--line-2, #d6d6e0); }
  .asst-chip, .asst-action, .asst-show { min-height: 44px; }
  .asst-clear { min-height: 44px; }
  .asst-log { padding: 14px; }
}
@keyframes asst-in-up { from { transform: translateY(32px); opacity: .4; } }

/* the footer's last line never sits under the button (QA 2026-11-20, phones): room for it below */
html.asst-on .foot { padding-bottom: 76px; }

@media (prefers-reduced-motion: reduce) {
  .asst, .asst-panel[open], .asst-tip { transition: none; animation: none; }
  .asst-fab.is-pulsing::before, .asst-fab.is-pulsing-once::before, .asst-dots i, .asst-spot { animation: none; }
}
