/* ════════════════════════════════════════════════════════════════
   EP · Asistente (según EP-Chatbot-Boceto, octubre 2026)
   1 Botón · 2 Bienvenida · 3 Panel y portada · 4 Conversación
   5 Presupuesto · 6 Resumen · 7 Celular · 8 Reducir movimiento
   ════════════════════════════════════════════════════════════════ */
.chat, .chat-dock {
  --c-ink: #111111; --c-paper: #FFFFFF; --c-text2: #4A4A4A;
  --c-label: #757575; --c-label-dark: #8A8A8A; --c-line: #D9D9D9; --c-online: #22C55E;
  --c-title: "Darker Grotesque", "Helvetica Neue", Arial, sans-serif;
  --c-body: "Helvetica Neue", Helvetica, Inter, Arial, sans-serif;
  --c-ease: cubic-bezier(.2, .7, .2, 1);
  font-family: var(--c-body); font-weight: 400; letter-spacing: 0;
}
.chat [hidden], .chat-dock [hidden] { display: none !important; }
.c-label { color: var(--c-label); font-size: 10px; font-weight: 500; line-height: 1.4; letter-spacing: .2em; text-transform: uppercase; }

/* La malla de EP: cuadrícula fina + puntos */
.c-mesh { position: relative; isolation: isolate; overflow: hidden; background: var(--c-ink); }
.c-mesh::before {
  content: ""; position: absolute; inset: -56px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle, rgba(255, 255, 255, .16) 1px, transparent 1.4px) 0 0 / 14px 14px,
    linear-gradient(rgba(255, 255, 255, .1) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, rgba(255, 255, 255, .1) 1px, transparent 1px) 0 0 / 56px 56px;
  animation: c-mesh 8s linear infinite;
}
@keyframes c-mesh { to { transform: translate(56px, 56px) } }

/* ═══ 1 · Botón cerrado ═══ */
.chat-dock { position: fixed; right: 24px; bottom: 24px; z-index: 105; display: flex; align-items: center; gap: 16px; }
.chat-launch { position: relative; flex: none; width: 84px; height: 84px; border-radius: 50%; color: #fff; background: var(--c-ink); box-shadow: 0 0 0 1px rgba(255, 255, 255, .3); transition: transform 300ms var(--c-ease); }
.chat-launch:focus-visible { outline: 2px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 1px #fff, 0 0 0 7px #111; }
.chat-launch__core { position: absolute; inset: 16px; border-radius: 50%; display: grid; place-items: center; font: 700 24px/1 var(--c-title); letter-spacing: -.01em; }
.chat-launch__core::before { inset: -56px; background-size: 14px 14px, 28px 28px, 28px 28px; }
.chat-launch__ring { position: absolute; inset: 0; width: 100%; height: 100%; animation: c-spin 20s linear infinite; }
.chat-launch__ring text { fill: #fff; font: 600 10.4px/1 var(--c-body); }
@keyframes c-spin { to { transform: rotate(360deg) } }
@media (hover: hover) { .chat-launch:hover { transform: scale(1.06); } }

/* ═══ 2 · Bienvenida ═══ */
.chat-hello { position: relative; background: #fff; color: var(--c-ink); border: 1px solid var(--c-line); border-radius: 4px; animation: c-rise 260ms var(--c-ease); }
.chat-hello__open { display: block; padding: 16px 56px 18px 18px; font: 400 18px/1.25 var(--c-body); }
.chat-hello__open .c-label { display: block; margin-bottom: 8px; }
.chat-hello__close { position: absolute; top: 0; right: 0; width: 44px; height: 44px; display: grid; place-items: center; font-size: 22px; line-height: 1; }
.chat-hello :focus-visible { outline: 2px solid var(--c-ink); outline-offset: -3px; }
@keyframes c-rise { from { opacity: 0; transform: translateY(10px) } }

/* ═══ 3 · Panel y portada ═══ */
.chat { position: fixed; inset: auto 24px 120px auto; z-index: 104; width: 344px; height: min(548px, calc(100dvh - 140px)); max-width: none; max-height: none; margin: 0; padding: 0; border: 1px solid var(--c-line); border-radius: 4px; overflow: hidden; background: #fff; color: var(--c-ink); color-scheme: light; }
.chat[open] { display: flex; flex-direction: column; }
.chat::backdrop { background: transparent; }
.chat :focus-visible { outline: 2px solid var(--c-ink); outline-offset: 2px; }
.chat__head :focus-visible { outline-color: #fff; }
.chat__curtain { position: absolute; inset: 0; z-index: 5; background: var(--c-ink); pointer-events: none; visibility: hidden; }
.chat.is-opening .chat__curtain { visibility: visible; animation: c-curtain 400ms cubic-bezier(.65, 0, .35, 1) both; }
@keyframes c-curtain { 0% { clip-path: inset(100% 0 0 0) } 55% { clip-path: inset(0) } 100% { clip-path: inset(0 0 100% 0) } }
.chat__head { flex: none; color: #fff; }
.chat__min { position: absolute; top: 8px; right: 8px; z-index: 2; width: 44px; height: 44px; display: grid; place-items: center; }
.chat__min::before { content: ""; width: 14px; height: 2px; background: #fff; }
.chat__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.chat__body:focus-visible { outline-offset: -3px; }

.chat__cover { display: none; height: 50%; padding: 18px 20px; flex-direction: column; justify-content: space-between; }
.chat.is-home .chat__cover { display: flex; }
.chat.is-home .chat__head { flex: 1 0 170px; display: flex; }
.chat.is-home .chat__body { flex: 0 1 auto; }
.chat.is-home .chat__cover { flex: 1; height: auto; }
.chat__cover .c-label { color: var(--c-label-dark); }
.chat__title { font: 400 38px/.86 var(--c-title); letter-spacing: -.01em; }
.chat__title span { display: inline-block; overflow: hidden; overflow: clip; padding: .1em 0 .2em; margin: -.1em 0 -.2em; vertical-align: top; }
.chat__title i { display: inline-block; font-style: normal; }
.chat__title b { font-weight: 700; }
.chat__cover p { margin-top: 8px; color: #B4B4B4; font-size: 13px; line-height: 1.4; }
.chat.is-opening .chat__title i { animation: c-word 500ms var(--c-ease) both; animation-delay: calc(300ms + var(--w) * 60ms); }
@keyframes c-word { from { transform: translateY(110%) } }

.chat__bar { display: none; align-items: center; gap: 12px; min-height: 56px; padding: 6px 60px 6px 10px; }
.chat:not(.is-home) .chat__bar { display: flex; }
.chat__avatar { flex: none; width: 44px; height: 44px; display: grid; place-items: center; }
.chat__avatar span { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: var(--c-ink); font: 700 18px/1 var(--c-title); }
.chat__name { font: 700 23px/.9 var(--c-title); }
.chat__online { display: flex; align-items: center; gap: 8px; margin-top: 5px; color: var(--c-label-dark); }
.chat__online i { width: 8px; height: 8px; border-radius: 50%; background: var(--c-online); animation: c-beat 2s ease-in-out infinite; }
@keyframes c-beat { 0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .5) } 50% { box-shadow: 0 0 0 5px rgba(34, 197, 94, .12) } }

/* Índice de servicios (portada, conversación y paso 1) */
.c-index { list-style: none; margin: 0; padding: 0; }
.c-index li { position: relative; }
.c-index li + li::before { content: ""; position: absolute; inset: 0 0 auto; z-index: 1; height: 1px; background: var(--c-line); transform-origin: left; animation: c-rule 300ms var(--c-ease) both; animation-delay: calc(var(--n, 0) * 40ms); }
@keyframes c-rule { from { transform: scaleX(0) } }
.c-row { position: relative; isolation: isolate; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 20px; color: var(--c-ink); font: 700 13px/1.15 var(--c-body); transition: color 200ms; }
.c-row::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--c-ink); transform: scaleX(0); transform-origin: left; transition: transform 280ms cubic-bezier(.65, 0, .35, 1); }
.c-row__n { color: var(--c-line); font: 400 24px/1 var(--c-title); transition: color 200ms; }
.c-row__a { opacity: 0; transform: translateX(-8px); transition: transform 280ms var(--c-ease), opacity 200ms; font-size: 16px; }
.c-row:is(:hover, :focus-visible, [aria-pressed="true"]) { color: #fff; }
.c-row:is(:hover, :focus-visible, [aria-pressed="true"])::before { transform: none; }
.c-row:is(:hover, :focus-visible, [aria-pressed="true"]) .c-row__n { color: #fff; }
.c-row:is(:hover, :focus-visible, [aria-pressed="true"]) .c-row__a { opacity: 1; transform: none; }
.chat .c-row:focus-visible { outline: 2px solid #fff; outline-offset: -5px; }
@media (hover: none) { .c-row:hover:not(:focus-visible, [aria-pressed="true"]) { color: var(--c-ink); } .c-row:hover:not(:focus-visible, [aria-pressed="true"])::before { transform: scaleX(0); } .c-row:hover:not(:focus-visible, [aria-pressed="true"]) .c-row__n { color: var(--c-line); } }

/* Botones del chat */
.c-btn { position: relative; isolation: isolate; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 48px; padding: 0 18px; border: 1px solid var(--c-ink); border-radius: 2px; color: var(--c-ink); background: #fff; font: 700 11px/1.2 var(--c-body); letter-spacing: .16em; text-transform: uppercase; text-align: center; transition: color 200ms; }
.c-btn::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--c-ink); transform: scaleX(0); transform-origin: left; transition: transform 280ms cubic-bezier(.65, 0, .35, 1); }
.c-btn--full { width: 100%; }
.c-btn--dark { background: var(--c-ink); color: #fff; min-height: 46px; }
.c-btn--dark::before { background: #fff; }
@media (hover: hover) { .c-btn:not(:disabled):hover { color: #fff; } .c-btn:not(:disabled):hover::before { transform: none; } .c-btn--dark:not(:disabled):hover { color: var(--c-ink); } }
.c-btn:disabled { opacity: .45; cursor: default; }
.c-btn--dark:focus-visible { outline: 2px solid var(--c-ink); outline-offset: 2px; }
.c-textbtn { display: inline-flex; align-items: center; min-height: 44px; color: var(--c-text2); font: 400 14px/1.2 var(--c-body); text-decoration: underline; text-underline-offset: 4px; }
.c-foot { padding: 12px 16px 4px; border-top: 1px solid var(--c-line); }

/* ═══ 4 · Conversación ═══ */
.c-log { display: grid; gap: 16px; padding: 16px; align-content: start; }
.c-day { text-align: center; }
.c-day::before { content: "— "; } .c-day::after { content: " —"; }
.c-msg { max-width: 268px; animation: c-rise 220ms var(--c-ease) both; }
.c-msg--bot { padding-left: 16px; border-left: 2px solid var(--c-line); }
.c-msg--bot p { margin-top: 6px; color: var(--c-ink); font-size: 15px; font-weight: 300; line-height: 1.45; white-space: pre-line; }
.c-msg--bot b { font-weight: 700; background: linear-gradient(var(--c-line), var(--c-line)) 0 100% / 0 1px no-repeat; animation: c-emph 500ms 260ms var(--c-ease) both; }
@keyframes c-emph { from { opacity: .25 } to { opacity: 1; background-size: 100% 1px } }
.c-msg--user { justify-self: end; display: grid; justify-items: end; }
.c-msg--user p { margin-top: 6px; padding: 12px 14px; border-radius: 2px; background: var(--c-ink); color: #fff; font-size: 15px; font-weight: 300; line-height: 1.4; overflow-wrap: anywhere; }
.c-msg.is-old, .c-msg.is-old b { animation: none; }
.c-msg.is-old b { background-size: 100% 1px; }
.c-card { margin: 14px 0 0; border: 1px solid var(--c-line); border-radius: 3px; overflow: hidden; }
.c-msg--wide { max-width: none; }
.c-card__head { display: flex; align-items: center; gap: 12px; min-height: 38px; padding: 0 16px; border-bottom: 1px solid var(--c-line); }
.c-card__head::after { content: ""; flex: 1; height: 1px; background: var(--c-ink); }
.c-card .c-row { padding: 0 16px; }
.c-typing { display: flex; align-items: center; gap: 8px; }
.c-typing i { width: 4px; height: 4px; border-radius: 50%; background: var(--c-ink); animation: c-dot 1.2s infinite; }
.c-typing i:nth-of-type(2) { animation-delay: .2s } .c-typing i:nth-of-type(3) { animation-delay: .4s }
@keyframes c-dot { 0%, 60%, 100% { opacity: .2 } 30% { opacity: 1 } }
.c-quick { display: flex; gap: 8px; padding: 4px 16px 14px; overflow-x: auto; scrollbar-width: none; }
.c-quick .c-btn { flex: none; min-height: 44px; padding: 0 16px; font-size: 10px; }
.c-compose { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 18px; border-top: 1px solid var(--c-line); }
.c-compose input { flex: 1; min-width: 0; height: 48px; border: 0; background: none; color: var(--c-ink); font: 400 16px/1.2 var(--c-body); }
.c-compose input:focus-visible { outline: 0; }
.c-compose:focus-within { box-shadow: inset 0 2px 0 var(--c-ink); }
.c-compose input::placeholder { color: var(--c-label); opacity: 1; }
.c-compose button { flex: none; width: 48px; height: 48px; border-radius: 2px; background: var(--c-ink); color: #fff; display: grid; place-items: center; font-size: 18px; }
.c-compose button:disabled { opacity: .45; }

/* ═══ 5 · Presupuesto ═══ */
.c-step { display: flex; flex-direction: column; min-height: 100%; padding: 18px 20px 6px; }
.c-step__meta { display: flex; justify-content: space-between; }
.c-progress { position: relative; height: 3px; margin-top: 12px; background: linear-gradient(var(--c-line), var(--c-line)) 0 50% / 100% 1px no-repeat; }
.c-progress span { position: absolute; inset: 0; background: var(--c-ink); transform-origin: left; transform: scaleX(var(--to)); animation: c-prog 620ms cubic-bezier(.34, 1.3, .64, 1) both; }
@keyframes c-prog { from { transform: scaleX(var(--from)) } }
.c-step__n { display: flex; align-items: center; gap: 14px; margin-top: 18px; font: 700 34px/.8 var(--c-title); }
.c-step__n::after { content: ""; flex: 1; height: 1px; background: var(--c-ink); transform-origin: left; animation: c-rule 300ms var(--c-ease) both; }
.c-q { margin-top: 14px; font: 700 34px/.84 var(--c-title); letter-spacing: -.01em; text-wrap: balance; }
.c-q:focus { outline: none; }
.c-note { margin-top: 10px; color: var(--c-text2); font-size: 14px; line-height: 1.4; }
.c-chips { display: grid; gap: 10px; margin-top: 20px; }
.c-chip { justify-content: space-between; min-height: 52px; text-align: left; }
.c-chip[aria-pressed="true"] { background: var(--c-ink); color: #fff; }
.c-fields { display: grid; gap: 4px; margin-top: 12px; }
.c-fields label { display: grid; gap: 2px; font-size: 14px; font-weight: 700; }
.c-fields input:focus-visible { outline-offset: 0; }
.c-fields input { margin-top: 2px; height: 40px; padding: 0; border: 0; border-bottom: 1px solid var(--c-label); border-radius: 0; background: none; color: var(--c-ink); font: 400 16px/1.2 var(--c-body); }
.c-fields [aria-invalid="true"] { border-bottom: 2px solid var(--c-ink); }
.c-err { min-height: 18px; font-size: 13px; font-weight: 400; line-height: 18px; }
.c-step .c-index { margin: 14px -20px 0; border-block: 1px solid var(--c-line); }
.c-step__back { margin-top: auto; padding-top: 10px; }

/* ═══ 6 · Resumen y envío ═══ */
.c-sum { display: grid; gap: 14px; padding: 16px; }
.c-sheet { border: 1px solid var(--c-line); border-radius: 3px; overflow: hidden; }
.c-sheet__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 18px; padding: 16px 0 12px; border-bottom: 1px solid var(--c-ink); }
.c-sheet__brand { font: 400 16px/1.1 var(--c-body); white-space: nowrap; }
.c-sheet ul { list-style: none; margin: 0 18px 14px; padding: 0; }
.c-sheet li { display: grid; grid-template-columns: 92px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--c-line); font-size: 13px; line-height: 1.35; animation: c-rise 260ms var(--c-ease) both; animation-delay: calc(120ms + var(--n) * 110ms); }
.c-sheet li:last-child { border-bottom: 0; }
.c-sheet li span { color: var(--c-text2); } .c-sheet li span::before { content: "· "; color: var(--c-ink); font-weight: 700; }
.c-sheet li b { overflow-wrap: anywhere; }
.c-done { padding: 14px 18px 16px; color: #fff; animation: c-sweep 480ms 720ms cubic-bezier(.65, 0, .35, 1) both; }
@keyframes c-sweep { from { clip-path: inset(0 100% 0 0) } to { clip-path: inset(0) } }
.c-done .c-label { color: var(--c-label-dark); }
.c-done h3 { margin-top: 8px; font: 700 24px/.9 var(--c-title); letter-spacing: .02em; }
.c-done h3:focus { outline: none; }
.c-sheet__sign { padding: 12px 18px 14px; text-align: center; }
.c-sum__actions { display: grid; gap: 10px; }

/* ═══ 7 · Celular ═══ */
@media (max-width: 767px) {
  .chat-dock { right: 14px; bottom: 14px; gap: 10px; }
  .chat-launch { width: 68px; height: 68px; }
  .chat-launch__core { inset: 13px; font-size: 19px; }
  .chat { inset: 0; width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .chat__bar { padding-top: max(8px, env(safe-area-inset-top)); }
  .chat__title { font-size: 48px; }
  .c-row { min-height: 46px; font-size: 15px; }
  .c-msg--bot p, .c-msg--user p { font-size: 16px; }
  .c-btn { min-height: 48px; }
  .c-fields input { height: 46px; }
  .chat__avatar { min-height: 44px; }
  .c-compose, .c-foot { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .c-quick { padding-top: 10px; border-top: 1px solid var(--c-line); }
}
@media (min-width: 768px) and (max-height: 620px) { .chat { bottom: 24px; right: 124px; height: calc(100dvh - 48px); } }
@media print { .chat-dock, .chat { display: none !important; } }

/* ═══ 8 · Reducir movimiento: solo fundidos de 150 ms ═══ */
@media (prefers-reduced-motion: reduce) {
  .chat[open], .chat-hello, .c-msg:not(.is-old) { animation: c-fade 150ms linear both !important; }
  .chat__curtain { display: none; }
  .c-msg--bot b { background-size: 100% 1px; }
}
@keyframes c-fade { from { opacity: 0 } }
