/**
 * InstaPresse — Mobile responsive layer
 * Prévient le défilement horizontal parasite et adapte les tableaux en cartes.
 */

/* ── Containment global ───────────────────────────────────────────── */
html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: clip;
  max-width: 100%;
}

#app {
  overflow-x: clip;
  max-width: 100%;
}

/* Évite les débordements de la grille Bootstrap */
@media (max-width: 991.98px) {
  .container,
  .container-fluid {
    max-width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    overflow-x: clip;
  }

  .row {
    margin-left: -10px;
    margin-right: -10px;
  }

  .row > [class*="col-"] {
    padding-left: 10px;
    padding-right: 10px;
    min-width: 0;
  }
}

/* Médias et contenus larges */
img,
video,
iframe,
embed,
object,
svg,
canvas {
  max-width: 100%;
}

pre,
code {
  overflow-x: auto;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Hero décoratif — cercles hors écran */
.c-hero,
section.c-hero {
  overflow-x: clip;
}

/* Formulaires Forminator / WC */
.forminator-row,
.woocommerce form .form-row {
  margin-left: 0;
  margin-right: 0;
}

.forminator-col,
.woocommerce form .form-row {
  min-width: 0;
}

/* Slick : pas de débordement du track */
.slick-list {
  overflow: hidden;
}

.slick-slide {
  min-width: 0;
}

/* ── WooCommerce — tableaux Mon compte ──────────────────────────── */
@media (max-width: 767.98px) {
  .woocommerce-account .woocommerce-MyAccount-content,
  .woocommerce-account .account__content,
  .instapresse-account-dashboard {
    min-width: 0;
    max-width: 100%;
    overflow-x: clip;
  }

  .instapresse-account-dashboard__table-wrap {
    overflow-x: visible;
    margin-left: 0;
    margin-right: 0;
  }

  .woocommerce table.shop_table {
    display: block;
    width: 100%;
    min-width: 0 !important;
    border-spacing: 0;
  }

  .woocommerce table.shop_table thead {
    display: none;
  }

  .woocommerce table.shop_table tbody {
    display: block;
  }

  .woocommerce table.shop_table tbody tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
  }

  .woocommerce table.shop_table tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100% !important;
    padding: 0.65rem 1rem !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
    text-align: right !important;
    word-break: break-word;
    position: static !important;
    background: #fff !important;
  }

  .woocommerce table.shop_table tbody td:last-child {
    border-bottom: 0 !important;
  }

  /* Pseudo-bordures décoratives desktop */
  .woocommerce table.shop_table tbody td::before,
  .woocommerce table.shop_table tbody td:first-of-type::before,
  .woocommerce table.shop_table tbody td:last-of-type::before {
    display: none !important;
    content: none !important;
  }

  .woocommerce table.shop_table tbody td::after {
    content: attr(data-title);
    flex: 0 0 auto;
    max-width: 45%;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #888;
    text-align: left;
  }

  .woocommerce table.shop_table tbody td.woocommerce-orders-table__cell-order-actions {
    flex-direction: column;
    align-items: stretch;
    text-align: left !important;
  }

  .woocommerce table.shop_table tbody td.woocommerce-orders-table__cell-order-actions::after {
    margin-bottom: 0.35rem;
  }

  .woocommerce table.shop_table tbody td.woocommerce-orders-table__cell-order-actions .button,
  .woocommerce table.shop_table tbody td.woocommerce-orders-table__cell-order-actions .btn {
    margin: 0.25rem 0 0 !important;
    width: 100%;
    text-align: center;
  }

  .woocommerce-products-table tbody td::before {
    display: none !important;
  }

  .instapresse-orders-filters,
  .instapresse-dashboard-tabs .dashboard-tabs-navigation,
  .instaportail-invoice-filters,
  .instaportail-filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
  }

  .instapresse-orders-filters::-webkit-scrollbar,
  .instaportail-invoice-filters::-webkit-scrollbar {
    display: none;
  }

  .instapresse-orders-filters .orders-filter-btn,
  .instaportail-filter-btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

/* ── InstaPortail — tableaux empilés (cartes) ───────────────────── */
@media (max-width: 767.98px) {
  .instaportail-page,
  .instaportail-invoices-table,
  .instaportail-estimations-table,
  .instaportail-orders-table {
    max-width: 100%;
    overflow-x: clip;
  }

  .instaportail-table.instaportail-table--stacked {
    display: block;
    width: 100%;
    min-width: 0 !important;
    border: 0;
  }

  .instaportail-table.instaportail-table--stacked thead {
    display: none;
  }

  .instaportail-table.instaportail-table--stacked tbody {
    display: block;
  }

  .instaportail-table.instaportail-table--stacked tbody tr {
    display: block;
    margin-bottom: 0.85rem;
    padding: 0.85rem 1rem;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  }

  .instaportail-table.instaportail-table--stacked tbody tr:hover {
    background: #fff;
  }

  .instaportail-table.instaportail-table--stacked tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.4rem 0 !important;
    border: 0 !important;
    text-align: right !important;
    word-break: break-word;
    min-width: 0;
  }

  .instaportail-table.instaportail-table--stacked tbody td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 42%;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #888;
    text-align: left;
  }

  .instaportail-table.instaportail-table--stacked tbody td:empty {
    display: none;
  }

  .instaportail-table.instaportail-table--stacked .col-action,
  .instaportail-table.instaportail-table--stacked .instaportail-invoice-actions {
    flex-direction: column;
    align-items: stretch !important;
    text-align: left !important;
    padding-top: 0.65rem !important;
    margin-top: 0.35rem;
    border-top: 1px solid #eee !important;
  }

  .instaportail-table.instaportail-table--stacked .col-action::before,
  .instaportail-table.instaportail-table--stacked .instaportail-invoice-actions::before {
    margin-bottom: 0.35rem;
  }

  .instaportail-table.instaportail-table--stacked .button,
  .instaportail-table.instaportail-table--stacked .button--small,
  .instaportail-table.instaportail-table--stacked .button-small {
    display: block;
    width: 100%;
    margin: 0.25rem 0 0 !important;
    text-align: center;
  }

  .instaportail-header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .instaportail-header-actions .button {
    flex: 1 1 auto;
    text-align: center;
  }

  .instaportail-invoice-pay-table.instaportail-table--stacked tbody td:first-child {
    justify-content: flex-start;
  }

  .instaportail-invoice-pay-table.instaportail-table--stacked tbody td:first-child::before {
    display: none;
  }
}

/* Panier / checkout : empêcher débordement des tableaux */
@media (max-width: 767.98px) {
  .woocommerce-cart-form,
  .woocommerce-checkout,
  .woocommerce-order-details {
    overflow-x: clip;
    max-width: 100%;
  }
}
