/* ============================================================
   LAYOUT.CSS
   The app shell: sidebar, topbar, content area, and how it
   collapses on mobile. Page-specific inner layout belongs in
   assets/css/pages/<page>.css, not here.
   ============================================================ */

/* ---------- App shell wrapper ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar (desktop) ---------- */
.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-5) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.app-sidebar .brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2) var(--space-5);
  font-weight: 700;
  font-size: var(--fs-lg);
  color: var(--color-text);
}
.app-sidebar .brand img { color: var(--color-brand); width: 2rem; height: 2.2rem; }

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.nav-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; }
.nav-link:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
  text-decoration: none;
}
.nav-link.active {
  background: var(--color-brand-light);
  color: var(--color-brand-dark);
}

.nav-section-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-faint);
  padding: var(--space-4) var(--space-3) var(--space-1);
}

/* ---------- Topbar ---------- */
.app-topbar {
  height: var(--topbar-height);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-mobile-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--color-text);
}

/* ---------- Main content ---------- */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-content {
  padding: var(--space-5);
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

/* ---------- Mobile bottom nav (hidden on desktop) ---------- */
.app-bottomnav {
  display: none;
}

/* ============================================================
   RESPONSIVE: below 992px the sidebar becomes an off-canvas
   panel, and a 5-icon bottom bar takes over primary navigation.
   ============================================================ */
@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }
  .app-sidebar.is-open {
    transform: translateX(0);
  }

  .app-mobile-toggle { display: inline-flex; }

  .app-content { padding: var(--space-4); padding-bottom: 84px; }

  .app-bottomnav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    z-index: 30;
  }
  .app-bottomnav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.65rem;
    color: var(--color-text-muted);
  }
  .app-bottomnav a.active { color: var(--color-brand); }
  .app-bottomnav i { font-size: 1.2rem; }
}

/* Backdrop shown behind the off-canvas sidebar on mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 24, 0.35);
  z-index: 35;
}
.sidebar-backdrop.is-open { display: block; }
