/* responsive.css — CSS responsive global Zonify
   Injecté sur toutes les pages via zonify_app.py
   Couvre : login, dashboard, admin, carte, tarifs, 3D, legal
*/

/* ─── BASE MOBILE-FIRST ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

img, video, iframe { max-width: 100%; height: auto; }

/* ─── TABLETTE (max 1024px) ──────────────────────────────────────────────── */
@media (max-width: 1024px) {

  /* Dashboard — grille stats */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }

  /* Dashboard — grille communes */
  .communes-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Container général */
  .container {
    padding: 20px 16px !important;
    max-width: 100% !important;
  }
}

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

  /* ── LOGIN ── */
  .card {
    margin: 20px auto !important;
    padding: 28px 20px !important;
    width: calc(100% - 32px) !important;
    max-width: 420px !important;
  }

  /* ── NAV DASHBOARD ── */
  .nav-logo { font-size: 18px !important; }
  .nav-right {
    gap: 8px !important;
    flex-wrap: wrap !important;
  }
  .plan-badge { font-size: 11px !important; padding: 3px 8px !important; }
  .nav-logout { font-size: 12px !important; }

  /* ── DASHBOARD CONTAINER ── */
  .container {
    padding: 16px 12px !important;
  }

  /* ── STATS GRID ── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .stat-card {
    padding: 16px 12px !important;
  }
  .stat-number {
    font-size: 24px !important;
  }
  .stat-label {
    font-size: 11px !important;
  }

  /* ── BARRE DE RECHERCHE ── */
  .search-box {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .search-box input {
    width: 100% !important;
    font-size: 14px !important;
  }
  .search-btn {
    width: 100% !important;
    padding: 10px !important;
  }

  /* ── COMMUNES GRID ── */
  .communes-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .commune-card {
    padding: 14px !important;
  }

  /* ── SECTION TITLES ── */
  .section-title {
    font-size: 16px !important;
    margin: 20px 0 12px !important;
  }

  /* ── GREETING ── */
  .greeting {
    font-size: 14px !important;
  }

  /* ── ADMIN ── */
  .admin-grid,
  .admin-table-wrap {
    overflow-x: auto !important;
  }
  table {
    min-width: 600px;
    font-size: 12px !important;
  }
  .admin-header {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: flex-start !important;
  }

  /* ── CARTE ── */
  .carte-container,
  .carte-layout {
    flex-direction: column !important;
  }
  .carte-sidebar {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 40vh !important;
    overflow-y: auto !important;
    border-right: none !important;
    border-bottom: 1px solid #e5e7eb !important;
  }
  .carte-map {
    width: 100% !important;
    height: 55vh !important;
    min-height: 300px !important;
  }

  /* ── TARIFS ── */
  .tarifs-grid,
  .plans-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  .tarif-card,
  .plan-card {
    padding: 24px 20px !important;
  }

  /* ── LEGAL ── */
  .legal-container {
    padding: 24px 16px !important;
  }
  .legal-container h1 { font-size: 24px !important; }
  .legal-container h2 { font-size: 18px !important; }

  /* ── STUDIO 3D ── */
  .studio-layout {
    flex-direction: column !important;
  }
  .studio-toolbar {
    width: 100% !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    padding: 8px !important;
    border-right: none !important;
    border-bottom: 1px solid #e5e7eb !important;
  }
  .studio-canvas {
    width: 100% !important;
    height: 55vh !important;
  }
  .studio-panel {
    width: 100% !important;
    max-height: 35vh !important;
    overflow-y: auto !important;
  }

  /* ── BOUTONS GÉNÉRAUX ── */
  .btn, button[type="submit"] {
    width: 100% !important;
    padding: 12px !important;
    font-size: 14px !important;
  }

  /* ── FORMULAIRES ── */
  .form-group {
    margin-bottom: 14px !important;
  }
  input[type="text"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important; /* Évite le zoom auto sur iOS */
    padding: 10px 12px !important;
  }

  /* ── MODALS ── */
  .modal-content {
    width: calc(100% - 24px) !important;
    margin: 12px !important;
    padding: 20px 16px !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }

  /* ── ALERTES / NOTIFICATIONS ── */
  .alert-list,
  .notif-list {
    padding: 0 !important;
  }
  .alert-item {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 12px !important;
  }
}

/* ─── PETIT MOBILE (max 480px) ──────────────────────────────────────────── */
@media (max-width: 480px) {

  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .stat-number { font-size: 20px !important; }

  .commune-name { font-size: 14px !important; }
  .commune-insee { font-size: 11px !important; }

  /* Tables scrollables */
  .table-wrap { overflow-x: auto !important; }

  /* Cacher les éléments non essentiels */
  .hide-mobile { display: none !important; }
}

/* ─── UTILITAIRES RESPONSIVE ─────────────────────────────────────────────── */
.hide-mobile  { }
.hide-desktop { display: none; }

@media (max-width: 768px) {
  .hide-mobile  { display: none !important; }
  .hide-desktop { display: block !important; }
}

/* ─── PERFORMANCE — évite le flash de contenu non stylé ─────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 768px) {
  .bug-report-btn, [onclick*="bug"], button[style*="position:fixed"] {
    bottom: 80px !important;
  }
}

@media (max-width: 768px) {
  #bug-widget { display: none !important; }
}

@media (max-width: 768px) {
  .container table,
  .legal-container table,
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 12px !important;
  }
  table td, table th {
    padding: 8px 10px !important;
    white-space: normal;
    min-width: 80px;
  }
}
