/* ============================================
   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) {

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

  /* Décale le contenu */
  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); }

  /* ── Dashboard ─────────────────────────────── */
  /* Header greeting + météo + boutons rapides */
  main > div:first-child {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }
  #meteoWidget {
    width: 100% !important;
    min-width: unset !important;
    justify-content: space-between;
  }
  .quick-actions {
    width: 100% !important;
    justify-content: stretch !important;
  }
  .quick-actions .btn {
    flex: 1 !important;
    justify-content: center !important;
    font-size: 12px !important;
    padding: 7px 6px !important;
  }

  /* Graphiques : 1 par ligne sur mobile */
  .grid-charts {
    grid-template-columns: 1fr !important;
  }

  /* Blocs tâches dashboard : 1 colonne */
  .tasks-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Grilles génériques ─────────────────────── */
  .grid-2, .grid-3, .grid-4,
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Tableaux ───────────────────────────────── */
  .tbl-wrap, table {
    display: block !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Kanban ─────────────────────────────────── */
  .kanban { grid-template-columns: 1fr !important; }
  .col-wrap { min-width: unset !important; width: 100% !important; }

  /* ── Fiche projet ───────────────────────────── */
  .prop-grid { grid-template-columns: 1fr 1fr !important; }
  .ck-grid   { grid-template-columns: 1fr !important; }

  /* Checklist items : bouton croix toujours visible */
  .ck-del-btn { opacity: 1 !important; }

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

  /* ── Modaux : bottom sheet sur mobile ───────── */
  .modal-bg {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    overflow-y: auto !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)) !important;
  }
  /* Poignée visuelle en haut du modal */
  .modal::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border2);
    border-radius: 2px;
    margin: 0 auto .75rem;
  }

  /* Formulaires dans modaux → colonne */
  .form-grid, .modal-2col, .f-grid {
    grid-template-columns: 1fr !important;
  }
  .modal-full, .f-full { grid-column: 1 !important; }

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

  /* ── Contacts ───────────────────────────────── */
  .contact-row {
    grid-template-columns: 36px 1fr auto !important;
  }
  .c-infos { display: none !important; } /* masquer sur mobile — visible en détail */

  /* ── Heures ─────────────────────────────────── */
  .add-form { grid-template-columns: 1fr !important; }

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

  /* ── Notes rapides ──────────────────────────── */
  #quickNotes { min-height: 120px; }

  /* ── Capacité ───────────────────────────────── */
  .cap-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; }

  /* ── Bouton thème dans nav ──────────────────── */
  .theme-toggle-btn { font-size: 16px !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; }
  .quick-actions .btn { font-size: 11px !important; padding: 6px 4px !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));
  }
  main {
    padding-bottom: calc(.85rem + env(safe-area-inset-bottom)) !important;
  }
}
