/* ============================================================
   SERENZA · layout.css
   App layout: sidebar, navbar, containers, page headers.
   Requires colors_and_type.css + reset.css.
   ============================================================ */

/* ---------- APP LAYOUT ---------- */
.sz-app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh; /* se adapta a la barra retráctil de Chrome móvil */
}

.sz-app__sidebar {
  position: fixed;
  top: calc(var(--navbar-h, 60px) + env(safe-area-inset-top, 0px));
  left: 0;
  /* Altura ligada al viewport visible: sigue a la barra retráctil de Chrome móvil,
     así los últimos enlaces nunca quedan ocultos tras la barra del navegador. */
  height: calc(100vh - var(--navbar-h, 60px) - env(safe-area-inset-top, 0px));
  height: calc(100dvh - var(--navbar-h, 60px) - env(safe-area-inset-top, 0px));
  width: 260px;
  background: var(--forest);
  border-right: 1px solid var(--forest-80);
  z-index: 60; /* por encima de la barra inferior móvil (z-index 50) al abrirse */
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.2,.8,.2,1);
}
.sz-app__sidebar[data-open="true"],
.sz-app__sidebar.is-open {
  transform: none;
}

.sz-app__main {
  flex: 1;
  min-width: 0;
  padding: 32px clamp(20px, 4vw, 48px);
  margin-top: calc(var(--navbar-h, 60px) + env(safe-area-inset-top, 0px));
}

/* ---------- BACKDROP DEL SIDEBAR (móvil) ---------- */
.sz-app__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 42, 36, .42);
  z-index: 55; /* sobre el contenido y la barra inferior, bajo el sidebar (60) */
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.sz-app__backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Bloqueo de scroll del fondo cuando el sidebar está abierto */
body.sz-no-scroll {
  overflow: hidden;
}

/* Sidebar permanente SOLO en desktop con puntero fino (ratón).
   En iPad y cualquier dispositivo táctil (hover:none / pointer:coarse) se mantiene
   el menú colapsable con botón + backdrop, dejando todo el ancho al contenido
   (especialmente útil en el plano de mesas / seating). */
@media (min-width: 860px) and (hover: hover) and (pointer: fine) {
  .sz-app__sidebar {
    transform: none;
  }
  .sz-app__main {
    margin-left: 260px;
  }
  /* En desktop el sidebar es permanente: nunca backdrop ni scroll-lock */
  .sz-app__backdrop {
    display: none;
  }
  body.sz-no-scroll {
    overflow: visible;
  }
}

/* ---------- NAVBAR APP ---------- */
.sz-app-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* Suma el inset superior (notch iOS); en Android Chrome es 0 → sin cambios */
  height: calc(var(--navbar-h, 60px) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-left: clamp(16px, 3vw, 28px);
  padding-right: clamp(16px, 3vw, 28px);
  background: var(--paper-soft);
  color: var(--ink);
  border-bottom: 1px solid var(--paper-deep);
  z-index: 65; /* sobre el backdrop (55) para que el botón menú siga siendo clicable */
}
.sz-app-nav__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-size: 22px;
  color: var(--forest);
  letter-spacing: .02em;
  text-decoration: none;
  line-height: 1;
}
.sz-app-nav__brand:hover { text-decoration: none; color: var(--gold-deep); }
.sz-app-nav__isotipo {
  width: 22px;
  height: 26px;
  flex-shrink: 0;
}
.sz-app-nav__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sz-app-nav__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background .2s;
}
.sz-app-nav__toggle:hover { background: var(--paper-deep); }

.sz-app-nav__icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background .2s;
}
.sz-app-nav__icon-btn:hover { background: var(--paper-deep); }
.sz-app-nav__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--forest);
  font-size: 10px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.sz-app-nav__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background .2s;
  font-family: var(--sans);
  font-size: 14px;
}
.sz-app-nav__user:hover { background: var(--paper-deep); }

/* El botón hamburguesa se oculta solo cuando el sidebar es permanente
   (desktop con ratón). En iPad táctil sigue visible para abrir el menú. */
@media (min-width: 860px) and (hover: hover) and (pointer: fine) {
  .sz-app-nav__toggle { display: none; }
}

/* ---------- SIDEBAR NAV ---------- */
.sz-sidebar-nav {
  padding: 16px 12px;
  /* respeta el home indicator / área segura inferior en iOS */
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sz-sidebar-nav__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 14px;
  color: var(--paper-soft);
  text-decoration: none;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.sz-sidebar-nav__link:hover {
  background: var(--forest-80);
  color: var(--paper);
  text-decoration: none;
}
.sz-sidebar-nav__link[aria-current="page"],
.sz-sidebar-nav__link.is-active {
  background: var(--forest-80);
  color: var(--paper);
  font-weight: 500;
  border-left-color: var(--gold);
}
.sz-sidebar-nav__icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* ---------- CONTAINER ---------- */
.sz-container {
  max-width: var(--maxw, 1180px);
  margin: 0 auto;
}
.sz-container--sm { max-width: 720px; }
.sz-container--md { max-width: 900px; }
.sz-container--lg { max-width: 1100px; }

/* ---------- PAGE HEADER ---------- */
.sz-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.sz-page-head__title {
  font-family: var(--serif);
  font-size: clamp(26px, 3vw, 36px);
  color: var(--forest);
  margin: 0;
  line-height: 1.1;
}
.sz-page-head__sub {
  font-family: var(--sans);
  font-weight: 300;
  font-size: 14.5px;
  color: var(--ink-soft);
  margin: 6px 0 0;
}
.sz-page-head__actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}
