/**
 * PWA shell + adaptaciones operativas Buffet/Rodizio
 * REQ-BFN-20260803-002
 */

.socti-pwa-offline-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10050;
  padding: 8px 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff7ed;
  background: #c2410c;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.socti-pwa-offline-bar[hidden] {
  display: none !important;
}

.socti-pwa-toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 10060;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 10px 30px rgba(2, 8, 23, 0.45);
  font-size: 13px;
}

.socti-pwa-toast[hidden] {
  display: none !important;
}

.socti-pwa-toast__btn {
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  background: #2878ff;
  color: #fff;
}

/* Barra persistente: nueva versión PWA lista para redesplegar */
.socti-pwa-update-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10070;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, #1d4ed8 0%, #1e3a8a 100%);
  color: #eff6ff;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.35);
}

.socti-pwa-update-bar[hidden] {
  display: none !important;
}

.socti-pwa-update-bar__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 12px;
  line-height: 1.35;
}

.socti-pwa-update-bar__text strong {
  font-size: 13px;
  font-weight: 800;
}

.socti-pwa-update-bar__text span {
  opacity: 0.92;
}

.socti-pwa-update-bar__btn {
  flex: 0 0 auto;
  min-height: 44px;
  min-width: 110px;
  border: 0;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 800;
  font-size: 13px;
  background: #fff;
  color: #1e3a8a;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.socti-pwa-update-bar__btn:disabled,
.socti-pwa-update-bar.is-updating .socti-pwa-update-bar__btn {
  opacity: 0.85;
  cursor: wait;
  background: #e2e8f0;
  color: #334155;
}

.socti-pwa-update-bar.is-updating {
  background: linear-gradient(180deg, #0f766e 0%, #115e59 100%);
}

html.pwa-update-available body {
  /* deja aire bajo la barra de actualización */
  scroll-padding-top: 72px;
}

html.pwa-update-available .socti-pwa-offline-bar {
  top: auto;
}

/* ---- Buffet/Rodizio: maximizar área útil en standalone / móvil ---- */
html.pwa-standalone-ops.pwa-buffet-ops body.menu3-page .main-sidebar,
html.pwa-standalone-ops.pwa-buffet-ops body.menu3-page .control-sidebar,
html.pwa-standalone-ops.pwa-buffet-ops body.menu3-page .control-sidebar-bg,
html.pwa-standalone-ops.pwa-buffet-ops body.menu3-page .main-footer {
  display: none !important;
}

html.pwa-standalone-ops.pwa-buffet-ops body.menu3-page .content-wrapper,
html.pwa-standalone-ops.pwa-buffet-ops body.menu3-page .content-wrapper.menu3-favoritos-wrap {
  margin-left: 0 !important;
  padding-left: 0 !important;
}

html.pwa-standalone-ops.pwa-buffet-ops body.menu3-page .main-header {
  position: sticky;
  top: 0;
  z-index: 1030;
}

html.pwa-standalone-ops.pwa-buffet-ops body.menu3-page {
  overflow-x: hidden;
}

@media (max-width: 900px) {
  html.pwa-buffet-ops body.menu3-page .main-sidebar {
    /* Drawer móvil: no reservar columna permanente */
  }
  html.pwa-buffet-ops body.menu3-page.sidebar-collapse .content-wrapper,
  html.pwa-buffet-ops body.menu3-page .content-wrapper {
    margin-left: 0 !important;
  }
  html.pwa-buffet-ops body.menu3-page .m3-page-head h1 {
    font-size: 1.25rem;
  }
}

@media (max-width: 430px) {
  html.pwa-buffet-ops body.menu3-page {
    --m3-card-min: 140px;
    --m3-card-h: 128px;
  }
}

/* Salón hostess: layout móvil solo por ancho (PWA desktop debe conservar mosaico) */
@media (max-width: 820px) {
  html.pwa-buffet-ops.bf-salon-hostess .hs-app,
  html.bf-salon-hostess.pwa-buffet-ops .hs-app,
  html.bf-salon-hostess .hs-app {
    grid-template-columns: 1fr !important;
  }
  html.pwa-buffet-ops.bf-salon-hostess .hs-sidebar,
  html.bf-salon-hostess.pwa-buffet-ops .hs-sidebar {
    display: none !important;
  }
}

@media (max-width: 430px) {
  html.bf-salon-hostess .hs-app {
    grid-template-columns: 1fr !important;
  }
}

/* Venta móvil: safe areas notch */
html.pwa-buffet-ops body.buffette-mobile-orden-active .buffette-mobile-shell,
body.buffette-mobile-orden-active .buffette-mobile-shell {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html.pwa-offline body.buffette-mobile-orden-active .send,
html.pwa-offline body.buffette-mobile-orden-active #btnEnviarOrden,
html.pwa-offline body.buffette-mobile-orden-active button[type="submit"] {
  opacity: 0.55;
  pointer-events: none;
}

@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: none;
  }
  html.pwa-buffet-ops body.menu3-page .content-wrapper {
    min-height: 100dvh;
  }
}

/* PWA en PC: no colapsar shell operativo (sidebar/mosaico) */
html.socti-desktop-device.pwa-buffet-ops .hs-app,
html.socti-desktop-pwa .hs-app {
  grid-template-columns: 88px 1fr !important;
}
html.socti-desktop-device.pwa-buffet-ops .hs-sidebar,
html.socti-desktop-pwa .hs-sidebar {
  display: flex !important;
}
html.socti-desktop-device:not(.socti-mobile-shell) {
  /* marca estable para CSS/JS de módulos */
}

/* Navegación tipo app/Amazon en móvil: acciones abajo y contenido fuera del notch. */
.socti-mobile-nav { display: none; }

@media (max-width: 768px) {
  body.fixed .main-header.fge-header { display: none !important; }
  body.fixed .content-wrapper,
  body.fixed .right-side {
    padding-top: 0 !important;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .socti-mobile-nav {
    position: fixed;
    z-index: 1045;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: 60px;
    padding: 3px 4px 2px;
    background: rgba(15, 23, 42, 0.98);
    border-top: 1px solid rgba(148, 163, 184, 0.28);
    box-shadow: 0 -8px 24px rgba(2, 8, 23, 0.38);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
  .socti-mobile-nav__dropup { position: relative; min-width: 0; }
  .socti-mobile-nav .socti-mobile-nav__item {
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 52px;
    margin: 0;
    padding: 5px 2px 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #cbd5e1;
    font: inherit;
    text-align: center;
    text-decoration: none;
    touch-action: manipulation;
  }
  .socti-mobile-nav .socti-mobile-nav__item:hover,
  .socti-mobile-nav .socti-mobile-nav__item:focus,
  .socti-mobile-nav .socti-mobile-nav__item:active,
  .socti-mobile-nav__dropup.open > .socti-mobile-nav__item {
    outline: none;
    color: #fff;
    background: rgba(59, 130, 246, 0.18);
  }
  .socti-mobile-nav__item .fa { font-size: 20px; line-height: 1; }
  .socti-mobile-nav__item span {
    max-width: 100%;
    overflow: hidden;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .socti-mobile-nav__item[href="inicio"] .fa { color: #34d399; }
  .socti-mobile-nav__item[href="menu3"] .fa { color: #fbbf24; }
  .socti-mobile-nav__badge {
    position: absolute;
    top: 3px;
    left: calc(50% + 7px);
    min-width: 16px;
    padding: 2px 4px;
    border-radius: 999px;
    color: #fff;
    background: #ef4444;
    font-size: 9px;
    line-height: 1.2;
  }
  .socti-mobile-nav__menu {
    right: 4px;
    bottom: calc(100% + 8px);
    left: auto;
    width: min(300px, calc(100vw - 16px));
    max-height: min(55vh, 420px);
    margin: 0;
    overflow-y: auto;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 45px rgba(2, 8, 23, 0.32);
  }
  .socti-mobile-nav__branches { right: auto; left: 50%; transform: translateX(-65%); }
  .socti-mobile-nav__menu > li > a,
  .socti-mobile-nav__menu > .dropdown-header { padding: 11px 14px; white-space: normal; }
  .socti-pwa-toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 360px) {
  .socti-mobile-nav__item span { font-size: 9px; }
}
