/* =========================================================
   Club Fortuna · Landing V2 — piel del chat de soporte.
   Sólo presentación: widget.js, sus IDs, vistas y la semántica de los mensajes no cambian
   (los automáticos financieros siguen saliendo como burbuja de agente, cf-msg-agent).
   Se carga DESPUÉS de widget.css y gana por orden / especificidad de #cf-widget-root.
   Teléfono (< 600): pantalla completa que sigue al teclado (--vvh/--vvt los fija app.js con visualViewport).
   Tablet (600–1099): panel lateral derecho de alto completo. Escritorio: panel flotante sobre la píldora.
   ========================================================= */
#cf-widget-root {
  --cf-void: #08101c;
  --cf-panel: #0f1828;
  --cf-panel-alt: #16223a;
  --cf-body: #0b1422;
  --cf-header: #0f1828;
  --cf-line: rgba(160, 185, 230, .12);
  --cf-line-strong: rgba(160, 185, 230, .2);
  --cf-gold: #e9b949;
  --cf-gold-bright: #f4cf6e;
  --cf-ink: #f2eee4;
  --cf-ink-soft: #a9b3c6;
  --cf-ink-faint: #8792a8;
  font-family: var(--ui);
}
#cf-widget-root button:focus-visible, #cf-widget-root input:focus-visible, #cf-widget-root textarea:focus-visible { outline: 2px solid var(--cf-gold-bright); outline-offset: 2px; }

/* ---------- píldora (sólo escritorio; en teléfono y tablet el acceso es "Soporte" en la barra inferior) ---------- */
#cf-widget-root .cf-bubble {
  height: 48px; gap: 8px; padding: 0 16px 0 6px;
  border: 1px solid var(--cf-line-strong); border-radius: 999px;
  color: var(--cf-ink); background: var(--cf-panel);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .4);
  transition: background-color .15s ease, border-color .15s ease;
}
#cf-widget-root .cf-bubble:hover { transform: none; background: var(--cf-panel-alt); border-color: rgba(233, 185, 73, .5); box-shadow: 0 10px 28px rgba(0, 0, 0, .4); }
#cf-widget-root .cf-bubble-icon { width: 36px; height: 36px; flex-basis: 36px; color: var(--cf-gold-ink, #1b1405); background: var(--cf-gold); }
#cf-widget-root .cf-bubble-icon .cf-icon { width: 20px; height: 20px; color: #1b1405; }
#cf-widget-root .cf-bubble-label { font-size: 14px; font-weight: 600; }
#cf-widget-root .cf-bubble-chevron { display: none; }

/* ---------- panel ---------- */
#cf-widget-root .cf-panel {
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--cf-line-strong); border-radius: 18px;
  background: var(--cf-body);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .55);
  animation: none;
}
#cf-widget-root .cf-panel.hidden { display: none; }
#cf-widget-root .cf-panel-header {
  flex: 0 0 auto; min-height: 60px; padding: 8px 8px 8px 14px; gap: 10px;
  border-bottom: 1px solid var(--cf-line); background: var(--cf-header);
}
#cf-widget-root .cf-header-logo { width: 36px; height: 36px; flex-basis: 36px; border: 0; background: transparent; }
#cf-widget-root .cf-header-logo img { border-radius: 50%; }
#cf-widget-root .cf-panel-title { font-size: 15px; font-weight: 700; }
#cf-widget-root .cf-panel-status { margin-top: 1px; color: var(--cf-ink-soft); font-size: 12.5px; }
#cf-widget-root .cf-online-dot { background: #6fd39b; box-shadow: none; }
#cf-widget-root .cf-close-btn { width: 44px; height: 44px; flex-basis: 44px; border: 0; border-radius: 10px; color: var(--cf-ink-soft); background: transparent; }
#cf-widget-root .cf-close-btn:hover { color: var(--cf-ink); background: var(--cf-panel-alt); }
#cf-widget-root .cf-panel-body { padding: 14px 14px 12px; background: var(--cf-body); }

/* ---------- bienvenida / login dentro del widget ---------- */
#cf-widget-root .cf-welcome h3 { font: 700 26px/1.1 "Barlow SC", system-ui, sans-serif; letter-spacing: 0; }
#cf-widget-root .cf-welcome p { font-size: 15px; line-height: 1.5; }
#cf-widget-root .cf-welcome-emblem { width: 64px; height: 64px; border: 0; background: transparent; box-shadow: none; }
#cf-widget-root .cf-btn { min-height: 48px; border-radius: 10px; font-size: 15px; font-weight: 600; }
#cf-widget-root .cf-btn:hover { transform: none; }
#cf-widget-root .cf-btn-gold { color: #1b1405; background: var(--cf-gold); box-shadow: none; }
#cf-widget-root .cf-btn-gold:hover { background: var(--cf-gold-bright); }
#cf-widget-root .cf-btn-outline { color: var(--cf-ink); background: var(--cf-panel-alt); border-color: var(--cf-line); }
#cf-widget-root .cf-btn-link { min-height: 40px; color: var(--cf-ink-soft); font-size: 14px; }
#cf-widget-root .cf-back-link { margin-bottom: 6px; text-decoration: none; }
#cf-widget-root .cf-inline-form label { font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--cf-ink); }
#cf-widget-root .cf-inline-form input { min-height: 50px; border-radius: 10px; background: var(--cf-void); font-size: 16px; }
#cf-widget-root .cf-form-error { font-size: 13.5px !important; color: #ff8a80 !important; }
#cf-widget-root .cf-user-card { border-radius: 10px; background: var(--cf-void); }

/* ---------- conversación ---------- */
#cf-widget-root .cf-chat-messages { gap: 6px; padding: 4px 2px 10px; overscroll-behavior: contain; scroll-padding-bottom: 12px; }
#cf-widget-root .cf-msg { max-width: 82%; padding: 9px 12px; border-radius: 16px; font-size: 15px; line-height: 1.45; box-shadow: none; }
#cf-widget-root .cf-msg-agent { border: 0; border-bottom-left-radius: 6px; border-top-left-radius: 16px; color: var(--cf-ink); background: var(--cf-panel-alt); }
#cf-widget-root .cf-msg-user { border: 0; border-bottom-right-radius: 6px; border-top-right-radius: 16px; color: #1b1405; background: var(--cf-gold); }
#cf-widget-root .cf-msg-user a { color: #1b1405; }
#cf-widget-root .cf-msg-system { max-width: 92%; padding: 4px 8px; color: var(--cf-ink-faint); background: transparent; font-size: 12.5px; }
#cf-widget-root .cf-day-divider { margin: 10px 0 4px; padding: 2px 10px; border-radius: 999px; background: var(--cf-panel); color: var(--cf-ink-soft); font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
#cf-widget-root .cf-agent-typing { border: 0; background: var(--cf-panel-alt); }
#cf-widget-root .cf-chat-empty p { font-size: 14.5px; color: var(--cf-ink-soft); }
#cf-widget-root .cf-chat-input-row { gap: 6px; padding-top: 10px; border-top: 1px solid var(--cf-line); background: var(--cf-body); }
#cf-widget-root .cf-chat-input-row textarea {
  min-height: 46px; max-height: 120px; padding: 12px 14px; resize: none;
  border: 1px solid var(--cf-line-strong); border-radius: 23px; background: var(--cf-void);
  font-size: 16px; line-height: 1.35;
}
#cf-widget-root .cf-chat-input-row textarea:focus { border-color: var(--cf-gold); box-shadow: none; }
#cf-widget-root .cf-chat-input-row > button { width: 46px; min-width: 46px; height: 46px; border: 0; border-radius: 50%; color: var(--cf-ink-soft); background: var(--cf-panel-alt); box-shadow: none; }
#cf-widget-root .cf-chat-input-row > button[type="submit"] { color: #1b1405; background: var(--cf-gold); box-shadow: none; }
#cf-widget-root .cf-chat-input-row > button .cf-icon { width: 20px; height: 20px; }

/* ---------- teléfono: panel superpuesto del 80 % del alto visible, anclado abajo; se ve la página detrás ---------- */
@media (max-width: 599px) {
  #cf-widget-root .cf-panel {
    position: fixed; left: 0; right: 0; bottom: auto;
    top: calc(var(--vvt, 0px) + var(--vvh, 100dvh) * .2);
    width: 100%; height: calc(var(--vvh, 100dvh) * .8); max-height: none;
    border: 0; border-top: 1px solid var(--cf-line-strong); border-radius: 20px 20px 0 0;
    box-shadow: 0 -16px 48px rgba(0, 0, 0, .5);
  }
  /* asa visual: indica que es una hoja superpuesta */
  #cf-widget-root .cf-panel::before { content: ""; position: absolute; z-index: 1; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: rgba(242, 238, 228, .28); }
  #cf-widget-root .cf-panel-header { padding-top: 14px; border-radius: 20px 20px 0 0; }
  #cf-widget-root .cf-panel-body { padding: 12px 12px max(10px, env(safe-area-inset-bottom)); }
  body.cf-chat-keyboard #cf-widget-root .cf-panel-body { padding-bottom: 8px; }
}
/* ---------- tablet: panel flotante abajo a la derecha, 80 % del alto ---------- */
@media (min-width: 600px) and (max-width: 1099px) {
  #cf-widget-root .cf-panel {
    position: fixed; top: auto; left: auto; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
    width: 400px; height: calc(var(--vvh, 100dvh) * .8); max-height: none;
    border-radius: 18px;
  }
}
/* ---------- teléfono y tablet: globo flotante clásico sobre la barra inferior ---------- */
@media (max-width: 1099px) {
  #cf-widget-root { right: max(12px, env(safe-area-inset-right)); bottom: calc(var(--tabbar-h, 60px) + env(safe-area-inset-bottom) + 12px); }
  #cf-widget-root .cf-bubble { width: 56px; height: 56px; padding: 0; justify-content: center; border: 0; border-radius: 50%; background: var(--cf-gold); box-shadow: 0 10px 26px rgba(0, 0, 0, .45); }
  #cf-widget-root .cf-bubble:hover { background: var(--cf-gold-bright); }
  #cf-widget-root .cf-bubble-icon { width: 56px; height: 56px; flex-basis: 56px; background: transparent; }
  #cf-widget-root .cf-bubble-icon .cf-icon { width: 26px; height: 26px; color: #1b1405; }
  #cf-widget-root .cf-bubble-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* con el chat abierto el globo no asoma junto al panel: se cierra con la X o tocando el velo */
  body.cf-chat-open #cf-widget-root .cf-bubble { visibility: hidden; }
}
/* ---------- escritorio ---------- */
@media (min-width: 1100px) {
  #cf-widget-root { right: 24px; bottom: 24px; }
  #cf-widget-root .cf-panel { position: absolute; right: 0; bottom: 60px; width: 392px; height: min(620px, calc(100dvh - 120px)); }
}
/* con el chat abierto la página no se desplaza por detrás (teléfono/tablet) */
@media (max-width: 1099px) { body.cf-chat-open { overflow: hidden; } body.cf-chat-open .tabbar { visibility: hidden; } }
