/**
 * Uniformisation visuelle du Panier et du Checkout WooCommerce avec le design de
 * l'application React LanguAfrica — Phase 1.
 *
 * Portée : chargé UNIQUEMENT sur /panier/ et /commander/ (voir woocommerce-style.php,
 * is_cart() / is_checkout()) — ne peut donc affecter aucune autre page WordPress.
 *
 * Ne touche à aucune logique métier : uniquement des règles visuelles (couleurs,
 * typo, espacements, rayons, ombres) sur des sélecteurs WooCommerce Blocks stables
 * (classes officielles du package @woocommerce/blocks) et sur le header/footer natifs
 * du thème Hello Elementor. Les boutons Apple Pay / Google Pay / Link sont rendus dans
 * un iframe Stripe cross-origin : seul l'espacement de leur CONTENEUR est ajusté ici,
 * jamais leur intérieur (de toute façon inatteignable en CSS).
 *
 * Valeurs alignées sur le frontend React (voir tailwind.config.js, index.css,
 * Layout.jsx, Footer.jsx, button.jsx, card.jsx) :
 *   - amber-600 #D97706 / amber-700 #B45309 : CTA d'achat (Passer commande / Valider)
 *   - emerald-600 #059669 : réservé aux actions "espace membre" (non utilisé ici)
 *   - slate-900 #0F172A, slate-600 #475569, slate-500 #64748B, slate-400 #94A3B8
 *   - pas de police custom : stack système Tailwind (font-sans)
 */

body.woocommerce-cart,
body.woocommerce-checkout {
  --la-amber-600: #D97706;
  --la-amber-700: #B45309;
  --la-slate-900: #0F172A;
  --la-slate-600: #475569;
  --la-slate-500: #64748B;
  --la-slate-400: #94A3B8;
  --la-border: #E2E8F0; /* slate-200, pour séparateurs/bordures de carte */
  --la-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --la-radius-lg: 1rem;      /* rounded-2xl */
  --la-radius-md: 0.75rem;   /* rounded-xl */
  --la-radius-full: 9999px;  /* rounded-full */
  --la-shadow-card: 0 1px 2px 0 rgb(0 0 0 / 0.05); /* shadow-sm */

  background-color: #ffffff;
  color: var(--la-slate-900);
  font-family: var(--la-font);

  /* Patron "sticky footer" classique : élimine l'espace blanc sous le footer
     quand le contenu de la page est plus court que la hauteur de l'écran (voir
     ci-dessous). Sans effet sur les pages où le contenu dépasse déjà 100vh. */
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* html{height:100%} est nécessaire pour que le min-height:100% du body
 * ci-dessus se calcule par rapport à la hauteur réelle de l'écran plutôt que
 * de valoir 0 (percentage height require un ancêtre à hauteur définie).
 * Non scopé par une classe body car html n'en porte aucune — mais cette
 * feuille de style n'est chargée QUE sur /panier/ et /commander/ (voir
 * woocommerce-style.php), donc cette règle n'a de toute façon aucun effet
 * ailleurs sur le site : rien ne charge ce fichier en dehors de ces 2 pages. */
html {
  height: 100%;
}

/* #content (le <main> Hello Elementor, entre header et footer) absorbe tout
 * l'espace vertical restant : le footer se retrouve ainsi collé en bas de
 * l'écran au lieu de laisser un espace blanc en dessous. header/footer ne
 * doivent jamais être compressés par ce flex : flex-shrink:0. */
body.woocommerce-cart #content,
body.woocommerce-checkout #content {
  flex: 1 0 auto;
}

body.woocommerce-cart #site-header,
body.woocommerce-checkout #site-header,
body.woocommerce-cart #site-footer,
body.woocommerce-checkout #site-footer {
  flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
 * Layout / largeur — mobile-first : pleine largeur avec padding confortable,
 * puis un max-width proche du container React (1024px) à partir du desktop.
 * ------------------------------------------------------------------------- */
body.woocommerce-cart .site-content,
body.woocommerce-checkout .site-content,
body.woocommerce-cart .content-area,
body.woocommerce-checkout .content-area {
  padding-left: 1rem;
  padding-right: 1rem;
}

body.woocommerce-cart .wp-block-woocommerce-cart,
body.woocommerce-checkout .wp-block-woocommerce-checkout {
  max-width: 100%;
  min-width: 0;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 768px) {
  body.woocommerce-cart .site-content,
  body.woocommerce-checkout .site-content,
  body.woocommerce-cart .content-area,
  body.woocommerce-checkout .content-area {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  body.woocommerce-cart .wp-block-woocommerce-cart,
  body.woocommerce-checkout .wp-block-woocommerce-checkout {
    max-width: 1024px;
  }
}

/* ---------------------------------------------------------------------------
 * Titre de page (H1 "Panier" / "Commander" — .entry-title du thème)
 * ------------------------------------------------------------------------- */
body.woocommerce-cart .entry-title,
body.woocommerce-checkout .entry-title {
  font-family: var(--la-font);
  font-weight: 700;
  color: var(--la-slate-900);
  font-size: 1.75rem;
  letter-spacing: normal;
}

@media (min-width: 768px) {
  body.woocommerce-cart .entry-title,
  body.woocommerce-checkout .entry-title {
    font-size: 2.25rem;
  }
}

/* ---------------------------------------------------------------------------
 * Header natif (Hello Elementor) — harmonisation légère uniquement :
 * couleur du site-title alignée sur l'accent amber du logo React. La vraie
 * reconstruction du header (logo + nav) est traitée séparément (Phase 2).
 * ------------------------------------------------------------------------- */
body.woocommerce-cart #site-header .site-title a,
body.woocommerce-checkout #site-header .site-title a {
  font-family: var(--la-font);
  color: var(--la-amber-600);
  font-weight: 700;
  text-decoration: none;
}

body.woocommerce-cart #site-header,
body.woocommerce-checkout #site-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--la-border);
}

/* Cause vérifiée (HTML + CSS réels de /panier/ et /commander/, y compris
 * hello-elementor theme.css, header-footer.css, elementor-post-4.css,
 * custom-frontend.min.css) : AUCUNE règle CSS, sur tout le site, ne contraint
 * jamais .site-logo img / .custom-logo — seulement `display:block`. Le
 * <img> du logo porte width="562" height="491" en HTML (dimensions
 * intrinsèques du fichier uploadé), donc le navigateur les utilise telles
 * quelles. /panier/ et /commander/ partagent exactement le même header, la
 * même image, le même CSS : aucune différence de règle entre les deux pages.
 * Le rendu "petit" déjà vu sur /commander/ ne vient donc pas d'une règle CSS
 * spécifique à cette page, mais du rétrécissement flex par défaut du
 * navigateur (.header-inner est en display:flex, et un <img> sans taille CSS
 * explicite peut s'y redimensionner différemment selon l'espace occupé par
 * les autres éléments du header) — un comportement non fiable, qui peut
 * changer d'une page à l'autre sans qu'aucun CSS ne change. On fixe donc une
 * taille explicite, identique sur les deux pages, pour ne plus dépendre de ce
 * comportement.
 *
 * Sélecteur volontairement plus spécifique que celui du thème
 * (`.site-header .header-inner .site-branding .site-logo img`) + !important :
 * garde-fou pour qu'aucune future règle Hello Elementor / Elementor Kit /
 * WooCommerce ne puisse ré-agrandir le logo par accident. `flex-shrink: 0`
 * empêche aussi le conteneur flex du header de le rétrécir en dessous de
 * cette taille sur les très petits écrans. */
body.woocommerce-cart #site-header .header-inner .site-branding .site-logo .custom-logo-link .custom-logo,
body.woocommerce-checkout #site-header .header-inner .site-branding .site-logo .custom-logo-link .custom-logo,
body.woocommerce-cart #site-footer .footer-inner .site-branding .site-logo .custom-logo-link .custom-logo,
body.woocommerce-checkout #site-footer .footer-inner .site-branding .site-logo .custom-logo-link .custom-logo {
  height: 40px !important;
  width: auto !important;
  max-width: 100% !important;
  flex-shrink: 0;
}

/* Logo du footer aligné à gauche sur mobile — cause vérifiée dans
 * header-footer.css : sous 576px, le thème passe .site-branding en
 * `display:block; text-align:center` (media max-width:576px), mais
 * `.custom-logo-link` ET l'image `.custom-logo` sont tous deux forcés en
 * `display:block` par le thème (jamais inline/inline-block) — un bloc n'est
 * jamais repositionné par `text-align`, qui ne s'applique qu'au contenu
 * inline. D'où le logo collé à gauche malgré le text-align:center hérité.
 * On transforme uniquement `.custom-logo-link` du FOOTER (jamais le header,
 * grâce à #site-footer) en conteneur flex centré : ça ne change rien sur
 * desktop/tablette, où ce conteneur n'est déjà large que de son contenu (rien
 * à centrer) — l'effet ne se voit que là où le thème force déjà la pleine
 * largeur, donc uniquement en mobile. La taille du logo (40px, règle
 * ci-dessus) n'est pas modifiée. */
body.woocommerce-cart #site-footer .footer-inner .site-branding .site-logo .custom-logo-link,
body.woocommerce-checkout #site-footer .footer-inner .site-branding .site-logo .custom-logo-link {
  display: flex;
  justify-content: center;
}

body.woocommerce-cart #site-footer .footer-inner .site-branding .site-logo .custom-logo-link .custom-logo,
body.woocommerce-checkout #site-footer .footer-inner .site-branding .site-logo .custom-logo-link .custom-logo {
  border-radius: 12px;
}

/* ---------------------------------------------------------------------------
 * Footer natif — fond slate-900 + texte clair, cohérent avec le footer React.
 * ------------------------------------------------------------------------- */
body.woocommerce-cart #site-footer,
body.woocommerce-checkout #site-footer {
  background-color: var(--la-slate-900);
  color: var(--la-slate-400);
}

body.woocommerce-cart #site-footer .copyright,
body.woocommerce-checkout #site-footer .copyright,
body.woocommerce-cart #site-footer .copyright p,
body.woocommerce-checkout #site-footer .copyright p {
  color: var(--la-slate-400);
  font-family: var(--la-font);
}

/* ---------------------------------------------------------------------------
 * Cartes produit / lignes du panier
 * ------------------------------------------------------------------------- */
body.woocommerce-cart .wc-block-cart-items,
body.woocommerce-checkout .wc-block-cart-items {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-lg);
  overflow: hidden;
  box-shadow: var(--la-shadow-card);
}

body.woocommerce-cart .wc-block-cart-items__row {
  padding: 1rem;
  border-bottom: 1px solid var(--la-border);
}

body.woocommerce-cart .wc-block-cart-items__row:last-child {
  border-bottom: none;
}

body.woocommerce-cart .wc-block-components-product-name {
  font-family: var(--la-font);
  font-weight: 600;
  color: var(--la-slate-900);
  /* Un titre de produit long ne doit jamais forcer la ligne plus large que le
     viewport (même piège flex rencontré sur le Dashboard React) : */
  min-width: 0;
  word-break: break-word;
}

body.woocommerce-cart .wc-block-components-formatted-money-amount {
  color: var(--la-slate-900);
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
 * Séparateurs génériques dans les blocs Woo
 * ------------------------------------------------------------------------- */
body.woocommerce-cart .wc-block-cart .wc-block-components-totals-wrapper,
body.woocommerce-checkout .wc-block-checkout .wc-block-components-totals-wrapper {
  border-top: 1px solid var(--la-border);
}

/* ---------------------------------------------------------------------------
 * Bloc des totaux (sidebar panier / checkout)
 * ------------------------------------------------------------------------- */
body.woocommerce-cart .wc-block-cart__totals-title,
body.woocommerce-checkout .wc-block-checkout__totals-title,
body.woocommerce-cart .wc-block-components-totals-item,
body.woocommerce-checkout .wc-block-components-totals-item {
  font-family: var(--la-font);
  color: var(--la-slate-900);
}

body.woocommerce-cart .wc-block-cart .wc-block-components-sidebar,
body.woocommerce-checkout .wc-block-checkout .wc-block-checkout__sidebar {
  background-color: #F8FAFC; /* slate-50 */
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-lg);
  padding: 1.25rem;
  min-width: 0;
  max-width: 100%;
}

/* ---------------------------------------------------------------------------
 * Coupon ("Ajouter un code promo")
 * ------------------------------------------------------------------------- */
body.woocommerce-cart .wc-block-components-totals-coupon,
body.woocommerce-checkout .wc-block-components-totals-coupon {
  border-top: 1px solid var(--la-border);
  border-bottom: 1px solid var(--la-border);
}

body.woocommerce-cart .wc-block-components-totals-coupon__button,
body.woocommerce-checkout .wc-block-components-totals-coupon__button {
  border-radius: var(--la-radius-md);
}

body.woocommerce-cart .wc-block-components-text-input input,
body.woocommerce-checkout .wc-block-components-text-input input,
body.woocommerce-checkout .wc-block-components-radio-control,
body.woocommerce-checkout .wc-block-components-address-form input {
  font-family: var(--la-font);
  border-radius: var(--la-radius-md);
  border-color: var(--la-border);
}

/* ---------------------------------------------------------------------------
 * Bouton principal — "Passer à la commande" (panier) / "Valider la commande"
 * (checkout). Couleur validée : amber-600, hover amber-700. Ne concerne QUE ce
 * bouton natif WooCommerce — jamais les boutons Apple Pay / Google Pay / Link,
 * rendus dans un iframe Stripe et non ciblables (ni souhaité) depuis ce CSS.
 * ------------------------------------------------------------------------- */
body.woocommerce-cart .wc-block-cart__submit-button,
body.woocommerce-cart .wp-block-woocommerce-proceed-to-checkout-block .wc-block-components-button,
body.woocommerce-checkout .wc-block-components-checkout-place-order-button {
  background-color: var(--la-amber-600) !important;
  border-color: var(--la-amber-600) !important;
  color: #ffffff !important;
  border-radius: var(--la-radius-md) !important;
  font-family: var(--la-font);
  font-weight: 600;
  box-shadow: none;
}

body.woocommerce-cart .wc-block-cart__submit-button:hover,
body.woocommerce-cart .wp-block-woocommerce-proceed-to-checkout-block .wc-block-components-button:hover,
body.woocommerce-checkout .wc-block-components-checkout-place-order-button:hover {
  background-color: var(--la-amber-700) !important;
  border-color: var(--la-amber-700) !important;
}

body.woocommerce-checkout .wc-block-components-checkout-return-to-cart-button {
  color: var(--la-slate-600);
  border-radius: var(--la-radius-md);
}

/* Conteneur des boutons de paiement express (Apple/Google Pay, Link) : espacement
 * uniquement, jamais overflow:hidden (ne doit jamais rogner l'iframe Stripe), jamais
 * de style appliqué à l'intérieur. */
body.woocommerce-cart .wc-block-components-express-payment,
body.woocommerce-checkout .wc-block-components-express-payment {
  margin-top: 1rem;
  margin-bottom: 1rem;
  min-width: 0;
  max-width: 100%;
}

/* ---------------------------------------------------------------------------
 * Filet de sécurité mobile générique (mêmes classes que le débordement déjà
 * corrigé une fois sur /panier/) — jamais overflow-x:hidden, uniquement des
 * contraintes de largeur ciblées pour empêcher tout enfant de forcer la page
 * plus large que le viewport.
 * ------------------------------------------------------------------------- */
@media (max-width: 767px) {
  body.woocommerce-cart .wc-block-cart,
  body.woocommerce-checkout .wc-block-checkout,
  body.woocommerce-cart .wc-block-components-main,
  body.woocommerce-checkout .wc-block-checkout__main,
  body.woocommerce-cart .wc-block-components-sidebar,
  body.woocommerce-checkout .wc-block-checkout__sidebar {
    max-width: 100%;
    min-width: 0;
  }
}
