/* Movistar Arena — Chatbot (Fase 1)
   - Mobile-first
   - Bottom-sheet móvil / Drawer desktop
   - Accesible (focus visible, reduced motion)
*/

/* =========================
   Tokens
   ========================= */
:root{
  --ma-cb-z: 9990;
  --ma-cb-panel: rgba(15, 22, 44, 0.96);
  --ma-cb-text: #eaf0ff;
  --ma-cb-muted: rgba(234,240,255,.72);
  --ma-cb-border: rgba(255,255,255,.12);
  --ma-cb-accent: #0B5CFF;

  /* Chat body (tuyo: blanco) */
  --ma-cb-body-bg: #fff;

  /* Mensajes */
  --ma-cb-user-color: #6b7280; /* gris 14px */
  --ma-cb-assistant-color: var(--ma-cb-accent); /* azul 18px */

  /* UI */
  --ma-cb-shadow: 0 18px 42px rgba(0,0,0,.35);
  --ma-cb-radius: 16px;
  --ma-cb-gap: 12px;
  --ma-cb-fab: 52px;

  --ma-cb-font: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

/* =========================
   Utilities
   ========================= */
.sr-only{
  position:absolute !important;
  width:1px; height:1px;
  padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0);
  white-space:nowrap; border:0;
}

.ma-chatbot{ font-family: var(--ma-cb-font); }

/* =========================
   FAB
   ========================= */
.ma-chatbot__fabstack{
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: var(--ma-cb-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--ma-cb-gap);
}

.ma-chatbot__fab{
  width: var(--ma-cb-fab);
  height: var(--ma-cb-fab);
  border-radius: 999px;
  border: 0;
  background: var(--ma-cb-accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ma-chatbot__fab:focus-visible{
  outline: 3px solid rgba(255,255,255,.65);
  outline-offset: 3px;
}

.ma-chatbot__fabIcon{
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
}

/* =========================
   Overlay general (oscurece página)
   ========================= */
.ma-chatbot__overlay{
  position: fixed;
  inset: 0;
  z-index: calc(var(--ma-cb-z) - 1);
  background: rgba(0,0,0,.38);
  backdrop-filter: blur(2px);
}

/* =========================
   Panel
   ========================= */
.ma-chatbot__panel{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--ma-cb-z);
  background: var(--ma-cb-panel);
  color: var(--ma-cb-text);
  border-top: 1px solid var(--ma-cb-border);
  border-radius: var(--ma-cb-radius) var(--ma-cb-radius) 0 0;
  box-shadow: var(--ma-cb-shadow);
  max-height: 86vh;

  display: grid;
  grid-template-rows: auto 1fr auto;

  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.ma-chatbot__panel[data-open="1"]{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (min-width: 980px){
  .ma-chatbot__panel{
    right: 16px;
    left: auto;
    width: 390px;
    bottom: 16px;
    border-radius: var(--ma-cb-radius);
    border: 1px solid var(--ma-cb-border);
    max-height: min(78vh, 640px);
  }
}

/* =========================
   Header
   ========================= */
.ma-chatbot__header{
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--ma-cb-border);
}

.ma-chatbot__title{
  margin: 0;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: .2px;
}

.ma-chatbot__subtitle{
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ma-cb-muted);
}

.ma-chatbot__iconBtn{
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--ma-cb-border);
  background: rgba(255,255,255,.06);
  color: var(--ma-cb-text);
  cursor: pointer;
}

.ma-chatbot__iconBtn:disabled{
  opacity: .45;
  cursor: default;
}

.ma-chatbot__iconBtn:focus-visible{
  outline: 3px solid rgba(255,255,255,.65);
  outline-offset: 2px;
}

/* =========================
   Body / Messages
   ========================= */
.ma-chatbot__body{
  position: relative; /* necesario para overlay “pensando” */
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr;
  background: var(--ma-cb-body-bg);
	border-radius: 16px;
}

.ma-chatbot__messages{
  padding: 12px;
  overflow: auto;
  scroll-behavior: smooth;
}

.ma-chatbot__msg{
  display: grid;
  gap: 6px;
  margin: 10px 0;
}

.ma-chatbot__bubble{
  max-width: 92%;
  line-height: 1.35;
}

/* Asistente (azul 18px) */
.ma-chatbot__msg--assistant .ma-chatbot__bubble{
  color: var(--ma-ink);
  font-size: var(--fs-element-badge);
  font-weight: var(--fw-element-badge);
}

.ma-chatbot__msg--assistant .ma-chatbot__bubble p{
  margin: 0 0 .7em;
}

.ma-chatbot__msg--assistant .ma-chatbot__bubble ul,
.ma-chatbot__msg--assistant .ma-chatbot__bubble ol{
  margin: .3em 0 .75em;
  padding-left: 1.35em;
}

.ma-chatbot__msg--assistant .ma-chatbot__bubble li{
  padding-left: .1em;
}

.ma-chatbot__msg--assistant .ma-chatbot__bubble li + li{
  margin-top: .35em;
}

.ma-chatbot__msg--assistant .ma-chatbot__bubble > :last-child{
  margin-bottom: 0;
}

.ma-chatbot__msg--assistant .ma-chatbot__bubble strong{
  font-weight: 800;
}

.ma-chatbot__msg--assistant .ma-chatbot__inlineLink{
  color: var(--ma-blue, #086ef7);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: .08em;
  text-underline-offset: .14em;
}

.ma-chatbot__msg--assistant .ma-chatbot__inlineLink:hover{
  text-decoration-thickness: .13em;
}

.ma-chatbot__msg--assistant .ma-chatbot__inlineLink:focus-visible{
  border-radius: 3px;
  outline: 3px solid rgba(var(--ma-blue-rgb), .3);
  outline-offset: 3px;
}

/* Usuario (gris 14px) */
.ma-chatbot__msg--user{
  justify-items: end;
}

.ma-chatbot__msg--user .ma-chatbot__bubble{
  color: var(--ma-cb-user-color);
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}

/* =========================
   Choices
   ========================= */
.ma-chatbot__choices{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.ma-chatbot__choice{
  border: 1px solid rgba(var(--ma-green-rgb), 0.5);
  background: rgba(var(--ma-green-rgb), 1) !important;
  color: rgba(var(--ma-ink-rgb), 1) !important;
  border-radius: 16px;
  padding: 10px 15px;
  font-size: 16px;
  cursor: pointer;
}

.ma-chatbot__choice:hover{
  border-color: rgba(255,255,255,.22);
}

.ma-chatbot__choice:focus-visible{
  outline: 3px solid rgba(255,255,255,.65);
  outline-offset: 2px;
}

.ma-chatbot__choices.is-used{ opacity: .55; }
.ma-chatbot__choice:disabled{ opacity: .55; cursor: default; }

/* =========================
   Footer
   ========================= */
.ma-chatbot__footer{
  border-top: 1px solid var(--ma-cb-border);
  padding: 10px 12px 12px;
  display: grid;
  gap: 8px;
}

.ma-chatbot__form{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.ma-chatbot__input{
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--ma-cb-border);
  background: rgba(255,255,255,.06);
  color: var(--ma-cb-text);
  padding: 10px 12px;
  font-size: 14px;
}

.ma-chatbot__input::placeholder{
  color: rgba(234,240,255,.5);
}

.ma-chatbot__input:focus-visible{
  outline: 3px solid rgba(255,255,255,.65);
  outline-offset: 2px;
}

.ma-chatbot__send{
  border-radius: 12px;
  border: 1px solid rgba(11,92,255,.55);
  background: rgba(11,92,255,.25);
  color: var(--ma-cb-text);
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

.ma-chatbot__send:focus-visible{
  outline: 3px solid rgba(255,255,255,.65);
  outline-offset: 2px;
}

.ma-chatbot__legal{
  font-size: 12px;
  color: var(--ma-cb-muted);
}

/* =========================
   Thinking overlay (tipo Siri)
   Requiere: #maChatbotThinking en el HTML
   ========================= */
.ma-chatbot__thinking[hidden]{ display:none !important; }

.ma-chatbot__thinking{
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 5;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(6px);
}

.ma-chatbot__thinkingInner{
  min-width: 180px;
  max-width: 80%;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(255,255,255,.92);
  box-shadow: 0 18px 42px rgba(0,0,0,.12);
  display: grid;
  gap: 10px;
  justify-items: center;
}

.ma-chatbot__thinkingText{
  font-size: 14px;
  font-weight: 750;
  color: rgba(0,0,0,.68);
  letter-spacing: .2px;
}

.ma-chatbot__thinkingDots{
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.ma-chatbot__thinkingDots span{
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--ma-cb-accent);
  opacity: .22;
  animation: maCbThink 1.0s infinite;
}

.ma-chatbot__thinkingDots span:nth-child(2){ animation-delay: .12s; }
.ma-chatbot__thinkingDots span:nth-child(3){ animation-delay: .24s; }

@keyframes maCbThink{
  0%,100%{ transform: translateY(0); opacity: .22; }
  50%{ transform: translateY(-4px); opacity: .75; }
}

/* =========================
   Reduced motion
   ========================= */
@media (prefers-reduced-motion: reduce){
  .ma-chatbot__panel,
  .ma-chatbot__messages{
    scroll-behavior: auto;
    transition: none;
  }
  .ma-chatbot__overlay{ backdrop-filter: none; }
  .ma-chatbot__thinking{ backdrop-filter:none; }
  .ma-chatbot__thinkingDots span{ animation:none; opacity:.6; }
}
