/* =====================================================================
   Eikove.App · Shell móvil global (barra inferior de 5 destinos)
   ---------------------------------------------------------------------
   Se carga ANTES de angosto.css: la capa angosta sigue siendo la última.
   Solo se muestra en pantallas <= 768 px. En escritorio manda la
   navegación propia de cada panel.
   ===================================================================== */
:root {
  --alto-shell: 62px;
  --shell-fondo: color-mix(in srgb, var(--tarjeta, #ffffff) 96%, transparent);
  --shell-borde: var(--borde, #e3e9f2);
  --shell-texto: var(--suave, #6b7a90);
  --shell-activo: var(--texto, #6B53D1);
  --shell-acento: var(--oro, #6B53D1);
  --z-contenido: 1;
  --z-sticky: 20;
  --z-cab: 90;
  --z-barra: 100;
  --z-cajon: 400;
  --z-dock: 450;
  --z-hoja: 500;
  --z-aviso: 1000;
}

.tb-shell {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-barra);
  display: none;
  background: var(--shell-fondo);
  border-top: 1px solid var(--shell-borde);
  box-shadow: 0 -6px 22px color-mix(in srgb, var(--perfil-accent, #6B53D1) 10%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateZ(0);
}

.tb-shell-in {
  display: grid;
  grid-template-columns: repeat(var(--tb-n, 5), minmax(0, 1fr));
  align-items: end;
  height: var(--alto-shell);
  max-width: 560px;
  margin: 0 auto;
  padding: 0 4px;
}

.tb-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 44px;
  padding: 8px 2px 7px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--shell-texto);
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .01em;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tb-slot .tb-ico {
  position: relative;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
}
.tb-slot .tb-ico svg { width: 23px; height: 23px; display: block; }
.tb-slot .tb-txt { line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tb-slot.activo { color: var(--shell-activo); }
.tb-slot.activo::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 35%;
  right: 35%;
  height: 2px;
  border-radius: 0 0 3px 3px;
  background: var(--shell-acento);
}
.tb-slot:focus-visible { outline: 2px solid var(--azul-3, #4C3AA0); outline-offset: -2px; }

.tb-slot .tb-nb {
  position: absolute;
  top: 1px;
  right: calc(50% - 19px);
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: #c62828;
  color: #fff;
  font-size: 10px;
  line-height: 17px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.tb-slot .tb-nb[hidden] { display: none; }

/* Reserva de espacio para que la barra no tape el final del contenido */
@media (max-width: 768px) {
  .tb-shell { display: block; }
  body.tb-con-shell {
    padding-bottom: calc(var(--alto-shell) + env(safe-area-inset-bottom) + 10px) !important;
  }
  /* Toasts por encima de la barra, nunca debajo */
  body.tb-con-shell #toasts,
  body.tb-con-shell #contenedor-notificaciones-popups {
    bottom: calc(var(--alto-shell) + env(safe-area-inset-bottom) + 12px);
  }
}

/* Celular en horizontal: el ancho supera los 768 px pero la pantalla es un teléfono.
   La barra inferior sigue siendo la navegación principal, así que se mantiene (más baja). */
@media (orientation: landscape) and (max-height: 560px) and (max-width: 1080px) {
  .tb-shell { display: block !important; height: calc(50px + env(safe-area-inset-bottom)) !important; }
  body.tb-con-shell {
    --alto-shell: 50px;
    padding-bottom: calc(var(--alto-shell) + env(safe-area-inset-bottom) + 8px) !important;
  }
  body.tb-con-shell #toasts,
  body.tb-con-shell #contenedor-notificaciones-popups {
    bottom: calc(var(--alto-shell) + env(safe-area-inset-bottom) + 10px);
  }
  .tb-slot { gap: 1px; padding: 2px 0; }
  .tb-slot .tb-ico svg { width: 20px; height: 20px; }
  .tb-slot .tb-txt { font-size: 9.5px; }
  .tb-slot-centro .tb-ico svg { width: 21px; height: 21px; }
}

/* Tema oscuro */
html[data-tema="oscuro"] .tb-shell {
  --shell-fondo: rgba(18, 27, 41, .97);
  --shell-borde: #26364e;
  --shell-texto: #93a4bb;
  --shell-activo: #e8eef8;
}

/* Pastilla EN VIVO de la cabecera (reemplaza el botón flotante) */
.tb-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(229, 57, 53, .35);
  background: rgba(229, 57, 53, .10);
  color: #b3261e;
  font: inherit;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: .04em;
  cursor: pointer;
}
.tb-live-pill[hidden] { display: none !important; }
.tb-live-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e53935;
  box-shadow: 0 0 0 0 rgba(229, 57, 53, .55);
  animation: tb-pulso 1.8s ease-out infinite;
}
html[data-tema="oscuro"] .tb-live-pill { color: #ff8b86; border-color: rgba(255, 139, 134, .4); }
@keyframes tb-pulso {
  0% { box-shadow: 0 0 0 0 rgba(229, 57, 53, .55); }
  70% { box-shadow: 0 0 0 7px rgba(229, 57, 53, 0); }
  100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .tb-live-pill::before { animation: none; }
}

/* Botón de ayuda en cabecera (reemplaza el SOS flotante) */
.tb-sos-cab {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--borde, #d6deea);
  background: transparent;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.tb-sos-cab:hover { background: color-mix(in srgb, var(--perfil-accent, #6B53D1) 6%, transparent); }
.tb-sos-cab:focus-visible { outline: 2px solid var(--azul-3, #4C3AA0); outline-offset: 2px; }

/* Hoja de creación (+) */
.tb-hoja-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: none;
}
.tb-hoja-tabs::-webkit-scrollbar { display: none; }
.tb-hoja-tab {
  flex: none;
  min-height: 38px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--borde, #d6deea);
  background: var(--tarjeta, #fff);
  color: var(--texto, #142033);
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}
.modal .tb-hoja-tabs .tb-hoja-tab {
  background: transparent;
  border-color: var(--borde, #d6deea);
  color: var(--texto, #142033);
}
.modal .tb-hoja-tabs .tb-hoja-tab.activa {
  background: var(--marca, #6B53D1);
  border-color: var(--marca, #6B53D1);
  color: #fff;
}
.tb-hoja-lista { display: grid; gap: 8px; }
/* El atributo hidden debe ganarle al display:grid de la lista (los paneles por
   rol conviven en la hoja y sólo se ve el de la pestaña activa). */
.tb-hoja-lista[hidden] { display: none; }
.tb-hoja-opcion {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 11px 13px;
  border: 1px solid var(--borde, #d6deea);
  border-radius: 14px;
  background: var(--tarjeta, #fff);
  color: var(--texto, #142033);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.tb-hoja-opcion:hover { border-color: var(--azul-3, #4C3AA0); }
.tb-hoja-opcion .tb-hoja-ico {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--azul-claro, #e7eef8);
  font-size: 19px;
}
.tb-hoja-opcion b { display: block; font-size: 14px; }
.tb-hoja-opcion small { display: block; margin-top: 1px; color: var(--suave, #5b6b82); font-size: 11.5px; line-height: 1.35; }
.tb-hoja-opcion.destacada { border-color: var(--oro, #6B53D1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--perfil-accent, #6B53D1) 12%, transparent) inset; }
.tb-hoja-opcion.destacada .tb-hoja-ico { background: var(--aviso-claro, #fff4dc); }
.tb-hoja-nota { margin: 10px 0 0; color: var(--suave, #5b6b82); font-size: 11.5px; line-height: 1.4; }

/* Botón de ayuda sobre la cabecera azul marino */
/* Igual que los demás botones redondos de la cabecera: toma el color del tema (antes era blanco fijo y desaparecía en tema claro). */
.superapp-header .tb-sos-cab { color: var(--perfil-texto, #334155); background: var(--perfil-superficie-2, #f1f5f9); border-color: var(--perfil-borde, #cbd5e1); }
.superapp-header .tb-sos-cab:hover { background: color-mix(in srgb, var(--perfil-accent, #6B53D1) 12%, var(--perfil-superficie-2, #f1f5f9)); }

/* Avisos abiertos en el lugar (fuera del muro) */
.tb-avisos-velo { position: fixed; inset: 0; z-index: 1290; background: rgba(0, 0, 0, .55); }
.tb-avisos-hoja {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1300; max-height: 82vh; display: flex; flex-direction: column;
  background: var(--tarjeta, #fff); color: var(--texto, #1a1a1a); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .4);
  animation: tbAvisosSube .24s cubic-bezier(.3, .9, .3, 1);
}
@keyframes tbAvisosSube { from { transform: translateY(100%); } to { transform: none; } }
.tb-avisos-hoja header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid rgba(128, 128, 128, .25); font-size: 16px; }
.tb-avisos-x { width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(128, 128, 128, .18); color: inherit; font-size: 22px; line-height: 1; cursor: pointer; }
.tb-avisos-lista { overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px calc(14px + env(safe-area-inset-bottom)); display: grid; gap: 8px; align-content: start; }
.tb-aviso { display: block; padding: 10px 12px; border: 1px solid rgba(128, 128, 128, .3); border-radius: 10px; color: inherit; text-decoration: none; }
.tb-aviso.nuevo { border-color: var(--marca, #6B53D1); background: color-mix(in srgb, var(--perfil-accent, #6B53D1) 12%, transparent); }
.tb-aviso b { font-size: 12.5px; }
.tb-aviso p { margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.tb-aviso small, .tb-avisos-vacio { color: rgba(128, 128, 128, .95); font-size: 12px; }
.tb-avisos-vacio { text-align: center; padding: 18px 0; font-size: 14px; }
body.tb-avisos-abierto { overflow: hidden; }
@media (min-width: 769px) { .tb-avisos-hoja { left: 50%; right: auto; width: 460px; transform: translateX(-50%); border-radius: 18px; bottom: 24px; animation: none; } }

/* Tienda al centro de la barra: ícono en un bloque de color que sobresale un poco */
.tb-slot-centro { overflow: visible; }
.tb-slot-centro .tb-ico {
  width: 46px; height: 46px; margin-top: -16px; border-radius: 16px;
  background: var(--shell-acento, #6B53D1); color: var(--perfil-acento-texto, #fff);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .28), 0 0 0 4px var(--shell-fondo, #fff);
  transition: transform .15s ease, box-shadow .2s ease;
}
.tb-slot-centro .tb-ico svg { width: 25px; height: 25px; }
.tb-slot-centro:active .tb-ico { transform: scale(.94); }
.tb-slot-centro.activo::before { display: none; }
.tb-slot-centro.activo .tb-ico { box-shadow: 0 8px 20px rgba(0, 0, 0, .34), 0 0 0 4px var(--shell-fondo, #fff), 0 0 0 6px var(--shell-acento, #6B53D1); }
.tb-slot-centro .tb-txt { font-weight: 800; }

/* Tienda al centro: el aro del botón (sombra de 4-6 px) pisaba la palabra «Tienda». Se deja aire debajo del ícono. */
.tb-slot-centro .tb-ico { margin-bottom: 9px; }
.tb-slot-centro .tb-txt { position: relative; z-index: 1; }
.tb-slot-centro.activo .tb-ico { box-shadow: 0 8px 20px rgba(0, 0, 0, .34), 0 0 0 3px var(--shell-fondo, #fff), 0 0 0 5px var(--shell-acento, #6B53D1); }

/* Con la bandeja de mensajes abierta, la barra inferior queda por encima: el botón central (Tienda) no se tapa. */
body.chat-abierto .tb-shell { z-index: 700; }
/* Con el teclado del celular abierto la barra queda tapada (ver ui.js). */
html.tb-teclado-abierto .tb-shell { display: none !important; }

/* Cartel mientras se pasa de un panel a otro (la barra de abajo queda a la vista). */
#tbYendo { position: fixed; inset: 0; z-index: 640; display: grid; place-items: center; background: color-mix(in srgb, var(--perfil-bg, #f7f5fd) 82%, transparent); backdrop-filter: blur(3px); }
#tbYendo > div { display: grid; justify-items: center; gap: 12px; font-weight: 700; color: var(--perfil-texto, #171a2b); }
#tbYendo i { width: 44px; height: 44px; border-radius: 50%; border: 4px solid color-mix(in srgb, var(--perfil-accent, #6b53d1) 22%, transparent); border-top-color: var(--perfil-accent, #6b53d1); animation: tb-yendo .8s linear infinite; }
@keyframes tb-yendo { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #tbYendo i { animation-duration: 2.4s; } }
