/* ═══════════════════════════════════════════════════════════
   FleetFlow — Responsive Layer
   Desktop (≥1024px): untouched — sidebar + topbar + ml-60
   Tablet (768–1023px): sidebar collapses, hamburger shows
   Mobile (<768px): bottom nav, stacked layout, touch-friendly
═══════════════════════════════════════════════════════════ */

/* ── Overlay backdrop for open sidebar on mobile ── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(3px);
  z-index: 29;
}
#sidebar-overlay.visible { display: block; }

/* ── Hamburger button (hidden on desktop) ── */
#hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #94a3b8;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
}
#hamburger:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ── Bottom navigation bar (mobile only) ── */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #0A1628;
  border-top: 1px solid rgba(255,255,255,0.07);
  z-index: 40;
  padding: 0 4px;
  align-items: center;
  justify-content: space-around;
  gap: 2px;
}
.bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: #475569;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .03em;
  transition: all .15s;
  min-width: 52px;
  cursor: pointer;
}
.bnav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.bnav-item.active { color: #60a5fa; }
.bnav-item.active svg { color: #60a5fa; }
.bnav-item:hover:not(.active) { color: #94a3b8; background: rgba(255,255,255,0.04); }

/* ── "More" menu sheet (mobile) ── */
#more-sheet {
  display: none;
  position: fixed;
  bottom: 60px;
  left: 0;
  right: 0;
  background: #0e1c30;
  border-top: 1px solid rgba(255,255,255,0.07);
  z-index: 45;
  padding: 12px 16px 16px;
  border-radius: 20px 20px 0 0;
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
#more-sheet.open { transform: translateY(0); display: block; }
.more-grid {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 8px;
  margin-top: 4px;
}
.more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 4px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: all .15s;
}
.more-item:hover { background: rgba(59,130,246,0.12); color: #60a5fa; border-color: rgba(59,130,246,0.25); }
.more-item svg { width: 22px; height: 22px; }
.more-handle {
  width: 40px; height: 4px; background: rgba(255,255,255,0.15);
  border-radius: 2px; margin: 0 auto 12px;
}

/* ════════════════════════════════════════════════════════════
   TABLET  768px – 1023px
   Sidebar: hidden by default, slides in as drawer
════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  /* Sidebar becomes a slide-in drawer */
  aside#sidebar {
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 50;
  }
  aside#sidebar.open { transform: translateX(0); }

  /* Header: spans full width */
  header#topbar {
    left: 0 !important;
  }

  /* Main: no left margin */
  main#main-content {
    margin-left: 0 !important;
  }

  /* Show hamburger */
  #hamburger { display: flex; }

  /* Hide search on tablet header */
  #header-search { display: none; }
}

/* ════════════════════════════════════════════════════════════
   MOBILE  < 768px
════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  /* Show bottom nav, add bottom padding to main */
  #bottom-nav { display: flex; }
  main#main-content { padding-bottom: 68px !important; }

  /* Main padding tighter */
  main#main-content > div { padding: 14px 12px !important; }

  /* KPI cards: 2 columns on mobile */
  .kpi-card-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .kpi-card { padding: 14px !important; }
  .kpi-card .text-3xl { font-size: 1.4rem !important; }

  /* Charts: stack to single column */
  .chart-grid { grid-template-columns: 1fr !important; }
  .col-span-2 { grid-column: span 1 !important; }

  /* Bottom row: stack */
  .bottom-grid { grid-template-columns: 1fr !important; }

  /* Fleet grid: single column */
  #fleet-grid {
    grid-template-columns: 1fr !important;
  }

  /* Table overflow: horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { min-width: 560px; }

  /* Reservation calendar strip: scroll */
  .cal-grid { overflow-x: auto; }

  /* Tabs: scroll horizontally */
  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    scrollbar-width: none;
  }
  .tab-bar::-webkit-scrollbar { display: none; }

  /* Modals: full screen on mobile */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 20px 20px 0 0 !important;
    max-width: 100% !important;
    max-height: 92vh;
  }
  .modal-xl { max-width: 100% !important; }

  /* Header: compact */
  #topbar-title { font-size: 14px !important; }
  #topbar-sub { display: none; }

  /* Checkout/checkin: grid → single col */
  .checkout-grid { grid-template-columns: 1fr !important; }
  .co-summary-sticky { position: static !important; }

  /* Reports KPI row: 2 cols */
  .reports-kpi { grid-template-columns: 1fr 1fr !important; }
  .reports-charts { grid-template-columns: 1fr !important; }

  /* Customers/contracts table: hide less important cols */
  .hide-mobile { display: none !important; }

  /* Expenses summary: 2×2 grid */
  .exp-summary { grid-template-columns: 1fr 1fr !important; }
  .exp-main { grid-template-columns: 1fr !important; }

  /* Fleet cards: adjust image height */
  .vcard-img { height: 140px !important; }

  /* Typography adjustments */
  h2.page-title { font-size: 18px !important; }

  /* Buttons: full width in forms */
  .mobile-full { width: 100% !important; justify-content: center; }

  /* Fuel selector: fit on small screens */
  #fuel-selector, #ci-fuel-sel {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Step indicator: compact on mobile */
  .step-text { display: none; }
  .step-divider { max-width: 20px !important; }
}

/* ════════════════════════════════════════════════════════════
   SMALL MOBILE  < 400px
════════════════════════════════════════════════════════════ */
@media (max-width: 399px) {
  .kpi-card-grid { grid-template-columns: 1fr !important; }
  .bnav-label { display: none; }
  .bnav-item { min-width: 44px; }
  .more-grid { grid-template-columns: repeat(3,1fr) !important; }
}
