/* ═══════════════════════════════════════════════════
   SN-SÉCURITÉ — Responsive Mobile (max 768px)
   ═══════════════════════════════════════════════════ */

/* ── Bouton hamburger (caché sur desktop) ── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: var(--card, #1a1f28);
  border: 1px solid var(--border2, rgba(255,255,255,0.06));
  border-radius: 8px;
  cursor: pointer;
  padding: 8px 7px;
  flex-shrink: 0;
  transition: border-color 0.2s;
}
.hamburger:hover { border-color: var(--border, rgba(200,151,58,0.15)); }
.hamburger span {
  display: block;
  height: 2px;
  background: var(--text2, #9aa3b2);
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* ── Overlay sombre derrière la sidebar ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1400;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

@media (max-width: 768px) {

  /* ── Hamburger visible ── */
  .hamburger { display: flex; }

  /* ── Sidebar : cachée par défaut, slide-in au tap ── */
  .sidebar {
    transform: translateX(-240px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1500; /* Au-dessus de Leaflet (~800-1000) */
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
  }

  /* ── Contenu principal — prend toute la largeur ── */
  .main { margin-left: 0 !important; }

  /* ── Topbar ── */
  .topbar {
    padding: 12px 14px !important;
    gap: 10px;
  }
  .topbar-title { font-size: 18px !important; }
  .topbar-right { gap: 8px; }
  .topbar-btn { padding: 6px 10px !important; font-size: 11px !important; }
  .back-btn { padding: 6px 10px !important; font-size: 11px !important; }

  /* ── Masquer certains boutons topbar sur petit écran ── */
  .topbar-btn.hide-mobile { display: none; }

  /* ── Content padding ── */
  .content { padding: 14px 12px !important; }

  /* ── KPI grid : 2 colonnes sur mobile ── */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .kpi-value { font-size: 28px !important; }

  /* ── Grilles 2 et 3 colonnes → 1 colonne ── */
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .grid-col { gap: 12px !important; }

  /* ── Stats row admin : 2 colonnes ── */
  .stats-row {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  /* ── Tabs admin : scroll horizontal si trop longs ── */
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; min-width: 90px; }

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

  /* ── Carte Leaflet : hauteur réduite pour ne pas bloquer la navigation ── */
  #map { height: 55vh !important; min-height: 300px; }

  /* ── Barre de stats carte ── */
  .stats-bar { flex-wrap: wrap; gap: 8px; }
  .stat-chip { font-size: 11px; padding: 6px 10px; }

  /* ── Bannière incidents : adapt mobile ── */
  #incidentAlertBanner {
    left: 0 !important;
    flex-wrap: wrap;
    padding: 10px 14px !important;
    gap: 8px !important;
  }
  #incidentAlertBanner .hide-mobile { display: none; }

  /* ── Toolbar admin (search + boutons) ── */
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .search-input { min-width: 0; }
  .btn-add { white-space: nowrap; }

  /* ── Modal : plein écran sur mobile ── */
  .modal-overlay { align-items: flex-end; }
  .modal {
    border-radius: 20px 20px 0 0 !important;
    max-width: 100% !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* ── Carte mini-dashboard (aperçu postes) ── */
  .map-wrap { height: 200px !important; }

  /* ── Barre recherche carte ── */
  .search-bar { flex-wrap: wrap; }
  .search-bar .filter-select { flex: 1; min-width: 120px; }

  /* ── Form row (2 colonnes → 1) ── */
  .form-row { grid-template-columns: 1fr !important; }

  /* ── Bar chart labels ── */
  .bar-label { width: 80px !important; font-size: 10px !important; }
}

/* ── Très petits écrans (< 380px) ── */
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr 1fr !important; }
  .kpi-value { font-size: 24px !important; }
  .stats-row { grid-template-columns: 1fr 1fr !important; }
  .topbar-title { font-size: 16px !important; }
}
