/* ============================================================
   One Life Van — order-summary.css
   Refonte de la sidebar "Résumé de la commande" du checkout
   block-based WooCommerce (WC 8+). CSS pur, cible les classes
   WC blocks natives. Tokens (--bg, --surface, --ink…) déjà chargés.
   Objectif : densité -50%, tout sombre (Midnight), promo en pill.

   Source : Claude Design 26/06, intégration Stef.
   Charge APRÈS cart-checkout.css → override les anciennes règles.
   ============================================================ */

/* ------------------------------------------------------------
   0. WRAPPER SIDEBAR (cart + checkout)
   ------------------------------------------------------------ */
.wp-block-woocommerce-checkout-order-summary-block,
.wp-block-woocommerce-checkout-order-summary,
.wp-block-woocommerce-cart-order-summary-block,
.wp-block-woocommerce-cart-totals-block,
.wc-block-components-order-summary,
.wp-block-woocommerce-cart-order-summary-block-frontend {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  font-family: var(--font-body);
  color: var(--ink);
}

/* ------------------------------------------------------------
   0.1 RÉORDONNANCEMENT — abandonné (Stef 26/06).
   Les sub-blocks WC ne sont pas enfants directs d'un même flex
   parent → CSS order ne fonctionnait pas comme prévu. On garde
   l'ordre natif WC : Heading → Coupon → Items → Subtotal →
   Shipping → Totals.
   ------------------------------------------------------------ */

/* Vire les border-top parasites entre sub-blocks (subtotal, shipping)
   qui créaient des doubles lignes de séparation laides. On garde juste
   les séparateurs entre items produits et autour du total final. */
.wp-block-woocommerce-cart-order-summary-subtotal-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-cart-order-summary-shipping-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-cart-order-summary-fee-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-cart-order-summary-discount-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-cart-order-summary-taxes-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-checkout-order-summary-subtotal-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-checkout-order-summary-shipping-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-checkout-order-summary-fee-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-checkout-order-summary-discount-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-checkout-order-summary-taxes-block .wc-block-components-totals-wrapper {
  border-top: 0 !important;
  padding: 2px 0 !important;
}

/* Sticky en desktop, statique en mobile. top: 100px pour passer sous le
   header sticky du thème (~80 px). */
@media (min-width: 782px) {
  .wp-block-woocommerce-checkout-order-summary-block,
  .wp-block-woocommerce-checkout-order-summary {
    position: sticky;
    top: 100px;
  }
}

/* ------------------------------------------------------------
   1. TITRE DE SECTION
   ------------------------------------------------------------ */
.wc-block-components-order-summary .wc-block-components-checkout-step__title,
.wp-block-woocommerce-checkout-order-summary-block > .wp-block-heading,
.wp-block-woocommerce-checkout-order-summary > .wp-block-heading {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 14px;
  padding: 0;
}

/* ------------------------------------------------------------
   2. LIGNE PRODUIT
   ------------------------------------------------------------ */
.wc-block-components-order-summary__content,
.wc-block-components-order-summary-item + .wc-block-components-order-summary-item {
  border: none;
}

.wc-block-components-order-summary-item {
  display: grid !important;
  grid-template-columns: 56px 1fr auto !important;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.wc-block-components-order-summary-item:last-child { border-bottom: none; }

/* Image 56×56 (au lieu de 80) */
.wc-block-components-order-summary-item__image {
  width: 56px !important;
  height: 56px !important;
  margin: 0 !important;
  flex: 0 0 56px;
}
.wc-block-components-order-summary-item__image img,
.wc-block-components-order-summary-item__image .wc-block-components-product-img {
  width: 56px !important;
  height: 56px !important;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

/* Sale-badge "ÉCONOMISEZ X €" caché dans le récap — le prix barré suffit
   visuellement et le badge prenait trop de place pour rien. */
.wc-block-components-order-summary-item .wc-block-components-sale-badge,
.wc-block-components-order-summary-item .wc-block-components-product-badge {
  display: none !important;
}

/* Description courte cachée dans le récap (redondante avec la fiche produit
   et tronquée laidement "Le module lit + ra..."). */
.wc-block-components-order-summary-item__description .wc-block-components-product-metadata,
.wc-block-components-order-summary-item__description .wc-block-components-product-metadata__description,
.wc-block-components-order-summary-item__description .wc-block-components-product-details {
  display: none !important;
}

/* Badge quantité (pastille en coin d'image) */
.wc-block-components-order-summary-item__quantity {
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  border: none;
}

/* Description : nom + prix unitaire (la metadata description est cachée
   ci-dessus pour éviter le tronquage moche). */
.wc-block-components-order-summary-item__description {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wc-block-components-order-summary-item__description .wc-block-components-product-name {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wc-block-components-order-summary-item__description .wc-block-components-product-metadata__variation-data {
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  margin: 0;
}

/* Prix unitaire : ancien barré + nouveau inline sur la même ligne */
.wc-block-components-order-summary-item__description .wc-block-components-product-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  font-size: 13px;
}
/* Prix courant */
.wc-block-components-product-price__value,
.wc-block-components-product-price ins {
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
  font-weight: 500;
}
/* Ancien prix barré — discret */
.wc-block-components-product-price del,
.wc-block-components-product-price__regular {
  color: var(--muted);
  font-size: 12px;
  text-decoration: line-through;
  font-weight: 400;
  order: -1; /* ancien prix AVANT le nouveau (lecture naturelle) */
}

/* Total à droite */
.wc-block-components-order-summary-item__total-price {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  text-align: right;
}

/* ------------------------------------------------------------
   3. BADGE PROMO "Économisez X €" — pill rouille discrète
   ------------------------------------------------------------ */
.wc-block-components-sale-badge {
  display: inline-flex;
  align-items: center;
  background: color-mix(in srgb, var(--rust) 18%, transparent);
  color: var(--rust);
  border: 1px solid color-mix(in srgb, var(--rust) 40%, transparent);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  line-height: 1;
  margin: 0;
}

/* ------------------------------------------------------------
   4. ACCORDÉON CODE PROMO (compact)
   ------------------------------------------------------------ */
.wc-block-components-totals-coupon {
  padding: 6px 0 8px;
  border-top: 1px solid var(--line);
  margin-top: 0;
}
.wc-block-components-totals-coupon__button,
.wc-block-components-totals-coupon-link {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  padding: 0;
}
.wc-block-components-totals-coupon__button:hover,
.wc-block-components-totals-coupon-link:hover { color: var(--sun); }

/* Champ + bouton du formulaire de coupon */
.wc-block-components-totals-coupon__form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.wc-block-components-totals-coupon__input input,
.wc-block-components-totals-coupon__form .wc-block-components-text-input input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 9px 12px;
}
.wc-block-components-totals-coupon__input input:focus {
  outline: none;
  border-color: var(--sun);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sun) 25%, transparent);
}
.wc-block-components-totals-coupon__button.contained {
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 12px;
}

/* ------------------------------------------------------------
   5. BLOC TOTALS (Sous-total / Livraison / TVA…) — densité ++
   ------------------------------------------------------------ */
.wc-block-components-totals-wrapper {
  padding: 6px 0;
  border-top: 1px solid var(--line);
  margin: 0;
}
.wc-block-components-totals-wrapper::after { display: none; } /* supprime séparateur natif épais */

/* Vire les marges/paddings parasites des sub-blocks WC */
.wp-block-woocommerce-cart-order-summary-subtotal-block,
.wp-block-woocommerce-cart-order-summary-shipping-block,
.wp-block-woocommerce-checkout-order-summary-subtotal-block,
.wp-block-woocommerce-checkout-order-summary-shipping-block {
  margin: 0 !important;
  padding: 0 !important;
}
.wp-block-woocommerce-cart-order-summary-subtotal-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-cart-order-summary-shipping-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-checkout-order-summary-subtotal-block .wc-block-components-totals-wrapper,
.wp-block-woocommerce-checkout-order-summary-shipping-block .wc-block-components-totals-wrapper {
  padding: 4px 0 !important;
}

.wc-block-components-totals-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;            /* encore plus serré */
  margin: 0;
}
.wc-block-components-totals-item__label {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--muted);
}
.wc-block-components-totals-item__value {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap;
}
.wc-block-components-totals-item__description {
  flex-basis: 100%;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin: 0;
}

/* Livraison gratuite — vert leaf */
.wc-block-components-totals-shipping .wc-block-components-totals-item__value {
  color: var(--ink);
}
.wc-block-components-totals-shipping .wc-block-components-totals-item__value:only-child {
  color: var(--ink);
}

/* Montant formaté */
.wc-block-components-formatted-money-amount { font-family: var(--font-mono); }

/* ------------------------------------------------------------
   6. TOTAL FINAL — carte mise en valeur
   ------------------------------------------------------------ */
.wc-block-components-totals-footer-item,
.wc-block-components-totals-wrapper:last-of-type .wc-block-components-totals-item.wc-block-components-totals-footer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 8px;
}
.wc-block-components-totals-footer-item .wc-block-components-totals-item__label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 5vw, 36px);
  letter-spacing: -0.02em;
  color: var(--ink);
}
/* Sous-texte "dont X € de TVA" */
.wc-block-components-totals-footer-item .wc-block-components-totals-item__description {
  flex-basis: 100%;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: 4px;
}

/* ------------------------------------------------------------
   7. TRUST BADGES (ligne discrète sous le récap)
   Si tu ajoutes un bloc HTML/texte custom sous le résumé,
   donne-lui la classe .olv-trust-row pour récupérer ce style.
   ------------------------------------------------------------ */
.olv-trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.olv-trust-row span + span::before {
  content: "·";
  margin-right: 10px;
  color: var(--line);
}

/* ------------------------------------------------------------
   8. RESPONSIVE — accordéon repliable en mobile (natif WC)
   ------------------------------------------------------------ */
@media (max-width: 781px) {
  .wp-block-woocommerce-checkout-order-summary-block,
  .wp-block-woocommerce-checkout-order-summary {
    padding: 16px;
    border-radius: var(--radius-lg);
  }
  /* En mobile WC affiche souvent un toggle "Afficher le récap" :
     on garde l'icône/chevron en couleur sun */
  .wc-block-components-panel__button { color: var(--ink); }
  .wc-block-components-panel__button:hover { color: var(--sun); }
  .wc-block-components-panel__button svg { fill: currentColor; }
}
