/* ==========================================================================
   CENTINELA — LAYOUT
   The app shell: sidebar, topbar, mobile drawer + bottom nav, content grid.
   Breakpoints: base <768, md 768–1023, lg 1024–1279, xl 1280–1535, xxl 1536+
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100svh;
}

/* Wraps topbar + main so the grid has exactly one column-2 item spanning
   the full row — the sidebar (column 1) then stretches to match its
   height naturally via grid row-stretch, instead of the sidebar being
   sized only to whichever of topbar/main would otherwise land in row 1. */
.app-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ------------------------------------------------------------------ *
 * SIDEBAR — persistent rail on desktop, off-canvas drawer below 1024
 * ------------------------------------------------------------------ */

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--color-surface-dark);
  border-right: 1px solid var(--graphite-800);
  display: flex;
  flex-direction: column;
  z-index: var(--z-drawer);
  transform: translateX(-100%);
  transition: transform var(--duration-base) var(--ease-standard);
}

.app-sidebar.is-open {
  transform: translateX(0);
  box-shadow: var(--shadow-lg);
}

.app-sidebar__backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.55);
  z-index: calc(var(--z-drawer) - 1);
}
.app-sidebar.is-open ~ .app-sidebar__backdrop {
  display: block;
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5, 1.25rem) var(--space-5, 1.25rem);
  height: var(--topbar-height);
  flex-shrink: 0;
}

.app-sidebar__brand-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: opacity var(--duration-fast) var(--ease-standard);
}
.app-sidebar__brand-link:hover {
  opacity: 0.85;
}

.app-sidebar__brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.app-sidebar__brand-name {
  font: var(--text-h3);
  color: var(--white);
  letter-spacing: 0.01em;
}

.app-sidebar__close {
  margin-left: auto;
  color: var(--graphite-400);
  padding: var(--space-2);
  display: none;
}

.app-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.app-sidebar__section-label {
  font: var(--text-micro);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--graphite-500);
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.app-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--graphite-300);
  font: var(--text-body);
  font-weight: 500;
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
  position: relative;
}

.app-nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.app-nav-item:hover {
  background: var(--graphite-800);
  color: var(--white);
}

.app-nav-item.is-active {
  background: var(--graphite-800);
  color: var(--white);
}

.app-nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  translate: 0 -50%;
  width: 3px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--color-accent-on-dark);
}

.app-sidebar__footer {
  padding: var(--space-3);
  border-top: 1px solid var(--graphite-800);
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ *
 * TOPBAR
 * ------------------------------------------------------------------ */

.app-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-inline: var(--space-4);
}

.app-topbar__menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
}
.app-topbar__menu-btn:hover {
  background: var(--graphite-100);
}
.app-topbar__menu-btn svg {
  width: 22px;
  height: 22px;
}

.app-topbar__title {
  font: var(--text-h3);
  color: var(--color-text-primary);
  display: none;
}

.app-topbar__spacer {
  flex: 1;
}

.app-topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ------------------------------------------------------------------ *
 * MAIN CONTENT
 * ------------------------------------------------------------------ */

.app-main {
  min-width: 0;
  padding: var(--space-4) var(--space-4) calc(var(--space-16) + var(--space-4));
}

.app-page {
  max-width: var(--content-max-width);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* ------------------------------------------------------------------ *
 * MOBILE BOTTOM NAV — base breakpoint only
 * ------------------------------------------------------------------ */

.app-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--color-surface-dark);
  border-top: 1px solid var(--graphite-800);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  z-index: var(--z-sticky);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.app-bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  color: var(--graphite-400);
  font: var(--text-micro);
  text-transform: none;
  letter-spacing: normal;
}
.app-bottom-nav__item svg {
  width: 22px;
  height: 22px;
}
.app-bottom-nav__item.is-active {
  color: var(--white);
}

.app-bottom-nav__fab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: var(--white);
  margin: 0 auto;
  translate: 0 -14px;
  box-shadow: var(--shadow-lg);
}
.app-bottom-nav__fab svg {
  width: 24px;
  height: 24px;
}

/* ------------------------------------------------------------------ *
 * RESPONSIVE — sidebar becomes persistent, drawer chrome hides
 * ------------------------------------------------------------------ */

@media (min-width: 768px) {
  .app-bottom-nav {
    display: none;
  }
  .app-main {
    padding: var(--space-6) var(--space-6) var(--space-16);
  }
}

@media (min-width: 1024px) {
  .app-shell {
    grid-template-columns: var(--sidebar-width) 1fr;
  }
  .app-sidebar {
    position: sticky;
    transform: none;
    grid-column: 1;
  }
  .app-sidebar__backdrop {
    display: none !important;
  }
  .app-topbar__menu-btn {
    display: none;
  }
  .app-topbar__title {
    display: block;
  }
  .app-content {
    grid-column: 2;
    min-width: 0;
  }
  .app-main {
    padding: var(--space-8) var(--space-8) var(--space-16);
  }
}

@media (min-width: 1280px) {
  .app-main {
    padding-inline: var(--space-12);
  }
}

/* ------------------------------------------------------------------ *
 * MARKETING (index.html) SHELL — separate from the app shell
 * ------------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--graphite-800);
}

.site-header__inner {
  max-width: var(--content-max-width);
  margin-inline: auto;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-8);
}
