/* ============================================
   NetPilot — CSS Responsive + PWA Mobile
   ============================================ */

:root {
  --nav-w: 220px;
  --hamburger-h: 56px;
}

/* ── Hamburger button ───────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: var(--hamburger-h);
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  align-items: center;
  padding: 0 1rem;
  z-index: 200;
  gap: 12px;
}
.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.25s;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.hamburger-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}
.hamburger-title span { color: var(--primary); }
.hamburger-save { margin-left: auto; font-size: 11px; }

/* ── Overlay ────────────────────────────────── */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 150;
}
.nav-overlay.visible { display: block; }

/* ══════════════════════════════════════════════
   MOBILE (≤ 768px)
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Affiche le hamburger */
  .hamburger { display: flex; }

  /* Décale le contenu sous la barre */
  body { padding-top: var(--hamburger-h) !important; }
  main {
    margin-left: 0 !important;
    padding: .85rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Nav en drawer latéral */
  nav.sidebar {
    position: fixed !important;
    top: 0 !important; left: 0 !important;
    width: 260px !important;
    height: 100vh !important;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 175 !important;
    overflow-y: auto;
  }
  nav.sidebar.open { transform: translateX(0); }

  /* Cards */
  .card { border-radius: 8px !important; }

  /* Tableaux → scroll horizontal */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* Kanban tâches (3 cols → 1 col) */
  .kanban {
    grid-template-columns: 1fr !important;
  }
  .col-wrap {
    min-width: unset !important;
    width: 100% !important;
  }

  /* Propriétés fiche projet */
  .prop-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Finances config */
  .fin-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Checklist → 1 colonne */
  .ck-grid {
    grid-template-columns: 1fr !important;
  }

  /* Toolbar (filtres) */
  .toolbar {
    flex-direction: column !important;
    gap: 8px !important;
    align-items: stretch !important;
  }
  .toolbar input[type=text],
  .toolbar select { width: 100% !important; }

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

  /* Calcul finances (2 cols sur mobile) */
  #calcFin > div {
    grid-template-columns: 1fr !important;
  }
  #calcFin > div > div > div {
    grid-template-columns: 1fr 1fr 1fr !important;
  }

  /* Dashboard stats (2×2 sur mobile) */
  #statsGrid, .grid-4 {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Calendrier dashboard */
  #weekCalGrid > div {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Heures — formulaire en colonne */
  .add-form, .form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Titres */
  h2 { font-size: 16px !important; }

  /* Save footer */
  .save-footer { padding: .4rem .75rem !important; }
  .save-footer-ind { font-size: 11px !important; }
}

/* ── Très petit écran (iPhone SE) ───────────── */
@media (max-width: 380px) {
  main { padding: .65rem !important; }
  .prop-grid { grid-template-columns: 1fr !important; }
  .fin-grid  { grid-template-columns: 1fr !important; }
}

/* ── PWA standalone (plein écran installée) ─── */
@media (display-mode: standalone) {
  body {
    padding-top: calc(var(--hamburger-h) + env(safe-area-inset-top)) !important;
  }
  .hamburger {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--hamburger-h) + env(safe-area-inset-top));
  }
}
