/* ============================================================
   App shell layout — header, sidebar (desktop), bottom nav (mobile)
   ============================================================ */

/* ---- Top app bar ---- */
.topbar {
  position: sticky; top: 0;
  z-index: var(--z-header);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
}
.topbar--gradient { background: var(--gradient-dark); border-bottom: none; color: #fff; }
.topbar--gradient .topbar__greeting span { color: rgba(255, 255, 255, 0.8); }
.topbar__brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.topbar__logo { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; }
.topbar__greeting { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.topbar__greeting strong { font-size: var(--fs-sm); font-weight: 600; }
.topbar__greeting span { font-size: var(--fs-xs); color: var(--color-text-hint); }
.topbar__title { font-size: var(--fs-lg); font-weight: 700; }
.topbar__actions { display: flex; align-items: center; gap: var(--space-1); }
.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 20px;
  color: var(--color-text-secondary);
  transition: background var(--dur-fast);
}
.icon-btn:hover { background: var(--color-background); }
.topbar--gradient .icon-btn { color: #fff; }

/* ---- Sub-page header (gradient bar with back arrow, e.g. Airtime/Data pages) ---- */
.page-header {
  background: var(--gradient-dark);
  color: #fff;
  padding: var(--space-2) var(--space-4) var(--space-6);
}
.page-header__row { display: flex; align-items: center; gap: var(--space-2); }
.page-header__title { font-size: var(--fs-2xl); font-weight: 700; }
.page-header__subtitle { font-size: var(--fs-sm); color: rgba(255, 255, 255, 0.65); margin-top: 2px; }

/* ---- Page body ---- */
.page-body {
  padding: var(--space-4);
  /* Must clear the bottom nav's full rendered height, including the safe-area
     inset it adds on notched phones (see .bottom-nav) — not just the base 64px. */
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0) + var(--space-6));
  max-width: 640px;
  margin-inline: auto;
  width: 100%;
}
.page-body--wide { max-width: var(--content-max-width); }

/* ---- Bottom navigation (mobile) ---- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: var(--z-nav);
  display: flex;
  background: var(--color-surface);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.08);
  /* box-sizing is border-box globally, so padding-bottom below would eat
     into the icon/label content area on a notched phone (safe-area-inset-bottom
     can be ~34px) unless the safe area is added on top of the content height
     here explicitly. */
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav__item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--color-text-hint);
  font-size: 10px;
  font-weight: 500;
}
.bottom-nav__item .icon { font-size: 21px; }
.bottom-nav__item.active { color: var(--color-primary); font-weight: 600; }

/* ---- Sidebar (desktop/tablet) ---- */
.sidebar {
  display: none;
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-divider);
  padding: var(--space-5) var(--space-3);
  overflow-y: auto;
  z-index: var(--z-nav);
}
.sidebar__brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3) var(--space-6); }
.sidebar__brand img { width: 34px; height: 34px; border-radius: 9px; }
.sidebar__brand strong { font-size: var(--fs-lg); }
.sidebar__item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--fs-md);
  font-weight: 500;
  margin-bottom: 2px;
}
.sidebar__item .icon { font-size: 20px; width: 22px; text-align: center; }
.sidebar__item:hover { background: var(--color-background); }
.sidebar__item.active { background: var(--color-icon-bg-alt); color: var(--color-primary); font-weight: 600; }
.sidebar__section-label { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; color: var(--color-text-hint); text-transform: uppercase; padding: var(--space-4) var(--space-3) var(--space-2); }

/* ---- Content shell wrapper for desktop 2/3-column dashboards ---- */
.dash-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

/* Horizontal scroller for service rows on narrow screens if the grid overflows */
.hscroll { display: flex; gap: var(--space-3); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.hscroll::-webkit-scrollbar { display: none; }
