/* responsive.css — couche mobile (<=640px) pour la console VelocitAI.
   Tout est gated dans la media query : le rendu desktop (>640px) est inchangé.
   Les nouveaux éléments (.m-topbar/.m-backdrop/.m-burger) sont masqués hors mobile.
   Les surcharges utilisent !important pour battre les style="" inline des templates. */

.m-topbar,
.m-backdrop,
.m-burger { display: none; }
.rl-cards { display: none; } /* desktop = table ; mobile bascule en cartes */

@media (max-width: 640px) {
  /* ---- Shell : la grille 232px+1fr passe en une colonne ---- */
  .shell-grid { display: block !important; }

  /* ---- Barre mobile (console client) + bouton burger ---- */
  .m-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 52px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 45;
  }
  .m-burger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 38px;
    height: 38px;
    padding: 9px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .m-burger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--fg);
    border-radius: 2px;
  }
  .m-topbar .m-brand {
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
  }

  /* ---- Sidebar -> tiroir off-canvas ---- */
  .app-sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    width: 264px !important;
    height: 100vh !important;
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  body.drawer-open .app-sidebar {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0, 0, 0, .18);
  }

  .m-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, .42);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }
  body.drawer-open .m-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  body.drawer-open { overflow: hidden; }

  /* ---- Header agence : compact, burger visible, liens repliés dans le tiroir ---- */
  .app-agency-header {
    padding: 12px 16px !important;
    gap: 10px !important;
    flex-wrap: wrap;
  }
  .app-agency-header nav { gap: 12px !important; }
  .app-agency-header nav a { display: none !important; }
  .app-agency-header nav > span:first-of-type { display: none !important; } /* séparateur vertical */

  /* ---- Contenu principal : padding réduit ---- */
  .app-main { padding: 16px 14px !important; }

  /* ---- Tableaux larges (grilles inline) : scroll horizontal, colonnes conservées ---- */
  .table-block { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .data-grid { min-width: 640px; }

  /* ---- Tableaux HTML natifs (pages legacy/Tailwind) : scroll horizontal ----
     responsive.css n'est chargé que sur la console + layout legacy + auth, donc
     cibler `table` est sans risque pour les pages publiques/onboarding. */
  table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ---- Grilles tuiles / champs / panneaux ---- */
  .grid-2,
  .grid-3 { grid-template-columns: 1fr !important; }   /* -> 1 colonne */
  .grid-4 { grid-template-columns: repeat(2, 1fr) !important; } /* -> 2 colonnes */

  /* ---- En-tête de page (titre + actions) : empilé ---- */
  .page-head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px;
  }
  .page-head > * { width: 100%; }

  /* ---- record-list : bascule table -> cartes <details> ---- */
  .rl-table { display: none; }
  .rl-cards { display: block; }
  .rl-card { border-bottom: 1px solid var(--muted); }
  .rl-card:last-child { border-bottom: 0; }
  .rl-summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
  .rl-summary::-webkit-details-marker { display: none; }
  .rl-summary-main { flex: 1; min-width: 0; }
  .rl-primary { font-size: 13.5px; font-weight: 500; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rl-meta { font-size: 11px; color: var(--fg-muted); margin-top: 2px; }
  .rl-status { flex-shrink: 0; }
  .rl-chevron { flex-shrink: 0; width: 8px; height: 8px; border-right: 2px solid var(--fg-muted); border-bottom: 2px solid var(--fg-muted); transform: rotate(45deg); transition: transform .2s ease; }
  .rl-card[open] .rl-chevron { transform: rotate(-135deg); }
  .rl-body { padding: 0 16px 14px; }
  .rl-field { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--muted); font-size: 13px; }
  .rl-label { color: var(--fg-muted); flex-shrink: 0; }
  .rl-value { color: var(--fg); text-align: right; min-width: 0; word-break: break-word; }
  .rl-action { margin-top: 12px; }
  .rl-action > * { width: 100% !important; box-sizing: border-box; }

  /* ---- KPI compacts (dashboard) : 3 mini-stats sur une ligne ---- */
  .kpi-compact { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
  .kpi-compact > div { padding: 10px 8px !important; text-align: center; }
  .kpi-compact .tile-value { font-size: 19px !important; margin-top: 2px !important; }
  .kpi-compact .tile-label { font-size: 9.5px !important; letter-spacing: 0.03em !important; }
  .kpi-compact .tile-foot { display: none !important; }

  /* ---- sections repliables (pages détail / réglages) ---- */
  details.m-section > summary { list-style: none; cursor: pointer; }
  details.m-section > summary::-webkit-details-marker { display: none; }
}
