/* ============================================================
   SwaamLab Responsive Breakpoints & Adaptive Layout
   Audited for 360px, 390px, 430px, 768px, 1024px, 1280px, 1440px, 1920px
   ============================================================ */

/* Global safety against horizontal overflow */
html, body {
  overflow-x: hidden;
  width: 100%;
}

img, svg, video, canvas, iframe {
  max-width: 100%;
}

/* ---------- Tablet / Smaller Screens (max 1023px) ---------- */
@media (max-width: 1023px) {
  .grid.kpi { grid-template-columns: repeat(2, 1fr); }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .content { padding: 1.15rem 1.15rem 5.5rem; }
}

/* ---------- Mobile Phone Breakpoint (320px - 767px) ---------- */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  
  .menu-btn {
    display: inline-flex;
  }
  
  .topbar {
    padding: 0 1rem;
    height: 58px;
  }
  .topbar h1 {
    font-size: 16px;
  }

  .content {
    padding: 1rem 0.85rem 6.5rem;
  }

  .grid.kpi {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }
  .kpi-card {
    padding: 0.95rem 1rem;
  }
  .kpi-value {
    font-size: 20px;
  }

  .trip-banner {
    padding: 1rem 1.1rem;
    gap: 0.85rem;
  }
  .trip-title {
    font-size: 17px;
  }

  .bar-row {
    grid-template-columns: 105px 1fr 75px;
    font-size: 12px;
  }

  .btn {
    min-height: 44px; /* touch standard */
  }

  /* Sticky Form Actions positioned safely above mobile bottom nav */
  .form-actions {
    position: sticky;
    bottom: 64px;
    padding: 0.75rem 0;
  }

  /* Mobile Bottom Navigation Bar */
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  }

  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0.35rem 0.15rem;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.12s ease;
  }

  .bottom-nav a:hover,
  .bottom-nav a.active {
    color: var(--accent);
    text-decoration: none;
  }

  .bottom-nav a.active {
    font-weight: 600;
  }

  .bottom-nav .nav-add-btn {
    color: var(--accent);
    font-weight: 600;
  }

  #toasts {
    bottom: 84px;
    right: 16px;
    left: 16px;
    width: auto;
  }

  /* Drawer Navigation & Backdrop Scrim */
  .drawer {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 320px);
    background: var(--surface);
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
  }

  .drawer.open {
    transform: translateX(0);
  }

  .scrim {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 90;
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .scrim.open {
    display: block;
    opacity: 1;
  }
}

/* Extra small devices (360px - 380px) */
@media (max-width: 380px) {
  .grid.kpi {
    grid-template-columns: 1fr;
  }
  .content {
    padding: 0.85rem 0.65rem 6.5rem;
  }
}

/* Medium Devices / Tablets (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar { width: 220px; }
  .main { margin-left: 220px; }
  .grid.kpi { grid-template-columns: repeat(2, 1fr); }
}

/* Desktop Devices (1024px+) */
@media (min-width: 1024px) {
  .drawer, .scrim { display: none !important; }
}

/* Large Desktop Displays (1440px+) */
@media (min-width: 1440px) {
  .content { max-width: 1320px; }
}

/* Ultra-wide Monitors (1920px+) */
@media (min-width: 1920px) {
  .content { max-width: 1480px; }
}
