/* Herramientas comunes: aviso de cookies, accesibilidad, ir arriba y chat (ver widgets.js) */
.wg { --wg-bg: #2a2b2e; --wg-bg2: #34363a; --wg-line: rgba(255, 255, 255, .14); --wg-text: #f2f2f2; --wg-muted: #b9bcc0; --wg-amber: #ffc107; --wg-ink: #222325; position: fixed; inset: 0; z-index: 2147482000; pointer-events: none; font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.4; }
.wg > * { pointer-events: auto; }
.wg [hidden] { display: none !important; }

/* ---------- Botones flotantes ---------- */
.wg-left, .wg-right { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 10px; justify-items: center; }
.wg-left { left: calc(18px + env(safe-area-inset-left)); }
.wg-right { right: calc(18px + env(safe-area-inset-right)); }
.wg-btn { position: relative; display: grid; place-items: center; width: 52px; height: 52px; padding: 0; border: 1px solid var(--wg-line); border-radius: 50%; background: var(--wg-bg); color: #fff; cursor: pointer; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); transition: transform .2s cubic-bezier(.2, .8, .2, 1), background-color .2s, border-color .2s, box-shadow .2s, opacity .25s; }
.wg-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wg-btn:hover { transform: translateY(-2px); border-color: #fff; }
.wg-btn:focus-visible, .wg-chip:focus-visible, .wg-ok:focus-visible, .wg-link:focus-visible, .wg-x:focus-visible, .wg-send:focus-visible, .wg-in:focus-visible, .wg-go:focus-visible, .wg-sw:focus-within { outline: 3px solid var(--wg-amber); outline-offset: 2px; }
.wg-chat-btn { width: 60px; height: 60px; background: var(--wg-amber); border-color: var(--wg-amber); color: var(--wg-ink); box-shadow: 0 10px 28px rgba(255, 193, 7, .35); }
.wg-chat-btn:hover { background: #ffd54f; border-color: #ffd54f; }
.wg-chat-btn svg { width: 28px; height: 28px; }
.wg-chat-btn[aria-expanded='true'] { transform: scale(.94); }
.wg-badge { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: #e6005c; border: 2px solid #fff; }
.wg-chat-btn.seen .wg-badge { display: none; }
.wg-chat-btn.nudge { animation: wg-nudge 1.2s ease-in-out 2; }
@keyframes wg-nudge { 0%, 100% { transform: none; } 30% { transform: translateY(-8px) rotate(-6deg); } 60% { transform: translateY(0) rotate(5deg); } }
.wg-up { opacity: 0; transform: translateY(10px) scale(.9); }
.wg-up.in { opacity: 1; transform: none; }
.wg-up.in:hover { transform: translateY(-2px); }
.wg-a11y-btn { background: #fff; color: #222325; border-color: #fff; }
.wg-a11y-btn:hover { background: #fff; border-color: var(--wg-amber); }

/* ---------- Paneles ---------- */
.wg-panel { position: fixed; bottom: calc(92px + env(safe-area-inset-bottom)); width: min(370px, calc(100vw - 24px)); max-height: min(560px, calc(100dvh - 130px)); display: flex; flex-direction: column; overflow: hidden; border-radius: 20px; border: 1px solid var(--wg-line); background: var(--wg-bg); color: var(--wg-text); box-shadow: 0 24px 70px rgba(0, 0, 0, .5); animation: wg-pop .28s cubic-bezier(.2, .8, .2, 1); }
.wg-chat { right: calc(18px + env(safe-area-inset-right)); height: 540px; }
.wg-a11y { left: calc(18px + env(safe-area-inset-left)); width: min(330px, calc(100vw - 24px)); }
@keyframes wg-pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.wg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--wg-line); font-size: 16px; }
.wg-head-chat { justify-content: flex-start; background: linear-gradient(135deg, #34363a, #222325); }
.wg-title { display: grid; flex: 1; line-height: 1.2; }
.wg-title small { color: var(--wg-muted); font-size: 12px; }
.wg-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--wg-amber); color: var(--wg-ink); font-weight: 800; font-size: 18px; }
.wg-x { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--wg-muted); cursor: pointer; }
.wg-x:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.wg-x svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* Chat */
.wg-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 16px; scroll-behavior: smooth; }
.wg-msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: 14.5px; animation: wg-in .3s cubic-bezier(.2, .8, .2, 1); }
.wg-msg p { margin: 0; }
.wg-msg.bot { align-self: flex-start; background: var(--wg-bg2); border-bottom-left-radius: 5px; }
.wg-msg.me { align-self: flex-end; background: var(--wg-amber); color: var(--wg-ink); font-weight: 700; border-bottom-right-radius: 5px; }
@keyframes wg-in { from { opacity: 0; transform: translateY(8px); } }
.wg-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.wg-go { display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px; background: #fff; color: var(--wg-ink); font-size: 13px; font-weight: 800; text-decoration: none; }
.wg-go:hover { background: var(--wg-amber); }
.wg-msg.typing { display: flex; gap: 5px; padding: 14px 16px; }
.wg-msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--wg-muted); animation: wg-dot 1s infinite ease-in-out; }
.wg-msg.typing i:nth-child(2) { animation-delay: .15s; } .wg-msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes wg-dot { 0%, 80%, 100% { transform: none; opacity: .4; } 40% { transform: translateY(-5px); opacity: 1; } }
.wg-chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 12px; scrollbar-width: none; flex: none; }
.wg-chips::-webkit-scrollbar { display: none; }
.wg-chip { flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--wg-line-strong, rgba(255, 255, 255, .28)); background: transparent; color: var(--wg-text); font-weight: 700; font-size: 13px; line-height: 1.2; font-family: inherit; cursor: pointer; white-space: nowrap; transition: background-color .15s, color .15s, border-color .15s; }
.wg-chip:hover { background: #fff; color: var(--wg-ink); border-color: #fff; }
.wg-form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--wg-line); background: rgba(0, 0, 0, .18); }
.wg-in { flex: 1; min-width: 0; min-height: 42px; padding: 9px 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(0, 0, 0, .3); color: #fff; font-weight: 400; font-size: 16px; font-family: inherit; }
.wg-in::placeholder { color: var(--wg-muted); }
.wg-in:focus { border-color: var(--wg-amber); outline-offset: 1px; }
.wg-send { display: grid; place-items: center; width: 42px; height: 42px; flex: none; padding: 0; border: 0; border-radius: 50%; background: var(--wg-amber); color: var(--wg-ink); cursor: pointer; transition: transform .15s; }
.wg-send:hover { transform: scale(1.08); }
.wg-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Accesibilidad */
.wg-size-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 14px 16px 6px; }
.wg-size { text-align: center; font-weight: 700; font-size: 14px; }
.wg-size-row .wg-chip { min-width: 52px; font-size: 16px; text-align: center; }
.wg-sw { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; cursor: pointer; border-top: 1px solid rgba(255, 255, 255, .06); }
.wg-sw b { display: block; font-size: 14.5px; }
.wg-sw small { display: block; color: var(--wg-muted); font-size: 12px; }
.wg-sw input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.wg-sw i { position: relative; flex: none; width: 44px; height: 26px; border-radius: 99px; background: rgba(255, 255, 255, .2); transition: background-color .2s; }
.wg-sw i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
.wg-sw input:checked + i { background: var(--wg-amber); }
.wg-sw input:checked + i::after { transform: translateX(18px); background: var(--wg-ink); }
.wg-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 12px 16px 14px; border-top: 1px solid var(--wg-line); }
.wg-link { padding: 4px 0; border: 0; background: none; color: var(--wg-amber); font-weight: 700; font-size: 13px; font-family: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.wg-link:hover { color: #fff; }

/* ---------- Aviso de cookies ---------- */
.wg-cookies { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 5; width: min(620px, calc(100vw - 150px)); display: flex; align-items: center; gap: 16px; padding: 14px 16px 14px 20px; border-radius: 16px; border: 1px solid var(--wg-line); background: rgba(34, 35, 37, .96); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); color: var(--wg-text); box-shadow: 0 18px 50px rgba(0, 0, 0, .45); transform: translate(-50%, 24px); opacity: 0; transition: transform .45s cubic-bezier(.2, .8, .2, 1), opacity .45s; }
.wg-cookies.in { transform: translate(-50%, 0); opacity: 1; }
.wg-cookies.out { transform: translate(-50%, 24px); opacity: 0; }
.wg-cookies p { margin: 0; flex: 1; font-size: 13.5px; line-height: 1.4; color: #d7d9dc; }
.wg-cookies p strong { color: #fff; }
.wg-cookies a { color: var(--wg-amber); font-weight: 700; }
.wg-cookie-actions { display: flex; align-items: center; gap: 14px; flex: none; }
.wg-ok { min-height: 40px; padding: 8px 20px; border: 0; border-radius: 999px; background: var(--wg-amber); color: var(--wg-ink); font-weight: 800; font-size: 14px; font-family: inherit; cursor: pointer; transition: background-color .15s, transform .15s; }
.wg-ok:hover { background: #ffd54f; transform: translateY(-1px); }

/* ---------- Saltar al contenido ---------- */
.skip-link { position: fixed; left: 12px; top: -80px; z-index: 2147483001; padding: 12px 18px; border-radius: 12px; background: #FFC107; color: #222325; font: 800 15px 'Nunito', system-ui, sans-serif; text-decoration: none; transition: top .2s; }
.skip-link:focus { top: 12px; }

/* ---------- Teléfono ---------- */
@media (max-width: 700px) {
  .wg-left, .wg-right { bottom: calc(14px + env(safe-area-inset-bottom)); }
  .wg-left { left: calc(12px + env(safe-area-inset-left)); } .wg-right { right: calc(12px + env(safe-area-inset-right)); }
  .wg-btn { width: 46px; height: 46px; } .wg-chat-btn { width: 54px; height: 54px; }
  .wg-panel { left: 12px; right: 12px; width: auto; bottom: calc(82px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 110px); }
  .wg-chat { height: min(520px, calc(100dvh - 110px)); }
  .wg-cookies { width: calc(100vw - 24px); bottom: calc(76px + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; gap: 10px; }
  .wg-cookie-actions { justify-content: space-between; }
  /* el panel del comercio tiene barra inferior: los botones se suben para no taparla */
  body:has(.tabbar) .wg-left, body:has(.tabbar) .wg-right { bottom: calc(100px + env(safe-area-inset-bottom)); }
  body:has(.tabbar) .wg-panel { bottom: calc(168px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 190px); }
  body:has(.tabbar) .wg-cookies { bottom: calc(100px + env(safe-area-inset-bottom)); }
}

/* ---------- Preferencias de accesibilidad ---------- */
html.a11y-t-1 { font-size: 87.5%; }
html.a11y-t1 { font-size: 112.5%; }
html.a11y-t2 { font-size: 125%; }
html.a11y-t3 { font-size: 150%; }
/* el panel usa píxeles: el tamaño se aplica con zoom del cuerpo */
html.a11y-zoomable.a11y-t-1 body { zoom: .92; }
html.a11y-zoomable.a11y-t1 body { zoom: 1.1; }
html.a11y-zoomable.a11y-t2 body { zoom: 1.22; }
html.a11y-zoomable.a11y-t3 body { zoom: 1.4; }
html.a11y-links a:not(.wg-go):not(.cbtn):not(.btn):not(.skip-link) { text-decoration: underline !important; text-underline-offset: 3px; text-decoration-thickness: 2px; }
html.a11y-font body, html.a11y-font body *:not(svg):not(svg *) { font-family: Verdana, Arial, 'Helvetica Neue', sans-serif !important; letter-spacing: normal !important; }
html.a11y-spacing body p, html.a11y-spacing body li, html.a11y-spacing body dd, html.a11y-spacing body summary, html.a11y-spacing body td { line-height: 1.8 !important; word-spacing: .12em; }
html.a11y-calm *, html.a11y-calm *::before, html.a11y-calm *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
html.a11y-calm .cur, html.a11y-calm .l-year, html.a11y-calm .rt-halo { animation: none !important; }
html.a11y-contrast { --bg: #000; --surface: #111; --surface-2: #1b1b1b; --surface-3: #262626; --text: #fff; --muted: #fff; --line: rgba(255, 255, 255, .55); --line-strong: #fff; --gold-text: #ffe066; }
html.a11y-contrast body { filter: none; }
html.a11y-contrast:not(.a11y-zoomable) { filter: contrast(1.28) saturate(1.1); }
html.a11y-contrast .muted, html.a11y-contrast .small { color: #fff; }
html.a11y-contrast .wg { --wg-line: rgba(255, 255, 255, .7); --wg-muted: #fff; --wg-bg: #000; --wg-bg2: #1b1b1b; }
html.a11y-contrast input, html.a11y-contrast select, html.a11y-contrast textarea { border-color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .wg-panel, .wg-msg, .wg-chat-btn.nudge, .wg-msg.typing i { animation: none !important; }
  .wg-cookies { transition: none; }
}
@media print { .wg, .skip-link { display: none !important; } }

/* Fuera de la portada, el panel de accesibilidad se abre sobre la columna derecha */
.wg-a11y.on-right { left: auto; right: calc(18px + env(safe-area-inset-right)); }
@media (max-width: 700px) { .wg-a11y.on-right { left: 12px; right: 12px; } }
