/* =============================================================
   /sistema/ayuda/ — Wrapper unificado de 5 tabs
   Mismo estilo que estilos.css (legacy ayuda): Outfit + pink + cards.
   Mobile-first, sin dark mode (todas las tabs SIEMPRE en claro).
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --primary:        #ec4899;
  --primary-dark:   #db2777;
  --primary-light:  #fce7f3;
  --primary-muted:  rgba(236, 72, 153, 0.1);
  --blue:           #0284c7;
  --blue-light:     #e0f2fe;
  --bg-body:        #f8fafc;
  --bg-card:        #ffffff;
  --text-main:      #0f172a;
  --text-muted:     #64748b;
  --text-light:     #94a3b8;
  --border:         #e2e8f0;
  --border-soft:    #eef2f6;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 14px rgba(0,0,0,0.08);
  --shadow-lg:      0 10px 28px rgba(0,0,0,0.09);
  --radius:         12px;
  --radius-lg:      16px;
  --radius-pill:    999px;

  --tap: 44px;
  --gap: clamp(12px, 2vw, 20px);

  --header-h: 56px;
  --bottom-nav-h: 64px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-body);
  color: var(--text-main);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { color: var(--primary-dark); }

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* =============================================================
   SHELL — header + main + bottom nav
   ============================================================= */

.ayuda-shell {
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* ----- HEADER ----- */

.ayuda-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.ayuda-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--gap);
}

.ayuda-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.95rem;
  letter-spacing: -.01em;
}
.ayuda-header__brand:hover { text-decoration: none; color: var(--text-main); }

.ayuda-header__brand .logo-dot {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--primary-muted);
  color: var(--primary);
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px;
}

.ayuda-header__home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
}
.ayuda-header__home:hover {
  background: var(--bg-body);
  text-decoration: none;
  color: var(--text-main);
}

/* ----- TABS (desktop top-nav) ----- */

.ayuda-tabs {
  display: none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--gap);
  gap: 4px;
  border-top: 1px solid var(--border-soft);
}

.ayuda-tabs__btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
  border-radius: 0;
}
.ayuda-tabs__btn:hover {
  color: var(--text-main);
  text-decoration: none;
}
.ayuda-tabs__btn[aria-current="page"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.ayuda-tabs__btn .ayuda-tabs__emoji {
  font-size: 1rem;
  line-height: 1;
}

/* ----- MAIN ----- */

.aw-main {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: var(--gap);
}

/* 2026-05-30 — Responsive compacto en mobile para la tab Mensajes.
   Antes los campos quedaban muy separados y el textarea muy alto, requería
   scroll exagerado. Esto solo aplica al form de mensajes (no afecta el
   centro de ayuda). */
body.aw-tab-mensajes .gvl-msg-regresar:hover {
  background: var(--bg-body);
  color: var(--text-main);
}
@media (max-width: 767px) {
  body.aw-tab-mensajes .card { padding: 16px; }
  body.aw-tab-mensajes .card__title { font-size: 1.25rem; margin-bottom: 6px; }
  body.aw-tab-mensajes .card__sub { font-size: 0.9rem; margin-bottom: 12px; }
  body.aw-tab-mensajes .field + .field { margin-top: 10px; }
  body.aw-tab-mensajes .textarea { min-height: 100px; }
  body.aw-tab-mensajes .input, body.aw-tab-mensajes .textarea {
    font-size: 16px; /* >= 16px evita zoom-in auto del iOS Safari al hacer focus */
  }
}

/* Espacio para el bottom-nav fijo en móvil — aplica a body (cubre tabs nuevas
   y la tab Ayuda original que no usa .aw-main). */
@media (max-width: 767px) {
  body {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  }
}

/* ----- BOTTOM NAV (mobile) ----- */

.ayuda-bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 110;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 10px rgba(15, 23, 42, .04);
}

.ayuda-bottom-nav__inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.ayuda-bottom-nav__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--bottom-nav-h);
  padding: 6px 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
}
.ayuda-bottom-nav__btn:hover,
.ayuda-bottom-nav__btn:focus { color: var(--text-main); text-decoration: none; }
.ayuda-bottom-nav__btn[aria-current="page"] { color: var(--primary); }
.ayuda-bottom-nav__btn .icon { font-size: 1.2rem; line-height: 1; }
.ayuda-bottom-nav__btn .label { font-size: 0.7rem; letter-spacing: -.01em; }

/* ----- BREAKPOINTS ----- */

@media (min-width: 768px) {
  .ayuda-tabs { display: flex; flex-wrap: wrap; }
  .ayuda-bottom-nav { display: none; }
  :root { --header-h: 60px; }
}

/* =============================================================
   CARDS / SURFACES
   ============================================================= */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(18px, 3vw, 32px);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--gap); }

.card__title {
  margin: 0 0 8px;
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  letter-spacing: -.02em;
  font-weight: 700;
  color: var(--text-main);
}
.card__sub {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* =============================================================
   BOTONES, INPUTS, BADGES
   ============================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .1s, color .2s;
  text-decoration: none;
}
.btn:hover { background: var(--bg-body); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn--primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}
.btn--ghost { background: transparent; border-color: transparent; }
.btn--block { width: 100%; }

.input, .textarea, .select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.textarea { min-height: 120px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(236, 72, 153, .12);
}

.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.field + .field { margin-top: 14px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--primary-muted);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 600;
}

/* =============================================================
   CHAT (consulta + comprar)
   ============================================================= */

.chat {
  display: flex;
  flex-direction: column;
  height: clamp(520px, 70dvh, 760px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* ─── TABS CONSULTA + COMPRAR: chat full-height (mobile + PC) ──────────
   v26 (2026-05-29) — antes el chat ocupaba MÁXIMO 760px en PC. Ahora
   ocupa toda la altura disponible del viewport, con el "Escribí un
   mensaje" + botón enviar PEGADOS abajo. El cliente no tiene que
   scrollear el navegador para llegar al input.

   Mobile: header oculto, chat = 100dvh menos bottom-nav.
   PC:     header visible, chat = 100dvh menos header menos padding.
   Ambos:  100dvh se ajusta al keyboard de iOS automáticamente.
*/

.chat__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-card);
}
.chat__avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary-muted);
  color: var(--primary);
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
}
.chat__head-info { display: flex; flex-direction: column; }
.chat__head-name { font-weight: 700; font-size: 0.95rem; color: var(--text-main); }
.chat__head-status {
  font-size: 0.78rem; color: #16a34a;
  display: inline-flex; align-items: center; gap: 5px;
}
.chat__head-status::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #16a34a;
}

.chat__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-body);
  /* 2026-05-29 — Anclar mensajes al FONDO del body (como WhatsApp).
     Con 1 solo mensaje, queda pegado abajo del body (justo arriba del input).
     Con muchos mensajes, el margin-top:auto se calcula 0 y scroll normal.
     Esto evita el problema mobile: cuando hay pocos mensajes, el saludo
     queda flotando arriba con espacio vacío debajo → al abrir teclado, ese
     espacio vacío se achica pero el saludo quedaba en posición rara. */
  justify-content: flex-end;
}
.chat__body > :first-child {
  margin-top: auto; /* empuja TODOS los mensajes hacia el fondo */
}

.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* 2026-05-30 — Paleta en escala de grises (a pedido del admin).
   Admin (izquierda): gris claro suave.
   Cliente (derecha): gris un poco más oscuro para diferenciarlo.
   Ambos con texto oscuro para máxima legibilidad. */
.msg--bot {
  align-self: flex-start;
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  border-bottom-left-radius: 4px;
}
.msg--user {
  align-self: flex-end;
  background: #cbd5e1;
  color: #1e293b;
  border: 1px solid #94a3b8;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  border-bottom-right-radius: 4px;
}
.msg--system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 4px 8px;
}

/* Links dentro de los globos — color rosa primary para destacar sobre el gris. */
.msg--bot a,
.msg--user a {
  color: #db2777;
  text-decoration: underline;
  font-weight: 500;
}
.msg--bot a:hover,
.msg--user a:hover { color: #ec4899; }

/* Strong / bold dentro de los globos. */
.msg--bot strong,
.msg--user strong { color: #0f172a; font-weight: 700; }

/* Cuando una burbuja contiene HTML del admin (cuerpo_html con <p>, <br>, etc.)
   el pre-wrap del padre conserva los espacios/saltos de la indentación PHP y
   los <p> traen márgenes por default → burbuja con huecos enormes. Este
   wrapper anula ambos comportamientos para el HTML rico. */
.msg__body {
  white-space: normal;
}
.msg__body > *:first-child { margin-top: 0 !important; }
.msg__body > *:last-child { margin-bottom: 0 !important; }
.msg__body p { margin: 0 0 8px; }
.msg__body p:empty { display: none; }
.msg__body p:last-child { margin-bottom: 0; }
.msg__body ul, .msg__body ol { margin: 4px 0 8px; padding-left: 20px; }
.msg__body br + br { display: none; }
.msg__body img { max-width: 100%; height: auto; border-radius: 8px; margin: 4px 0; }
.msg__body div { margin: 0; }
.msg__body h1, .msg__body h2, .msg__body h3, .msg__body h4 {
  margin: 8px 0 4px; font-size: 1rem; font-weight: 700;
}

.msg__action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
}
.msg__action:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }

.chat__typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
}
.chat__typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: chat-typing 1.2s infinite ease-in-out;
}
.chat__typing span:nth-child(2) { animation-delay: .15s; }
.chat__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-typing {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.chat__foot {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-card);
}
.chat__foot textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  background: var(--bg-body);
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
  resize: none;
}
.chat__foot textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-card);
}
.chat__send {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 18px;
  transition: background .15s, transform .1s;
}
.chat__send:hover { background: var(--primary-dark); }
.chat__send:active { transform: scale(0.95); }
.chat__send[disabled] { background: var(--text-light); cursor: not-allowed; }

/* honeypot (oculto pero accesible para bots) */
.hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
  height: 0;
  width: 0;
}

/* ─── reCAPTCHA badge: oculto en todo /sistema/ayuda/ v26 ─────────────
   El logo de Google reCAPTCHA flota abajo-derecha y queda encima del
   bottom-nav móvil + se ve invasivo en general. Google permite ocultarlo
   SIEMPRE QUE se muestre un disclaimer legal en su lugar. Lo agregamos
   en .chat__legal (debajo del input de cada chat). */
.grecaptcha-badge {
  visibility: hidden !important;
}
.chat__legal {
  padding: 6px 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-card);
  line-height: 1.3;
}
.chat__legal a {
  color: var(--text-muted);
  text-decoration: underline;
}
.chat__legal a:hover { color: var(--primary); }

/* =============================================================
   HERO / INICIO (mismo estilo que .ayuda-hero del legacy)
   ============================================================= */

.hero {
  background: linear-gradient(135deg, #ffffff 0%, #fdf2f8 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(28px, 5vw, 52px);
  text-align: center;
  margin-bottom: var(--gap);
}
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -.5px;
}
.hero p {
  margin: 0;
  color: var(--text-muted);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
}

.tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}
@media (min-width: 540px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-main);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  min-height: 150px;
  box-shadow: var(--shadow-sm);
}
.tile:hover {
  text-decoration: none;
  color: var(--text-main);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}
.tile__icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--primary-muted);
  color: var(--primary);
  display: grid; place-items: center;
  font-size: 1.4rem;
}
.tile__title { font-weight: 700; font-size: 1.05rem; color: var(--text-main); }
.tile__sub { font-size: 0.88rem; color: var(--text-muted); }

/* =============================================================
   ALERTS / HELPERS
   ============================================================= */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert--ok   { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert--err  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert--info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; } .gap { gap: var(--gap); } .gap-sm { gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: var(--gap); }
.row > * { flex: 1 1 220px; }
