/* Adaptations aux petits écrans, tous domaines confondus. Chargé par TOUTES les pages,
   en DERNIER : ces règles surchargent celles des feuilles précédentes (base.html). */

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1024px) {
  .container {
    padding: 24px;
  }

  .preview-img {
    max-width: 100%;
    height: auto;
  }

  .recap-table,
  .compare-table {
    font-size: 0.92em;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .scan-card {
    grid-template-columns: 1fr;
  }

  .scan-photo {
    width: 100%;
    max-width: var(--photo-size);
    height: auto;
    margin: 0 auto;
  }

  .scan-trash {
    margin-top: 0;
  }

  .risk-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .home-nav {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

@media (max-width: 640px) {
  /* Le corps de texte ne rétrécit plus sous 640 px : la webview du poste
     tombait pile sur ce seuil selon la barre de défilement, et la police
     passait de 17,5 à 16 px d'une commande à l'autre. */
  .container {
    width: 100%;
    margin: 0;
    border-radius: 0;
    padding: 70px 14px 28px;
    border-left: 0;
    border-right: 0;
  }

  .container.glass {
    border-radius: 0;
  }

  h1 {
    font-size: 1.45rem;
    margin-bottom: 1em;
  }

  h2,
  .card-title {
    font-size: 1.08em;
  }

  .gear-btn,
  .logout-btn {
    /* Pas de réduction sous --tap-min : l'écran étroit est justement celui
       où l'on touche, jamais celui où l'on clique. Seule la marge se resserre. */
    top: 12px;
  }

  .gear-btn { right: 12px; }
  .logout-btn { right: 68px; }

  .preview-img {
    max-width: 95vw;
  }

  .hist-row {
    flex-direction: row;
    gap: 12px;
    padding: 12px;
  }

  .hist-img img {
    width: 64px;
    height: 64px;
  }

  .lavage-card,
  .lavage-hist {
    font-size: 0.97em;
  }

  .btn,
  .btn-secondary,
  .btn-danger,
  .btn-success,
  .order-validate-btn {
    width: 100%;
    text-align: center;
  }

  .hist-link {
    display: inline-flex;
    justify-content: center;
    margin-top: 16px;
  }

  table.recap-table th,
  table.recap-table td,
  table.compare-table th,
  table.compare-table td {
    padding: 7px 8px;
    font-size: 0.9em;
  }

  .compare-table thead {
    display: none;
  }

  .compare-table tr {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 8px;
  }

  .compare-table td:first-child {
    font-weight: 700;
  }

  .compare-table td:last-child {
    opacity: 0.85;
  }

  .analysis-layout {
    flex-direction: column;
    align-items: center;
  }

  .preview-col,
  .result-col {
    width: 100%;
    flex: none;
  }

  .preview-col .preview-img {
    max-width: min(100%, var(--photo-size));
    max-height: none;
  }

  .result-col .banner,
  .analysis-layout:not(.details-open) .result-col {
    height: auto;
  }

  .quick-summary-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .corr-row {
    flex-direction: column;
  }

  .corr-field {
    flex-direction: column;
    align-items: stretch;
  }

  .corr-field label {
    min-width: 0;
  }

  .page-links {
    margin: 20px 0 0;
    gap: 8px;
  }

  .page-links .hist-link {
    padding: 9px 14px;
    font-size: 0.9em;
  }

  .garment-card-top {
    grid-template-columns: 1fr;
  }

  .garment-thumb {
    width: 100%;
    max-width: none;
    height: 200px;
  }

  /* La vignette « zones suspectes » suit la photo qu'elle remplace. */
  .garment-thumb-wrap {
    width: 100%;
  }

  .garment-summary {
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 4px 10px;
  }

  .current-order-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .home-nav {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .home-nav-card {
    padding: 14px;
    min-height: 96px;
  }

  .home-nav-icon {
    width: 38px;
    height: 38px;
    font-size: 1.3em;
  }

  .home-nav-title {
    font-size: 0.96em;
  }

  .home-nav-desc {
    font-size: 0.82em;
  }

  .container.glass.history-container {
    height: 100vh;
    min-height: 100vh;
    padding: 70px 14px 24px !important;
  }

  .connexion-card {
    padding: 28px 22px;
  }

  .num-btn {
    padding: 14px 0;
    font-size: 1.35em;
    min-height: 50px;
  }

  .numeric-pad-grid {
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    max-width: 320px;
  }

  .modal-content,
  .signalement-modal-content {
    padding: 20px;
    border-radius: var(--radius-lg);
  }
}

@media (max-width: 380px) {
  .home-nav {
    grid-template-columns: 1fr;
  }
}
