/* ─────────────────────────────────────────────────────────────
   Floating ☰ button — base styles (display:none = hidden on desktop)
   Must come BEFORE the mobile media query so the mobile
   display:flex rule (same specificity, later = wins) overrides it.
───────────────────────────────────────────────────────────── */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 210;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  background: var(--color-sidebar-bg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-md);
  line-height: 1;
  transition: background 0.15s;
}

.menu-toggle:hover {
  background: var(--color-primary);
}

/* Mobile overlay — hidden by default */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 199;
}

/* Mobile bottom nav — hidden by default */
.mobile-bottom-nav {
  display: none;
}

/* ── Desktop sidebar collapsed (≥ 769px) ── */
@media (min-width: 769px) {
  .sidebar {
    transition: transform 0.25s ease;
  }

  .main-content {
    transition: margin-left 0.25s ease;
  }

  body.sidebar-collapsed .sidebar {
    transform: translateX(-240px);
  }

  body.sidebar-collapsed .main-content {
    margin-left: 0;
  }

  /* Show floating ☰ when sidebar is collapsed on desktop */
  body.sidebar-collapsed .menu-toggle {
    display: flex;
  }

  /* Push the page header to the right so the floating ☰ doesn't overlap the title */
  body.sidebar-collapsed .content-header {
    padding-left: 60px;
  }
}

/* ── Tablet (≤ 1024px) ── */
@media (max-width: 1024px) {
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Mobile (≤ 768px) ── */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }

  /* Hide the floating ☰ button when the mobile sidebar is open */
  body.sidebar-open-mobile .menu-toggle {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
  }

  /* Sidebar: off-screen by default, slides in when .open */
  .sidebar {
    transform: translateX(-240px);
    transition: transform 0.25s ease;
    width: 240px;
    z-index: 205;
  }

  .sidebar.open {
    transform: none;
  }

  /* Show overlay when sidebar is open */
  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0;
    min-width: 0;
    overflow-x: hidden;
  }

  /* Space on left for the fixed ☰ button */
  .content-header {
    padding: 0 12px 0 56px;
  }

  .page-body {
    padding: 12px;
    overflow-x: hidden;
    padding-bottom: 80px; /* clear bottom nav */
  }

  /* Horizontal scroll for wide tables */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .stat-cards {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .toolbar-left,
  .toolbar-right {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .breakdown-grid {
    grid-template-columns: 1fr;
  }

  .section-card-body {
    padding: 14px;
  }

  /* ── Show floating ☰ on mobile (overrides the display:none above) ── */
  .menu-toggle {
    display: flex;
  }

  /* ── Mobile Bottom Navigation Bar ── */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--color-sidebar-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 150;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    transition: color 0.15s;
  }

  .mobile-nav-item span:first-child {
    font-size: 20px;
    line-height: 1;
  }

  .mobile-nav-item.active {
    color: var(--color-primary);
  }

  .mobile-nav-item:hover {
    color: #fff;
  }
}

/* ── Small Mobile (≤ 480px) ── */
@media (max-width: 480px) {
  .stat-cards {
    grid-template-columns: 1fr;
  }

  .modal {
    max-width: 100%;
  }

  .content-header h1 {
    font-size: var(--font-size-base);
  }
}
