/* ============================================================
   PASSADU — App Shell Layout
   Structure: Header (60px) + [Sidebar | Main] + Bottom Nav (60px)
   ============================================================ */

/* ─── APP SHELL ROOT ─── */
html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
  margin: 0;
  padding: 0;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh; /* Dynamic viewport — accounts for mobile browser chrome */
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  background: var(--canvas);
  transition: background var(--t-med);
}

/* ─── APP HEADER (Fixed 60px) ─── */
.app-header {
  height: var(--header-h);
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 20;
  transition: background var(--t-med), border-color var(--t-med);
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark { color: var(--ink); flex-shrink: 0; }

.brand-wordmark {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--ink);
  transition: color var(--t-med);
}

.brand-badge {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: var(--surface-card);
  color: var(--primary);
  padding: 2px 7px;
  border-radius: var(--rounded-pill);
  border: 1px solid var(--hairline);
  transition: background var(--t-med), border-color var(--t-med);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Theme Toggle ── */
.theme-toggle-wrap {
  display: flex;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-pill);
  padding: 3px;
  gap: 2px;
  transition: background var(--t-med), border-color var(--t-med);
}

.theme-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border-radius: var(--rounded-pill);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--t-fast);
}

.theme-opt.active {
  background: var(--canvas);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(20, 20, 19, 0.08);
}

/* ── Icon Button ── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--rounded-md);
  cursor: pointer;
  transition: all var(--t-fast);
}

.icon-btn:hover {
  background: var(--surface-card);
  color: var(--ink);
}

/* ─── APP LAYOUT: Sidebar + Main ─── */
.app-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0; /* Firefox flexbox fix */
}

/* ─── SIDEBAR (desktop 768px+) ─── */
.app-sidebar {
  display: none;
  width: var(--sidebar-w);
  background: var(--canvas);
  border-right: 1px solid var(--hairline);
  padding: 20px 12px;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: none;
  transition: background var(--t-med), border-color var(--t-med);
}

.app-sidebar::-webkit-scrollbar { display: none; }

.sidebar-section { margin-bottom: 10px; }

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted-soft);
  padding: 4px 12px 6px;
  font-family: var(--font-sans);
}

.sidebar-nav-item {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--rounded-md);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--t-fast);
  border-left: 3px solid transparent;
}

.sidebar-nav-item:hover {
  background: var(--surface-card);
  color: var(--ink);
}

.sidebar-nav-item.active {
  background: var(--surface-card);
  color: var(--primary);
  border-left-color: var(--primary);
}

.sidebar-nav-item svg { flex-shrink: 0; }

.nav-item-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-item-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  transition: color var(--t-med);
}

.nav-item-sub {
  font-size: 11px;
  color: var(--muted-soft);
}

/* ─── MAIN CONTENT AREA ─── */
.app-main {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

/* ─── BOTTOM TAB NAV (mobile only) ─── */
.app-bottom-nav {
  height: var(--bottom-nav-h);
  background: var(--canvas);
  border-top: 1px solid var(--hairline);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  /* iPhone safe area for Home Indicator */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transition: background var(--t-med), border-color var(--t-med);
}

.bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--t-fast);
  min-height: 48px; /* Apple HIG touch target minimum */
  padding-bottom: 4px;
}

.bottom-tab svg { transition: stroke var(--t-fast); }

.bottom-tab.active {
  color: var(--primary);
}

.bottom-tab.active svg {
  stroke: var(--primary);
}

/* ─── RESPONSIVE: Sidebar on Desktop, Bottom Nav on Mobile ─── */
@media (min-width: 768px) {
  .app-sidebar   { display: flex; }
  .app-bottom-nav { display: none; }
}

/* ─── PWA Standalone Mode: Adjust safe areas ─── */
@media (display-mode: standalone) {
  .app-header {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  }
}
