/* ==========================================================================
   UPLIFTED — layout.css
   App shell: sidebar (desktop), bottom nav (mobile), header, page grid.
   ========================================================================== */

#app { min-height: 100vh; min-height: 100dvh; }

/* ---- Sidebar (desktop) ------------------------------------------------ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--side-bg);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  z-index: var(--z-nav);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-5) var(--space-5);
}

.sidebar-brand-mark {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, var(--accent-gold-bright), var(--accent-gold));
  display: flex; align-items: center; justify-content: center;
  color: var(--text-on-accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.sidebar-brand-word { font-weight: 600; font-size: var(--fs-md); letter-spacing: -0.01em; }
.sidebar-brand-sub { font-size: var(--fs-2xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  cursor: pointer;
  white-space: nowrap;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }

.nav-item:hover { background: var(--bg-surface-hover); color: var(--text-primary); }

.nav-item.active {
  background: var(--accent-gold-soft);
  color: var(--gold-t);
  border-left-color: var(--accent-gold);
}
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-glass);
}

/* ---- App shell / topbar ------------------------------------------------ */
.app-shell {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  background: var(--chrome-bg);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border-bottom: 1px solid var(--border-glass);
}

.topbar-title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-3); }

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-6);
  padding-bottom: var(--space-9);
}

/* ---- Grid system for dashboard-style pages ------------------------------------------------ */
.grid { display: grid; gap: var(--space-5); }
.grid > * { min-width: 0; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-main-side { grid-template-columns: 1.6fr 1fr; align-items: start; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.page-section { margin-top: var(--space-7); }
.page-section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.section-head h2 { font-size: var(--fs-md); font-weight: 600; }
.section-head a, .section-head button.link { font-size: var(--fs-xs); color: var(--blue-t); font-weight: 600; }

/* ---- Bottom nav (mobile) ------------------------------------------------ */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--chrome-bg);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border-top: 1px solid var(--border-glass);
  z-index: var(--z-nav);
  align-items: stretch;
  justify-content: space-around;
}

.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.bn-item svg { width: 21px; height: 21px; transition: transform var(--dur-fast) var(--ease-out); }
.bn-item.active { color: var(--gold-t); }
.bn-item.active svg { transform: translateY(-1px); }

/* ---- Responsive breakpoint: switch to mobile shell ------------------------------------------------ */
@media (max-width: 880px) {
  .sidebar { display: none; }
  .app-shell { margin-left: 0; }
  .app-main { padding: var(--space-4); padding-bottom: calc(var(--bottom-nav-h) + var(--space-8)); }
  .topbar { padding: 0 var(--space-4); }
  .bottom-nav { display: flex; }
  .grid-2, .grid-main-side, .grid-3 { grid-template-columns: 1fr; }

  /* Same button, same top-right spot as desktop — just icon-only to fit. */
  #addTxBtn.topbar-add-btn { padding: 10px; }
  #addTxBtn.topbar-add-btn .btn-label { display: none; }

  /* Smaller hero type + tighter card padding so large lakh/crore balances
     never clip against the card edge on narrow screens. */
  :root { --fs-hero: 2.25rem; }
  .hero-card { padding: var(--space-5) var(--space-5) var(--space-4); }

  /* Fewer/cheaper compositing passes on mobile GPUs: a slightly smaller blur
     radius across the many glass cards, and no fixed-attachment background
     (a well-known mobile Safari/Chrome scroll-jank source). */
  :root { --blur-glass: blur(12px); }
  body { background-attachment: scroll; }
}

@media (max-width: 560px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-stats > *:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (max-width: 380px) {
  /* Extra-small phones (e.g. iPhone SE, budget Android): shrink once more. */
  :root { --fs-hero: 1.9rem; }
}
