/**
 * Gestock — mise en page native mobile (sans défilement horizontal de page).
 * Tableaux → cartes, toolbars empilées, conteneurs bornés à 100 %.
 */

@media (max-width: 992px) {
  html,
  body {
    overflow-x: hidden;
    max-width: 100%;
  }

  main,
  .admin-main-content {
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  /* Toolbars page (titre + boutons) */
  .gestock-page-toolbar {
    flex-direction: column;
    align-items: stretch !important;
  }

  .gestock-page-toolbar > h1,
  .gestock-page-toolbar > div:first-child {
    width: 100%;
  }

  .gestock-page-toolbar > a,
  .gestock-page-toolbar > button,
  .gestock-page-toolbar > form,
  .gestock-page-toolbar > .flex.items-center.gap-3,
  .gestock-page-toolbar > .flex.gap-3 {
    width: 100%;
    flex-wrap: wrap;
  }

  .gestock-page-toolbar .flex.items-center.gap-3 > a,
  .gestock-page-toolbar .flex.gap-3 > a {
    flex: 1 1 calc(50% - 0.375rem);
    justify-content: center;
  }

  /* Formulaires filtres */
  main form .flex-wrap > div,
  main form .flex.flex-wrap > div {
    flex: 1 1 100% !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  .min-w-\[280px\],
  .min-w-\[200px\],
  .min-w-\[140px\],
  .min-w-\[100px\],
  main .w-48,
  main .w-56 {
    min-width: 0 !important;
    width: 100% !important;
  }

  /* Listes horizontales (catégories) : scroll contenu, pas la page */
  main .overflow-x-auto:not(.gestock-table-wrap) {
    overscroll-behavior-x: contain;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  /* Tableaux → cartes empilées */
  .gestock-table-wrap,
  .admin-table-wrap {
    overflow-x: visible !important;
    max-width: 100%;
  }

  table,
  .gestock-native-table,
  .admin-body table {
    min-width: 0 !important;
    width: 100%;
  }

  .gestock-native-table thead,
  .admin-table--tenants thead {
    display: none;
  }

  .gestock-native-table tbody tr,
  .admin-table--tenants tbody tr.admin-tenant-row {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.875rem;
    padding: 0.75rem;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  }

  .gestock-native-table tbody tr td,
  .admin-table--tenants tbody tr.admin-tenant-row td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0 !important;
    border: none !important;
    white-space: normal !important;
  }

  .gestock-native-table tbody tr td::before,
  .admin-table--tenants tbody tr.admin-tenant-row td::before {
    content: attr(data-label);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    flex-shrink: 0;
    min-width: 5rem;
  }

  .gestock-native-table tbody tr td[colspan]::before {
    display: none;
  }

  .gestock-native-table tbody tr td[colspan] {
    display: block;
    text-align: center;
  }

  .gestock-native-table tbody tr td:last-child {
    flex-direction: column;
    align-items: stretch;
  }

  .gestock-native-table tbody tr td .flex.items-center.gap-2,
  .gestock-native-table tbody tr td .flex.items-center.gap-3 {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .gestock-native-table .whitespace-nowrap {
    white-space: normal !important;
  }

  /* Rapports : boutons export empilés */
  .gestock-page-toolbar .flex.items-center.gap-3 {
    flex-direction: column;
    align-items: stretch !important;
  }

  .gestock-page-toolbar .flex.items-center.gap-3 > * {
    width: 100%;
  }

  /* POS : colonne unique */
  main.h-\[calc\(100vh-73px\)\].flex {
    flex-direction: column !important;
    height: auto !important;
    min-height: calc(100vh - 4rem);
    overflow-x: hidden;
  }

  main.h-\[calc\(100vh-73px\)\] .w-\[400px\] {
    width: 100% !important;
    max-width: 100% !important;
    border-left: 0 !important;
    border-top: 1px solid #e5e7eb;
  }
}
