/* ===========================================================================
   EasyTable · layout.css — estructura/shell del panel
   ---------------------------------------------------------------------------
   Barra superior, barra lateral flotante + navegación, interruptor de
   servicio, notificaciones del topbar, toaster global y contenedor de
   contenido. (No incluye estilos propios de cada pantalla.)
   =========================================================================== */

/* ---- Estructura general ---- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  background: var(--card); border-bottom: 1px solid var(--line-2); padding: 12px 22px;
}
.biz { display: flex; align-items: center; gap: 12px; }
.biz-logo {
  width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--surface-soft), var(--surface-soft-2));
  display: grid; place-items: center; font-size: 22px; border: 1px solid var(--line-2);
}
.biz-name { font-weight: 800; font-size: 16px; color: var(--navy); line-height: 1.1; }
.biz-state { font-size: 13px; color: var(--muted); }
.biz-state b { color: var(--green-d); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.admin { text-align: right; line-height: 1.15; }
.admin .name { font-weight: 700; color: var(--navy); font-size: 14px; }
.admin .role { font-size: 12px; color: var(--muted); }
.admin .role b { color: var(--ink); }
.power { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--green); color: var(--green); background: var(--card); font-size: 18px; }

.body { display: flex; align-items: flex-start; padding: 14px 0 0 14px; }
.sidebar {
  position: sticky; top: 14px; align-self: flex-start; height: calc(100vh - 28px);
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  padding: 14px 0 14px;
  display: flex; flex-direction: column; width: 72px; flex: 0 0 72px; overflow: visible; z-index: 25;
}
/* Logo de la tienda y avatar como ítems de navegación */
.nav-item.is-logo .nav-logo, .nav-item.is-avatar .avatar {
  width: 34px; height: 34px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  border: 2px solid var(--line-2); background: linear-gradient(135deg, var(--surface-soft), var(--surface-soft-2));
  font-size: 16px; transition: transform .12s, border-color .12s;
}
.nav-item.is-logo .nav-logo img, .nav-item.is-avatar .avatar img { width: 100%; height: 100%; object-fit: cover; opacity: 1; transform: none; }
.nav-item.is-avatar { margin-top: auto; } /* "Mi perfil" anclado al fondo, sobre el switch */
/* "Ver menú" (enlace <a>, no botón): anclado al fondo, pegado arriba del perfil.
   Solo él lleva margin-top:auto; al perfil que le sigue se le quita para que
   no se repartan el espacio libre entre los dos (quedaría un hueco). */
.nav-item.is-vermenu { margin-top: auto; text-decoration: none; }
.nav-item.is-vermenu + .nav-item.is-avatar { margin-top: 0; }
.nav-item.is-avatar .avatar { border-color: var(--navy); background: rgba(41,39,75,.08); color: var(--navy); font-weight: 700; }
.avatar-ini { font-size: 15px; font-weight: 700; color: var(--navy); }
.nav-item.active.is-logo .nav-logo, .nav-item.active.is-avatar .avatar { border-color: var(--crimson); transform: scale(1.06); }
/* Home y Perfil: al estar activos NO llevan fondo ni barra roja; basta el aro
   rojo de la propia imagen (logo / avatar). */
.nav-item.is-logo.active::before, .nav-item.is-logo.active::after,
.nav-item.is-avatar.active::before, .nav-item.is-avatar.active::after { content: none; }
/* Botón de cerrar sesión al pie de la barra */
.nav-logout { margin-top: 12px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid #f6c6d1;
  background: var(--card); display: grid; place-items: center; cursor: pointer; }
.nav-logout:hover { background: #fff3f5; }
[data-theme="dark"] .nav-logout:hover { background: rgba(239, 17, 73, .16); }
.nav-list { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow: visible; }
.nav-item {
  position: relative; width: 100%; height: 50px; border: none; background: transparent;
  display: grid; place-items: center; border-radius: 0; padding: 0;
}
.nav-item img { width: 30px; height: 30px; opacity: .45; transition: opacity .12s, transform .12s, filter .12s; }
.nav-item:hover img { opacity: .8; }
.nav-item.active img { opacity: 1; transform: scale(1.08); }
/* Los íconos de línea del menú son SVG de un solo color (trazo navy) pensados
   para fondo claro: en oscuro se invierten a blanco. El logo del negocio y el
   avatar de usuario son fotos reales, así que se excluyen (no se invierten). */
[data-theme="dark"] .nav-item img { filter: brightness(0) invert(1); }
[data-theme="dark"] .nav-item.is-logo .nav-logo img,
[data-theme="dark"] .nav-item.is-avatar .avatar img { filter: none; }
/* El ícono por defecto (sin logo/imagen todavía) SÍ es un SVG de un solo color
   y necesita invertirse aunque esté dentro de .nav-logo. */
[data-theme="dark"] .nav-item.is-logo .nav-logo img.default-icon { filter: brightness(0) invert(1) opacity(.6); }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 6px;
  border-radius: 4px; background: var(--crimson);
}
/* Fondo al pasar el cursor (suave) y en la sección activa (más marcado) */
.nav-item:hover::after {
  content: ""; position: absolute; inset: 4px 8px; border-radius: 14px;
  background: rgba(239, 17, 73, .07); z-index: -1;
}
.nav-item.active::after {
  content: ""; position: absolute; inset: 4px 8px; border-radius: 14px;
  background: rgba(239, 17, 73, .12); z-index: -1;
}
.nav-badge {
  position: absolute; top: 6px; right: 12px; min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--crimson); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--card);
}
/* Etiqueta saliente con el nombre de la sección (hover + activa) */
.nav-label {
  position: absolute; left: calc(100% - 2px); top: 50%; transform: translateY(-50%) translateX(8px);
  background: var(--navy-solid); color: #fff; padding: 6px 12px; border-radius: 9px; font-size: 13px;
  font-weight: 600; white-space: nowrap; opacity: 0; pointer-events: none; z-index: 60;
  box-shadow: var(--shadow-sm); transition: opacity .12s, transform .12s;
}
.nav-label::before {
  content: ""; position: absolute; left: -5px; top: 50%; transform: translateY(-50%);
  border: 5px solid transparent; border-right-color: var(--navy-solid);
}
.nav-item:hover .nav-label { opacity: 1; transform: translateY(-50%) translateX(0); animation: none; }
/* Al elegir una sección, la etiqueta aparece un momento y se oculta. */
.nav-item.active .nav-label { opacity: 0; background: var(--crimson); animation: navflash 1.8s ease forwards; }
.nav-item.active .nav-label::before { border-right-color: var(--crimson); }
/* Al pasar el cursor sobre la sección activa, la etiqueta también aparece (como las demás). */
.nav-item.active:hover .nav-label { opacity: 1; background: var(--navy-solid); transform: translateY(-50%) translateX(0); animation: none; }
.nav-item.active:hover .nav-label::before { border-right-color: var(--navy-solid); }
@keyframes navflash {
  0%   { opacity: 0; transform: translateY(-50%) translateX(8px); }
  12%  { opacity: 1; transform: translateY(-50%) translateX(0); }
  72%  { opacity: 1; transform: translateY(-50%) translateX(0); }
  100% { opacity: 0; transform: translateY(-50%) translateX(0); }
}

/* Interruptor de servicio (switch) al pie de la barra */
.nav-foot { border-top: 1px solid var(--line-2); padding-top: 12px; text-align: center; }
.svc-switch { width: 48px; height: 26px; border-radius: 999px; border: none; background: #cfd4de;
  position: relative; cursor: pointer; margin: 0 auto; padding: 0; transition: background .15s; }
[data-theme="dark"] .svc-switch { background: #3a3a52; }
.svc-switch.on { background: var(--green); }
.svc-switch.off { background: var(--crimson); }
.svc-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .15s; }
.svc-switch.on .svc-knob { left: 25px; }
.store-label { font-size: 11px; font-weight: 700; margin-top: 6px; }
.store-label.on { color: var(--green-d); }
.store-label.off { color: var(--crimson); }

/* Toaster global (ET.toast) — reemplaza alert() */
.et-toaster { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 9800; align-items: center; }
.et-toast { background: var(--navy-solid); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: 0 12px 30px rgba(20, 20, 50, .28); animation: toastup .28s ease; max-width: 360px; }
.et-toast.error { background: var(--crimson); }
.et-toast.ok { background: var(--green); }
.et-toast.out { opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; }

/* Notificaciones (toasts) que salen desde abajo */
.toasts { position: fixed; right: 22px; bottom: 92px; display: flex; flex-direction: column-reverse; gap: 10px; z-index: 9500; }
.toast-card { background: var(--navy-solid); color: #fff; padding: 13px 18px; border-radius: 12px; font-weight: 600;
  box-shadow: 0 12px 30px rgba(20, 20, 50, .28); animation: toastup .32s ease; max-width: 320px; }
@keyframes toastup { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: translateY(0); } }

/* Aviso de servicio inactivo: brillo rojo en los bordes */
.inactive-glow { position: fixed; inset: 0; pointer-events: none; z-index: 9000;
  box-shadow: inset 0 0 44px 6px rgba(239, 17, 73, .5); animation: glowpulse 2.6s ease-in-out infinite; }
@keyframes glowpulse {
  0%, 100% { box-shadow: inset 0 0 34px 3px rgba(239, 17, 73, .38); }
  50%      { box-shadow: inset 0 0 60px 10px rgba(239, 17, 73, .62); }
}

/* Botones de icono del topbar (notificaciones, salir) */
.biz-logo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.biz-state b.closed { color: var(--crimson); }
.icon-btn { position: relative; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line-2);
  background: var(--card); font-size: 18px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { filter: brightness(.97); }
.icon-btn.door { border-color: #f6c6d1; }
.notif-wrap { position: relative; }
.notif-badge { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 5px;
  background: var(--crimson); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--card); box-sizing: border-box; }
/* Botón flotante para cambiar de tema (siempre visible, en cualquier pantalla).
   right: 26px = 22px (right de .notif-fab) + (54px - 46px)/2, para que quede
   centrado horizontalmente con el botón de notificaciones de abajo. */
.theme-fab { position: fixed; right: 26px; bottom: 86px; z-index: 9600;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line-2);
  background: var(--card); box-shadow: var(--shadow); font-size: 20px; padding: 0;
  display: grid; place-items: center; cursor: pointer; transition: transform .12s, filter .12s; }
.theme-fab:hover { transform: translateY(-1px); filter: brightness(.97); }

/* Notificaciones flotantes (abajo a la derecha) */
.notif-fab { position: fixed; right: 22px; bottom: 22px; z-index: 9600;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.notif-fab-btn { position: relative; width: 54px; height: 54px; border-radius: 50%; border: none;
  padding: 8px; box-sizing: border-box;
  background: var(--navy-solid); color: #fff; box-shadow: 0 12px 28px rgba(20, 20, 50, .30);
  display: grid; place-items: center; cursor: pointer; transition: transform .12s, filter .12s; }
.notif-fab-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.notif-fab-btn .ic { display: block; background: #fff; }
.notif-menu { width: 340px; max-width: calc(100vw - 32px); background: var(--card);
  border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
  animation: toastup .2s ease; }
.notif-head { padding: 12px 14px; font-weight: 700; color: var(--navy); border-bottom: 1px solid var(--line); }
.notif-item { padding: 11px 14px; font-size: 14px; border-bottom: 1px solid var(--line); }
.notif-item:last-child { border-bottom: none; }

.content { flex: 1; min-width: 0; padding: 22px 26px 60px; }

/* ---------------------------------------------------------------------------
   Responsivo: la barra lateral (icon rail) se convierte en una barra inferior
   fija y horizontal con scroll — el patrón "bottom tab bar" de apps móviles,
   en vez de esconder la navegación sin reemplazo.
   --------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .body { padding: 0; }
  .content { padding: 16px 14px calc(78px + env(safe-area-inset-bottom)); }

  .sidebar {
    position: fixed; inset: auto 0 0 0; top: auto; height: auto; width: 100%;
    flex: none; flex-direction: row; align-items: stretch;
    border-radius: 16px 16px 0 0; padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    z-index: 90;
  }
  .nav-list { flex-direction: row; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 0; scrollbar-width: none; }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-item { width: 56px; height: 56px; flex: 0 0 56px; }
  .nav-item img { width: 24px; height: 24px; }
  .nav-item.is-avatar, .nav-item.is-vermenu { margin-top: 0; } /* ya no "al fondo": aquí todo va en fila */
  .nav-item.active::before { left: 10px; right: 10px; top: 0; bottom: auto; width: auto; height: 4px; border-radius: 0 0 4px 4px; }
  /* La etiqueta salía hacia la derecha del riel vertical; en una barra inferior
     no hay espacio horizontal para eso, así que no se activa con touch. */
  .nav-label { display: none; }

  .nav-foot { border-top: none; border-left: 1px solid var(--line-2); padding: 4px 0 4px 10px; margin-left: 4px;
    flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; }

  /* Elementos flotantes: subirlos por encima de la barra inferior fija. */
  .notif-fab { bottom: calc(78px + env(safe-area-inset-bottom)); right: 14px; }
  .theme-fab { bottom: calc(142px + env(safe-area-inset-bottom)); right: 18px; }
  .et-toaster { bottom: calc(78px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(212px + env(safe-area-inset-bottom)); right: 14px; }
}

/* Pantalla de carga inicial del panel */
.splash { display: grid; place-items: center; height: 100vh; color: var(--muted); }
