/**
 * Module 11 : Fiche produit (single product)
 * Thème Storefront Child - TAMISIER MACHINES AGRICOLES
 *
 * Surcharge de woocommerce/content-single-product.php.
 * Reprend la charte du thème : conteneur 1280px, Playfair Display pour
 * les titres, palette --agri-*, rayons et espacements cohérents.
 */

/* ==========================================================================
   1. MISE EN PAGE GÉNÉRALE
   Le header du thème n'ouvre pas .col-full, donc Storefront applique
   encore .right-sidebar .content-area { width: 73.913% } : sans cette
   règle, la fiche laisserait une bande blanche de 26 % à droite.
   ========================================================================== */

.single-product .content-area,
.single-product #primary {
  width: 100% !important;
  float: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  max-width: none !important;
}

.single-product .widget-area {
  display: none !important;
}

.tma-product-container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
  box-sizing: border-box;
}

/* ==========================================================================
   2. FIL D'ARIANE
   ========================================================================== */

.tma-product-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--agri-anthracite-muted, #525c59);
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.tma-product-breadcrumb a {
  color: var(--agri-anthracite-muted, #525c59) !important;
  text-decoration: none !important;
  transition: color 0.15s ease;
}

.tma-product-breadcrumb a:hover {
  color: var(--agri-green-primary, #215833) !important;
}

.tma-product-breadcrumb-sep {
  color: var(--agri-border-subtle, #e2e8f0);
}

.tma-product-breadcrumb-current {
  color: var(--agri-anthracite-base, #1e2322);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 46ch;
}

/* ==========================================================================
   3. COLONNES : GALERIE / INFORMATIONS
   ========================================================================== */

.tma-product-main {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 3rem;
  align-items: start;
}

/* --- Galerie --- */

.tma-product-media .woocommerce-product-gallery {
  width: 100% !important;
  float: none !important;
  margin: 0 !important;
}

.tma-product-media .woocommerce-product-gallery__wrapper {
  border: 1px solid var(--agri-border-subtle, #e2e8f0);
  border-radius: var(--agri-radius, 4px);
  background-color: var(--agri-white, #ffffff);
  overflow: hidden;
  margin: 0 !important;
}

.tma-product-media .woocommerce-product-gallery__image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0 !important;
}

.tma-product-media .flex-control-thumbs {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 0.6rem;
  margin: 0.85rem 0 0 !important;
  padding: 0 !important;
}

.tma-product-media .flex-control-thumbs li {
  width: auto !important;
  float: none !important;
  margin: 0 !important;
}

.tma-product-media .flex-control-thumbs img {
  width: 100% !important;
  height: auto !important;
  border: 2px solid transparent !important;
  border-radius: var(--agri-radius, 4px) !important;
  opacity: 0.65;
  transition: opacity 0.15s ease, border-color 0.15s ease;
  padding: 0 !important;
}

.tma-product-media .flex-control-thumbs img:hover,
.tma-product-media .flex-control-thumbs img.flex-active {
  opacity: 1;
  border-color: var(--agri-green-primary, #215833) !important;
}

.tma-product-media .woocommerce-product-gallery__trigger {
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
}

.tma-product-media .onsale {
  background-color: var(--agri-amber-accent, #d97706) !important;
  color: #ffffff !important;
  border-radius: var(--agri-radius, 4px) !important;
  font-weight: 700 !important;
  padding: 0.4rem 0.75rem !important;
  line-height: 1.2 !important;
  min-height: 0 !important;
  min-width: 0 !important;
}

/* ==========================================================================
   4. COLONNE INFORMATIONS
   ========================================================================== */

.tma-product-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--agri-green-primary, #215833);
  margin: 0 0 0.6rem !important;
}

.tma-product-title {
  font-family: "Playfair Display", Georgia, serif !important;
  font-size: clamp(1.9rem, 3vw, 2.7rem) !important;
  line-height: 1.14 !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em !important;
  color: var(--agri-anthracite-base, #1e2322) !important;
  margin: 0 0 1rem !important;
}

/* --- Étiquettes vendeur / référence --- */

.tma-product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.35rem;
}

.tma-product-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--agri-anthracite-muted, #525c59);
  background-color: var(--agri-bg-neutral, #f8fafc);
  border: 1px solid var(--agri-border-subtle, #e2e8f0);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  line-height: 1.3;
}

.tma-product-tag strong {
  color: var(--agri-anthracite-base, #1e2322);
  font-weight: 700;
}

.tma-product-tag-vendor {
  background-color: var(--agri-green-subtle, #edf7f0);
  border-color: rgba(33, 88, 51, 0.18);
}

.tma-product-tag-vendor strong {
  color: var(--agri-green-primary, #215833);
}

/* --- Bloc achat --- */

.tma-product-buybox {
  background-color: var(--agri-white, #ffffff);
  border: 1px solid var(--agri-border-subtle, #e2e8f0);
  border-radius: var(--agri-radius, 4px);
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.tma-product-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tma-product-price .price,
.tma-product-price .woocommerce-Price-amount {
  font-size: 1.9rem !important;
  font-weight: 700 !important;
  color: var(--agri-amber-accent, #d97706) !important;
  display: block;
  line-height: 1.2;
  margin: 0 !important;
}

.tma-product-price del {
  font-size: 1rem !important;
  color: var(--agri-anthracite-muted, #525c59) !important;
  font-weight: 400 !important;
  margin-right: 0.5rem;
}

.tma-product-price ins {
  text-decoration: none !important;
}

.tma-product-stock {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 999px;
  padding: 0.32rem 0.8rem;
  white-space: nowrap;
}

.tma-product-stock::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: currentColor;
}

.tma-product-stock.is-available {
  color: var(--agri-green-primary, #215833);
  background-color: var(--agri-green-subtle, #edf7f0);
}

.tma-product-stock.is-unavailable {
  color: #92400e;
  background-color: var(--agri-amber-subtle, #fef3c7);
}

.tma-product-excerpt {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--agri-anthracite-surface, #2b3230);
  margin-bottom: 1.25rem;
}

.tma-product-excerpt p:last-child {
  margin-bottom: 0 !important;
}

/* --- Actions --- */

.tma-product-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.35rem;
}

.tma-product-cart form.cart {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
  margin: 0 !important;
  flex-wrap: wrap;
}

.tma-product-cart .quantity {
  display: inline-flex;
  margin: 0 !important;
}

.tma-product-cart .quantity .qty {
  width: 4.25rem;
  height: 100%;
  min-height: 46px;
  text-align: center;
  border: 1px solid var(--agri-border-subtle, #e2e8f0) !important;
  border-radius: var(--agri-radius, 4px) !important;
  background-color: var(--agri-white, #ffffff) !important;
  box-shadow: none !important;
  padding: 0 0.4rem !important;
  font-size: 1rem !important;
  color: var(--agri-anthracite-base, #1e2322) !important;
}

.tma-product-cart .single_add_to_cart_button {
  flex: 1 1 auto;
  min-height: 46px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.tma-product-cart .stock.out-of-stock {
  margin: 0 !important;
  width: 100%;
}

.tma-btn-outline {
  background-color: transparent !important;
  color: var(--agri-green-primary, #215833) !important;
  border: 1.5px solid var(--agri-green-primary, #215833) !important;
  box-shadow: none !important;
}

.tma-btn-outline:hover {
  background-color: var(--agri-green-subtle, #edf7f0) !important;
  color: var(--agri-green-dark, #163e23) !important;
  border-color: var(--agri-green-dark, #163e23) !important;
  transform: none !important;
}

.tma-product-quote {
  min-height: 46px;
  width: 100%;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 0.9rem !important;
}

/* --- Fiche synthétique --- */

.tma-product-facts {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border-top: 1px solid var(--agri-border-subtle, #e2e8f0);
}

.tma-product-facts li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--agri-border-subtle, #e2e8f0);
  margin: 0 !important;
  font-size: 0.88rem;
  line-height: 1.4;
}

.tma-product-facts li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.tma-product-fact-label {
  color: var(--agri-anthracite-muted, #525c59);
  flex: 0 0 auto;
}

.tma-product-fact-value {
  color: var(--agri-anthracite-base, #1e2322);
  font-weight: 600;
  text-align: right;
}

.tma-product-assist {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--agri-anthracite-muted, #525c59);
  margin: 1rem 0 0 !important;
  padding-left: 1rem;
  border-left: 2px solid var(--agri-green-light, #2e7a47);
}

/* ==========================================================================
   5. SECTIONS DESCRIPTIF / CARACTÉRISTIQUES
   ========================================================================== */

.tma-product-details {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  margin-top: 3rem;
}

.tma-product-section {
  background-color: var(--agri-white, #ffffff);
  border: 1px solid var(--agri-border-subtle, #e2e8f0);
  border-radius: var(--agri-radius, 4px);
  padding: 1.75rem;
}

.tma-product-section-title {
  font-family: "Playfair Display", Georgia, serif !important;
  font-size: 1.35rem !important;
  font-weight: 700 !important;
  color: var(--agri-anthracite-base, #1e2322) !important;
  margin: 0 0 1.25rem !important;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--agri-border-subtle, #e2e8f0);
  line-height: 1.25 !important;
}

.tma-product-desc {
  font-size: 0.97rem;
  line-height: 1.7;
  color: var(--agri-anthracite-surface, #2b3230);
}

.tma-product-desc p:last-child {
  margin-bottom: 0 !important;
}

/* Le tableau technique est déjà mis en forme par 04-tech-tables.css */
.tma-product-specs .object-table,
.tma-product-specs .product-fields-object-table {
  margin-top: 0 !important;
  border-radius: var(--agri-radius, 4px) !important;
}

/* ==========================================================================
   6. PRODUITS LIÉS
   ========================================================================== */

.tma-product .related.products,
.tma-product .upsells.products {
  margin-top: 3rem;
  padding-top: 0;
}

.tma-product .related.products > h2,
.tma-product .upsells.products > h2 {
  font-family: "Playfair Display", Georgia, serif !important;
  font-size: 1.35rem !important;
  font-weight: 700 !important;
  color: var(--agri-anthracite-base, #1e2322) !important;
  border-bottom: 2px solid var(--agri-border-subtle, #e2e8f0);
  padding-bottom: 0.85rem;
  margin: 0 0 1.75rem !important;
}

/* ==========================================================================
   7. RESPONSIVE
   ========================================================================== */

@media (max-width: 1024px) {
  .tma-product-main {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.75rem;
  }

  .tma-product-title {
    font-size: 1.95rem !important;
  }
}

@media (max-width: 768px) {
  .tma-product-container {
    padding: 1.25rem 1rem 3rem;
  }

  .tma-product-breadcrumb {
    font-size: 0.76rem;
    margin-bottom: 1.25rem;
  }

  .tma-product-breadcrumb-current {
    display: none;
  }

  .tma-product-buybox {
    padding: 1.15rem;
  }

  .tma-product-price .price,
  .tma-product-price .woocommerce-Price-amount {
    font-size: 1.55rem !important;
  }

  .tma-product-section {
    padding: 1.25rem;
  }

  .tma-product-media .flex-control-thumbs {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 0.45rem;
  }

  .tma-product-cart form.cart {
    flex-direction: column;
  }

  .tma-product-cart .quantity {
    width: 100%;
  }

  .tma-product-cart .quantity .qty {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .tma-product-title {
    font-size: 1.6rem !important;
  }

  .tma-product-price-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* ==========================================================================
   8. CARACTÉRISTIQUES CLÉS (bandeau chiffres)
   Bandeau unique à séparateurs fins : plus léger que quatre cartes grises,
   et le libellé au-dessus de la valeur reste aligné même si la valeur
   passe sur deux lignes (« 7430 E Premium »).
   ========================================================================== */

.tma-product-highlights {
  list-style: none !important;
  margin: 0 0 1.25rem !important;
  padding: 0 !important;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  background-color: var(--agri-white, #ffffff);
  border: 1px solid var(--agri-border-subtle, #e2e8f0);
  border-radius: var(--agri-radius, 4px);
  overflow: hidden;
}

.tma-product-highlight {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  margin: 0 !important;
  padding: 0.9rem 0.7rem;
  min-height: 78px;
  box-sizing: border-box;
  text-align: center;
  background-color: transparent;
  border: 0;
  border-right: 1px solid var(--agri-border-subtle, #e2e8f0);
  border-radius: 0;
}

.tma-product-highlight:last-child {
  border-right: 0;
}

/* Libellé au-dessus : la valeur reste solidaire de son intitulé. */
.tma-product-highlight-label {
  order: -1;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--agri-anthracite-muted, #525c59);
}

.tma-product-highlight-value {
  font-weight: 700;
  font-size: clamp(0.92rem, 1.35vw, 1.05rem);
  line-height: 1.25;
  color: var(--agri-anthracite-base, #1e2322);
  word-break: break-word;
  hyphens: auto;
}

/* Deux colonnes sur petit écran : on rétablit les séparations correctement. */
@media (max-width: 640px) {
  .tma-product-highlights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tma-product-highlight {
    border-right: 1px solid var(--agri-border-subtle, #e2e8f0);
  }

  .tma-product-highlight:nth-child(2n) {
    border-right: 0;
  }

  .tma-product-highlight:nth-child(-n + 2) {
    border-bottom: 1px solid var(--agri-border-subtle, #e2e8f0);
  }

  .tma-product-highlight:last-child {
    border-right: 0;
  }
}

/* ==========================================================================
   9. BANDEAU DE CONFIANCE
   ========================================================================== */

.tma-product-trust {
  list-style: none !important;
  margin: 0 !important;
  padding: 1.1rem 0 0 !important;
  border-top: 1px solid var(--agri-border-subtle, #e2e8f0);
  display: grid;
  gap: 0.45rem;
}

.tma-product-trust li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 !important;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--agri-anthracite-surface, #2b3230);
}

.tma-product-trust svg {
  flex: 0 0 auto;
  color: var(--agri-green-primary, #215833);
}

/* ==========================================================================
   10. BLOC VENDEUR
   ========================================================================== */

.tma-product-seller {
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background-color: var(--agri-white, #ffffff);
  border: 1px solid var(--agri-border-subtle, #e2e8f0);
  border-radius: var(--agri-radius, 4px);
}

.tma-product-seller-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.tma-product-seller-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  background-color: var(--agri-green-subtle, #edf7f0);
  color: var(--agri-green-primary, #215833);
}

.tma-product-seller-label {
  display: block;
  font-size: 0.68rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--agri-anthracite-muted, #525c59);
}

.tma-product-seller-name {
  display: block;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--agri-anthracite-base, #1e2322);
}

.tma-product-seller-link {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--agri-green-primary, #215833) !important;
  text-decoration: none !important;
  border-bottom: 1px solid currentColor;
  white-space: nowrap;
}

.tma-product-seller-link:hover {
  color: var(--agri-green-dark, #163e23) !important;
}

/* ==========================================================================
   11. GALERIE COLLANTE (DESKTOP) & BARRE CTA MOBILE
   ========================================================================== */

@media (min-width: 1025px) {
  .tma-product-media {
    position: sticky;
    top: 1.5rem;
    align-self: start;
  }
}

.tma-product-sticky {
  display: none;
}

@media (max-width: 1024px) {
  .tma-product-sticky {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    background-color: var(--agri-white, #ffffff);
    border-top: 1px solid var(--agri-border-subtle, #e2e8f0);
    padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  }

  .tma-product-sticky-price .price,
  .tma-product-sticky-price .woocommerce-Price-amount {
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    color: var(--agri-amber-accent, #d97706) !important;
  }

  .tma-product-sticky-price del {
    display: none;
  }

  .tma-product-sticky .tma-btn {
    padding: 0.7rem 1.1rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .tma-product-container {
    padding-bottom: 6rem;
  }
}

/* ==========================================================================
   12. CORRECTIONS D'AFFICHAGE
   ========================================================================== */

/* Storefront affiche des vignettes « produit précédent / suivant » fixées
   aux bords de l'écran. Elles parasitent la fiche : on les retire. */
.storefront-product-pagination {
  display: none !important;
}

/* Storefront injecte son fil d'Ariane sur « storefront_before_content »,
   en plus de celui du template. On masque le sien (et son conteneur, qui
   conserve sinon ses marges et crée un vide). */
.single-product .storefront-breadcrumb,
.single-product .woocommerce-breadcrumb {
  display: none !important;
}

/* Description courte : Storefront applique 1.41575em entre paragraphes,
   ce qui crée de grands trous dans les fiches importées. */
.tma-product-excerpt p {
  margin: 0 0 0.4rem !important;
  line-height: 1.55;
}

.tma-product-excerpt p:last-child {
  margin-bottom: 0 !important;
}

.tma-product-excerpt ul,
.tma-product-excerpt ol {
  margin: 0 0 0.5rem 1.2rem !important;
}

.tma-product-price-row {
  margin-bottom: 0.9rem;
}

.tma-product-title {
  margin-bottom: 0.85rem !important;
}

.tma-product-tags {
  margin-bottom: 1.1rem;
}

/* Le fil d'Ariane du template ne doit pas coller à l'en-tête. */
.single-product .tma-product-container {
  padding-top: 1.25rem;
}

.single-product .tma-product-breadcrumb {
  margin-bottom: 1.5rem;
}
