/* ========================================================================
 * organisms.css — major composed sections + page templates
 *
 * Per docs/superpowers/specs/2026-05-08-atomic-design-system.md §5 + §6.
 *
 * Routing guide (organism inventory §5 + template §6):
 *  - Sidebar:           .sidebar, .nav-item (+ active/hover)
 *  - MobileTopbar:      .mob-topbar, .mob-hamburger, .mob-overlay
 *  - SectionShell:      .section, .topbar (template DashboardShell §6.2)
 *  - LoginShell parts:  .top-nav, .top-logo-mark, .login-mark,
 *                       .top-logo-text, .login-wrap, .login-logo,
 *                       .login-wordmark, .login-tagline (AuthShell §6.1)
 *  - RestaurantSelect:  .rest-wrap, .rest-header (lives with AuthShell)
 *  - FAB:               #quick-add-fab
 *  - MobileShell:       @media (max-width: 768px) responsive overrides
 *                       (template MobileShell §6.5)
 * ======================================================================== */

/* ── Top-nav (login / restaurant-select header) ─────────── */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 20px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
}
.top-logo-mark { display: none; }
.login-mark { display: none; }
.top-logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-family: var(--font-display);
  color: var(--text);
}

/* ── Login wrap (centered card) ─────────────────────────── */
.login-wrap { width: 100%; max-width: 420px; padding: 20px; }
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-bottom: 40px;
}
.login-wordmark {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-family: var(--font-display);
  color: var(--text);
}
.login-tagline {
  color: rgba(255,255,255,0.3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── Restaurant select shell ────────────────────────────── */
.rest-wrap { width: 100%; max-width: 820px; padding: 40px 20px; }
.rest-header h1 {
  color: white;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  font-family: var(--font-display);
}
.rest-header p {
  color: #505058;
  font-size: 14px;
  margin-bottom: 32px;
  line-height: 1.5;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: 236px;
  height: 100vh;
  background: var(--sidebar);
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.045);
  transition: transform 0.25s ease;
}
.main { margin-left: 0; min-height: 0; background: var(--bg); }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8.5px 14px;
  border-radius: 9px;
  cursor: pointer;
  color: #6C6C70;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s;
  margin: 1px 10px;
  letter-spacing: -0.005em;
}
.nav-item:hover { background: var(--sidebar-hover); color: #AEAEB2; }
.nav-item.active { background: rgba(232,183,66,0.13); color: var(--gold); font-weight: 600; }

/* ── Mobile topbar / overlay ────────────────────────────── */
.mob-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: 54px;
  background: var(--sidebar);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
.mob-topbar .mob-logo {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  flex: 1;
}
.mob-hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mob-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
}
.mob-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 39;
}
.mob-overlay.visible { display: block; }

/* ── Section + topbar (DashboardShell template) ─────────── */
.section {
  display: none;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  margin-left: 236px;
}
.section.active { display: block; }
.topbar {
  background: rgba(23,27,38,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 13px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

/* ── Quick-Add FAB ──────────────────────────────────────── */
#quick-add-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 54px;
  height: 54px;
  background: var(--gold);
  border: none;
  border-radius: 99px;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(232,183,66,0.5);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
#quick-add-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 36px rgba(232,183,66,0.6);
}

/* ========================================================================
 * MobileShell template — responsive overrides under 768px wide
 * ======================================================================== */
@media (max-width: 768px) {
  /* Mobile top bar */
  .mob-topbar { display: flex; }
  .mob-overlay { display: none; }
  .mob-overlay.visible { display: block; }

  /* Sidebar slide-in */
  .sidebar {
    transform: translateX(-100%);
    top: 0;
    z-index: 45;
    height: 100vh;
    overflow-y: auto;
  }
  .sidebar.mob-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,0.5);
  }

  /* Main content */
  .main { margin-left: 0 !important; padding-top: 0 !important; min-height: 0 !important; }
  /* Sections: remove desktop sidebar offset, add mob-topbar clearance */
  .section { margin-left: 0 !important; padding-top: 54px !important; }
  .topbar { display: none !important; }

  /* Restaurant selector screen */
  .screen-dark {
    align-items: flex-start;
    padding-top: 70px;
    overflow-y: auto;
    min-height: 100vh;
  }
  .rest-wrap { padding: 16px; max-width: 100%; }
  .rest-header h1 { font-size: 22px; }
  .rest-grid { grid-template-columns: 1fr !important; gap: 12px; }

  /* Login */
  .login-wrap { padding: 16px; }
  .login-card { padding: 24px 20px; }
  .login-wordmark { font-size: 28px; }

  /* Section padding */
  .section { padding: 0; }
  .section-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 16px;
  }
  .section-header > div:last-child { align-self: flex-start; }
  .section-title { font-size: 17px !important; }
  div[style*="padding:28px 32px"]  { padding: 16px !important; }
  div[style*="padding: 28px 32px"] { padding: 16px !important; }
  div[style*="padding:24px 32px"]  { padding: 16px !important; }
  div[style*="padding: 24px 32px"] { padding: 16px !important; }
  div[style*="padding:32px"]       { padding: 16px !important; }

  /* KPIs */
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .kpi { padding: 14px 16px !important; }
  .kpi-value { font-size: 1.4rem !important; }
  .value-number { font-size: 1.9rem !important; }

  /* Grids: collapse multi-col to 1 or 2 col */
  .chart-grid { grid-template-columns: 1fr !important; }
  .bottom-grid { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns:repeat(4"]  { grid-template-columns: repeat(2,1fr) !important; }
  div[style*="grid-template-columns: repeat(4"] { grid-template-columns: repeat(2,1fr) !important; }
  div[style*="grid-template-columns:repeat(3"]  { grid-template-columns: repeat(1,1fr) !important; }
  div[style*="grid-template-columns: repeat(3"] { grid-template-columns: repeat(1,1fr) !important; }
  div[style*="grid-template-columns:repeat(2"]  { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns: repeat(2"] { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns:1fr 1fr"]   { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns: 1fr 1fr"]  { grid-template-columns: 1fr !important; }

  /* Savings banner + alerts */
  .savings-banner { flex-direction: column; gap: 14px; padding: 16px !important; }
  .alert-strip { flex-direction: column; }
  .alert-pill { min-width: 0; }

  /* Tables: horizontal scroll */
  .card { overflow: visible; }
  div[style*="overflow-x:auto"], div[style*="overflow-x: auto"] { -webkit-overflow-scrolling: touch; }
  table { font-size: 11px; min-width: 480px; }
  th, td { padding: 8px 9px; white-space: nowrap; }

  /* Cards */
  .card { border-radius: 10px; }

  /* Filter rows */
  .filter-row { gap: 4px; }
  .filter-btn { font-size: 11.5px; padding: 5px 10px; }

  /* Bottom nav / FAB */
  #quick-add-fab { bottom: 20px; right: 20px; width: 48px; height: 48px; font-size: 22px; }

  /* Hide period badge on mobile topbar */
  .period-badge { display: none; }

  /* Topbar section header on mobile */
  .section > div:first-child { padding: 12px 16px !important; }
}
