/* ==========================================================================
   ANH Reservas (staff) - Layout: app shell, sidebar, topbar, footer, login, grid
   Requires tokens.css, base.css and components.css. Tokens only (REQ-DS-02).
   Reflows to one column at 1024px and keeps every navigation label visible
   (an icon-only link would have no accessible name), down to 320px.
   ========================================================================== */

/* ---- App shell -------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--layout-sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg-app);
}
.app-main { display: flex; flex-direction: column; min-width: 0; }
.app-content {
  width: 100%;
  max-width: var(--layout-content-max);
  margin: 0 auto;
  padding: var(--layout-content-pad);
  flex: 1;
}

/* ---- Sidebar ---------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--space-6) var(--space-4);
  background: var(--bg-inverse);
  color: var(--color-gray-300);
  z-index: var(--z-sidebar);
  overflow-y: auto;
}
.sidebar__brand { display: block; padding: 0 var(--space-3) var(--space-6); }
.sidebar__brand img { height: 52px; width: auto; }
.sidebar__section {
  padding: var(--space-5) var(--space-3) var(--space-2);
  font-size: var(--fs-label);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--color-gray-400);
}
.nav { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  color: var(--color-gray-300);
  text-decoration: none;
  border-radius: var(--radius-pill);
  transition: var(--transition-colors);
}
.nav__item:hover { background: var(--color-ink-soft); color: var(--color-white); }
.nav__item:focus-visible { box-shadow: var(--focus-ring-inverse); border-radius: var(--radius-pill); }
.nav__item[aria-current="page"] {
  background: var(--accent);
  color: var(--text-on-accent);
  font-weight: var(--fw-semibold);
}
.sidebar__footer {
  margin-top: auto;
  padding: var(--space-4) var(--space-3) 0;
  border-top: 1px solid var(--border-on-inverse);
  font-size: var(--fs-caption);
  color: var(--color-gray-400);
}

/* ---- Topbar and user menu --------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-height: var(--layout-topbar-h);
  padding: 0 var(--layout-content-pad);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
}
.topbar__title { font-weight: var(--fw-semibold); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

.user-menu { position: relative; }
.user-menu > summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 4px var(--space-3) 4px 4px;
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu__name { font-size: var(--fs-small); font-weight: var(--fw-semibold); line-height: 1.2; }
.user-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  z-index: var(--z-dropdown);
  display: grid;
  gap: var(--space-3);
  min-width: 260px;
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
}
.user-menu__email { font-size: var(--fs-caption); color: var(--text-secondary); overflow-wrap: anywhere; }

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--color-ink);
  color: var(--accent);
  font-size: var(--fs-small);
  font-weight: var(--fw-bold);
}

/* Flash messages: one live region, always present so screen readers announce what is injected. */
.flash { display: grid; gap: var(--space-3); margin-bottom: var(--space-4); }
.flash:empty { display: none; }

/* ---- Institutional footer lockup --------------------------------------- */
.inst-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-4);
  border-top: 1px solid var(--border-default);
  background: var(--bg-surface);
}
.inst-footer img { height: 56px; width: auto; }
.inst-footer__text { font-size: var(--fs-caption); color: var(--text-secondary); text-align: center; }

/* ---- Login layout ------------------------------------------------------ */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg-app);
}
.auth__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-8);
  padding: var(--space-12);
  background: var(--bg-inverse);
  color: var(--text-inverse);
  overflow: hidden;
}
.auth__panel-logo { height: 84px; width: auto; }
.auth__headline { font-size: 2.5rem; line-height: 1.12; font-weight: var(--fw-extrabold); letter-spacing: var(--tracking-display); color: var(--text-inverse); max-width: 14ch; }
.auth__headline mark { background: var(--accent); color: var(--text-on-accent); padding: 0 0.15em; border-radius: 4px; }
.auth__lead { margin-top: var(--space-4); max-width: 44ch; color: var(--color-gray-400); font-size: var(--fs-body-lg); line-height: var(--lh-body-lg); }
.auth__frame {
  position: absolute;
  right: -120px;
  bottom: -120px;
  width: 420px;
  height: 420px;
  border: 28px solid var(--color-ink-soft);
  border-radius: 64px;
  pointer-events: none;
}
.auth__form-side { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.auth__main { flex: 1; display: grid; place-items: center; padding: var(--space-10) var(--space-6); }
.auth__card { width: 100%; max-width: 440px; padding: var(--space-10); }
.auth__card > * + * { margin-top: var(--space-5); }

/* ---- Grid and spacing helpers ------------------------------------------ */
.grid-12 { display: grid; grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr)); gap: var(--grid-gutter); }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }
.stack { display: grid; gap: var(--space-4); align-content: start; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: var(--grid-gutter); margin: 0; padding: 0; list-style: none; }

/* ---- Responsive (desktop first, reflow down to 320px) ------------------- */
@media (max-width: 1200px) {
  .col-3 { grid-column: span 6; }
  .col-8, .col-4 { grid-column: span 12; }
}
@media (max-width: 1024px) {
  :root { --layout-content-pad: var(--space-6); }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: var(--space-4); overflow: visible; }
  .sidebar__brand { padding-bottom: var(--space-3); }
  .sidebar__brand img { height: 36px; }
  .sidebar__footer { display: none; }
  .nav { display: flex; flex-wrap: wrap; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth__panel { min-height: 0; padding: var(--space-8); }
}
@media (max-width: 480px) {
  :root { --layout-content-pad: var(--space-4); }
  .col-6, .col-3 { grid-column: span 12; }
  .topbar { gap: var(--space-3); }
  .user-menu__name {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .user-menu__panel { min-width: min(260px, calc(100vw - 2 * var(--space-4))); }
  .auth__card { padding: var(--space-6); }
  .auth__headline { font-size: 2rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ---- Pages without the staff menu (error pages, public screens) ---------- */
.app-shell--simple { grid-template-columns: minmax(0, 1fr); }
.topbar__brand img { height: 40px; width: auto; }

/* ---- Login panel ---------------------------------------------------------- */
.auth__points { display: grid; gap: var(--space-3); margin: var(--space-8) 0 0; padding: 0; list-style: none; color: var(--color-gray-300); }
.auth__points li { display: flex; align-items: center; gap: var(--space-3); }
.auth__points .icon { color: var(--accent); }
.auth__copy { font-size: var(--fs-caption); color: var(--color-gray-400); }
.auth__body { position: relative; }
