/**
 * Styles pour les articles de blog générés.
 *
 * @package WC_Shop_Builder
 */

/* Liens produits intégrés dans les articles */
.ecomx__product-cta {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  padding: 12px 15px;
  margin: 15px 0;
  background-color: #f8f9fa;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  border: 1px solid #e9ecef;
  transition: all 0.3s ease;
  max-width: 100%;
  width: auto;
}

.ecomx__product-cta:hover {
  background-color: #e9ecef;
  border-color: #dee2e6;
  text-decoration: none;
  color: inherit;
}

.ecomx__product-cta__img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.ecomx__product-cta span {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.ecomx__product-cta__review {
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

.ecomx__product-cta__text {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  line-height: 1.4;
}

/* Responsive */
@media (max-width: 768px) {
  .ecomx__product-cta {
    flex-direction: column;
    text-align: center;
  }

  .ecomx__product-cta__img {
    width: 100px;
    height: 100px;
  }
}

/* Section "En lire plus" */
.wcsb-related-posts {
  margin: 40px 0;
  padding: 30px;
  background-color: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.wcsb-related-posts h2 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 24px;
  color: #333;
}

.wcsb-related-posts > p {
  margin-bottom: 25px;
  color: #666;
  font-size: 16px;
}

/* Grille d'articles */
.wcsb-related-posts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 25px;
  margin: 0;
}

.wcsb-related-posts-item {
  background-color: #fff;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e9ecef;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.wcsb-related-posts-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.wcsb-related-posts-item a {
  display: block;
  text-decoration: none;
  color: inherit;
}

.wcsb-related-posts-image {
  width: 100%;
  height: 200px;
  overflow: hidden;
  background-color: #f0f0f0;
  position: relative;
}

.wcsb-related-posts-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.wcsb-related-posts-item:hover .wcsb-related-posts-image img {
  transform: scale(1.05);
}

.wcsb-related-posts-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
}

.wcsb-related-posts-title {
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  line-height: 1.4;
  text-align: center;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wcsb-related-posts-item:hover .wcsb-related-posts-title {
  color: #0073aa;
}

/* Responsive pour "En lire plus" */
@media (max-width: 1024px) {
  .wcsb-related-posts-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}

@media (max-width: 768px) {
  .wcsb-related-posts {
    padding: 20px;
    margin: 30px 0;
  }

  .wcsb-related-posts h2 {
    font-size: 20px;
  }

  .wcsb-related-posts-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .wcsb-related-posts-image {
    height: 180px;
  }

  .wcsb-related-posts-title {
    font-size: 15px;
    min-height: 50px;
  }
}

/* ============================================
   IMAGE INJECTÉE DANS LE CONTENU (PAGE BLOG)
   Solution générique pour tous les thèmes
   ============================================ */

/* Image injectée au début du contenu - la déplacer avant le wrapper */
article.post .entry-content .wcsb-content-image {
  display: block;
  width: 100%;
  margin: 0 0 20px 0;
  padding: 0;
}

article.post .entry-content .wcsb-content-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* Pour les thèmes qui utilisent blog-loop-content-wrapper */
article.post .blog-loop-content-wrapper .entry-content .wcsb-content-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  margin: 0;
  z-index: 1;
}

/* Alternative : extraire l'image du contenu et la placer avant le wrapper */
article.post.wcsb-has-content-image {
  position: relative;
}

article.post.wcsb-has-content-image .wcsb-content-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1;
}

/* Si le thème utilise .post-thumbnail, on s'assure que notre image a le même style */
.post-thumbnail.wcsb-content-image {
  display: block;
  width: 100%;
  overflow: hidden;
  margin-bottom: 0;
}

.post-thumbnail.wcsb-content-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* ============================================
   FIX LARGEUR : Forcer le contenu à 100% sur les pages blog
   (Override le width: 76% de Shoptimizer qui suppose une sidebar)
   Spécificité maximale pour override Shoptimizer
   ============================================ */

/* Forcer le contenu principal à prendre toute la largeur sur blog/articles */
/* Sélecteurs ultra-spécifiques pour garantir l'override */
body.single-post #primary,
body.single-post .content-area,
body.single-post div#primary,
body.single-post div.content-area,
body.blog #primary,
body.blog .content-area,
body.blog div#primary,
body.blog div.content-area,
body.archive #primary,
body.archive .content-area,
body.archive div#primary,
body.archive div.content-area,
body.category-blog #primary,
body.category-blog .content-area,
body.category-blog div#primary,
body.category-blog div.content-area,
.single-post #primary,
.single-post .content-area,
.blog #primary,
.blog .content-area,
.archive #primary,
.archive .content-area,
.category-blog #primary,
.category-blog .content-area {
  width: 100% !important;
  max-width: 1200px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  float: none !important;
}

/* Override du media query Shoptimizer qui applique width: 76% en desktop */
/* Triple spécificité pour être sûr de prendre le dessus */
@media (min-width: 993px) {
  body.single-post #primary,
  body.single-post .content-area,
  body.single-post div#primary,
  body.single-post div.content-area,
  body.blog #primary,
  body.blog .content-area,
  body.blog div#primary,
  body.blog div.content-area,
  body.archive #primary,
  body.archive .content-area,
  body.archive div#primary,
  body.archive div.content-area,
  body.category-blog #primary,
  body.category-blog .content-area,
  body.category-blog div#primary,
  body.category-blog div.content-area,
  .single-post #primary,
  .single-post .content-area,
  .blog #primary,
  .blog .content-area,
  .archive #primary,
  .archive .content-area,
  .category-blog #primary,
  .category-blog .content-area {
    width: 100% !important;
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

/* Masquer complètement la sidebar sur blog (au cas où elle serait encore générée) */
body.single-post #secondary,
body.single-post .widget-area,
body.blog #secondary,
body.blog .widget-area,
body.archive #secondary,
body.archive .widget-area,
body.category-blog #secondary,
body.category-blog .widget-area,
.single-post #secondary,
.single-post .widget-area,
.blog #secondary,
.blog .widget-area,
.archive #secondary,
.archive .widget-area,
.category-blog #secondary,
.category-blog .widget-area {
  display: none !important;
  width: 0 !important;
  visibility: hidden !important;
}

/* ============================================
   STYLES POUR LA PAGE BLOG (ARCHIVE)
   ============================================ */

/* Container principal de la page blog */
.blog .site-main,
.archive .site-main,
.category-blog .site-main,
.site-main.grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Grille des articles sur la page blog - Structure Shoptimizer */
.site-main.grid.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 30px;
  margin: 30px 0;
}

/* Wrapper du contenu de l'article (Shoptimizer) */
.blog-loop-content-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Article individuel sur la page blog */
.blog article.post,
.archive article.post,
.category-blog article.post,
article.post {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  height: auto;
}

.blog article.post:hover,
.archive article.post:hover,
.category-blog article.post:hover,
article.post:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

/* Image de l'article sur la page blog */
.blog article.post .entry-image,
.archive article.post .entry-image,
.category-blog article.post .entry-image,
.blog article.post .post-thumbnail,
.archive article.post .post-thumbnail,
.category-blog article.post .post-thumbnail,
.blog article.post .wp-block-image,
.archive article.post .wp-block-image,
.category-blog article.post .wp-block-image,
.blog article.post figure,
.archive article.post figure,
.category-blog article.post figure {
  width: 100%;
  height: 200px;
  overflow: hidden;
  margin: 0;
  padding: 0;
  position: relative;
  background-color: #f0f0f0;
  flex-shrink: 0;
}

/* Centrer l'image dans .post-thumbnail */
.blog article.post .post-thumbnail,
.archive article.post .post-thumbnail,
.category-blog article.post .post-thumbnail {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Image dans .post-thumbnail - centrée */
.blog article.post .post-thumbnail img,
.archive article.post .post-thumbnail img,
.category-blog article.post .post-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* Images dans le contenu de l'article (première image) */
.blog article.post .entry-content img,
.archive article.post .entry-content img,
.category-blog article.post .entry-content img,
.blog article.post .wp-block-image img,
.archive article.post .wp-block-image img,
.category-blog article.post .wp-block-image img,
.blog article.post figure img,
.archive article.post figure img,
.category-blog article.post figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* Cacher toutes les images sauf la première dans l'excerpt */
.blog article.post .entry-content img:not(:first-of-type),
.archive article.post .entry-content img:not(:first-of-type),
.category-blog article.post .entry-content img:not(:first-of-type) {
  display: none;
}

/* Contenu de l'article */
.blog article.post .entry-content,
.archive article.post .entry-content,
.category-blog article.post .entry-content,
.entry-content {
  padding: 10px 15px 12px 15px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Réduire les marges sous les paragraphes dans les cards */
.blog article.post .entry-content p,
.archive article.post .entry-content p,
.category-blog article.post .entry-content p {
  margin-bottom: 6px;
  margin-top: 0;
  font-size: 14px;
  line-height: 1.5;
}

.blog article.post .entry-content p:last-child,
.archive article.post .entry-content p:last-child,
.category-blog article.post .entry-content p:last-child {
  margin-bottom: 0;
}

/* Header de l'article */
.entry-header {
  padding: 12px 15px 8px 15px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.entry-header .entry-title {
  font-size: 18px;
  line-height: 1.3;
  margin-bottom: 6px;
}

.entry-header .entry-title a {
  font-size: 18px;
  line-height: 1.3;
}

.entry-header .posted-on {
  font-size: 12px;
}

/* Titre de l'article */
.blog article.post .entry-title,
.archive article.post .entry-title,
.category-blog article.post .entry-title {
  margin: 0 0 15px 0;
  font-size: 20px;
  line-height: 1.4;
}

.blog article.post .entry-title a,
.archive article.post .entry-title a,
.category-blog article.post .entry-title a {
  color: #333;
  text-decoration: none;
  transition: color 0.3s ease;
}

.blog article.post .entry-title a:hover,
.archive article.post .entry-title a:hover,
.category-blog article.post .entry-title a:hover {
  color: #0073aa;
}

/* Excerpt/Meta */
.blog article.post .entry-summary,
.archive article.post .entry-summary,
.category-blog article.post .entry-summary {
  margin-top: auto;
  padding-top: 15px;
  color: #666;
  font-size: 14px;
}

/* Cacher "posted in : blog" */
.blog article.post .entry-meta,
.archive article.post .entry-meta,
.category-blog article.post .entry-meta,
.single .entry-meta .posted-in,
.single .entry-footer .posted-in,
.single .entry-meta .cat-links {
  display: none !important;
}

/* ============================================
   STYLES POUR LES PAGES BLOG (SINGLE + ARCHIVE)
   POLICES : GÉRÉES PAR LE THÈME (Shoptimizer)
   ============================================ */

/* H1 plus grand que H2 sur les pages single blog - Taille raisonnable */
/* Sélecteur plus spécifique que celui du thème */
.single-post #primary .entry-title,
.single-post #primary .entry-header .entry-title,
.single-post #primary h1.entry-title,
.single-post #primary .entry-header h1,
.single #primary .entry-title,
.single #primary .entry-header .entry-title,
.single #primary h1.entry-title,
.single #primary .entry-header h1,
.single .site-main .entry-title,
.single .site-main .entry-header .entry-title,
.single .site-main h1.entry-title,
.single .site-main .entry-header h1 {
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.3;
  margin-bottom: 20px;
  font-weight: 600;
  margin-top: 0;
}

/* S'assurer que H2 est plus petit que H1 */
.single-post .entry-content h2 {
  font-size: clamp(24px, 3.5vw, 36px);
  font-weight: 600;
  margin-top: 40px;
  margin-bottom: 20px;
}

/* Redimensionner l'image principale du blog (single) - Taille raisonnable */
/* Sélecteur plus spécifique que .post .wp-post-image du thème pour override proprement */
.single #primary .post > img.wp-post-image,
.single #primary .hentry > img.wp-post-image,
.single #primary .type-post > img.wp-post-image,
.single #primary .has-post-thumbnail > img.wp-post-image,
.single #primary .post img.attachment.wp-post-image,
.single #primary .post-thumbnail img,
.single #primary .featured-image img,
.single #primary .wp-post-image,
.single #primary img.wp-post-image,
.single .site-main .post > img.wp-post-image,
.single .site-main .hentry > img.wp-post-image,
.single .site-main img.wp-post-image {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 30px;
  max-width: 100%;
  width: auto;
  max-height: 400px;
  height: auto;
  object-fit: cover;
  object-position: center;
  border-radius: 8px;
}

/* Limiter la hauteur max de l'image pour éviter qu'elle soit trop grande */
.single .post-thumbnail,
.single .featured-image,
.single .entry-image {
  max-width: 100%;
  margin: 0 auto 30px;
  overflow: hidden;
  max-height: 400px;
}

.single .post-thumbnail img,
.single .featured-image img,
.single .entry-image img {
  max-height: 400px;
  width: 100%;
  height: auto;
  object-fit: cover;
  object-position: center;
}

/* Centrer aussi si l'image est dans un wrapper */
.single .featured-image,
.single .post-thumbnail {
  text-align: center;
  margin: 0 auto 30px;
}

/* Responsive : réduire la hauteur max sur mobile */
@media (max-width: 768px) {
  .single .post-thumbnail img,
.single .featured-image img,
  .single .entry-image img,
  .single img.wp-post-image {
    max-height: 300px;
  }

  .single-post .entry-title,
  .single .entry-title {
    font-size: clamp(22px, 5vw, 28px) !important;
  }
}

/* Layout desktop : Image + premier paragraphe côte à côte */
/* Structure générée directement par PHP via les hooks WordPress */
@media (min-width: 769px) {
  /* Wrapper pour image + premier paragraphe (généré par PHP) */
  .single #primary .wcsb-image-intro-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: center;
    margin-bottom: 30px;
  }

  /* Image dans le wrapper */
  .single #primary .wcsb-image-intro-wrapper .wcsb-featured-image-wrapper {
    width: 100%;
  }

  .single #primary .wcsb-image-intro-wrapper .wcsb-featured-image {
    width: 100%;
    max-height: 400px;
    height: auto;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    display: block;
  }

  /* Premier paragraphe dans le wrapper - centré verticalement et justifié */
  .single #primary .wcsb-image-intro-wrapper .wcsb-first-paragraph {
    margin-top: 0;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    min-height: 0;
  }

  .single #primary .wcsb-image-intro-wrapper .wcsb-first-paragraph p {
    margin-top: 0;
    margin-bottom: 0;
    text-align: justify;
    hyphens: auto;
    width: 100%;
  }
}

/* Sur mobile, le wrapper s'affiche en colonne (comportement par défaut) */
@media (max-width: 768px) {
  .single #primary .wcsb-image-intro-wrapper {
  display: block;
  }

  .single #primary .wcsb-image-intro-wrapper .wcsb-featured-image-wrapper {
    margin-bottom: 20px;
  }

  .single #primary .wcsb-image-intro-wrapper .wcsb-first-paragraph p {
    text-align: justify;
    hyphens: auto;
  }
}

/* S'assurer que les commentaires restent après le contenu */
.single .entry-content {
  margin-bottom: 40px;
}

.single .entry-meta {
  margin-top: 40px;
  margin-bottom: 40px;
}

.single #comments {
  margin-top: 60px;
  clear: both;
}

/* Lien "Lire la suite" */
.blog article.post .more-link,
.archive article.post .more-link,
.category-blog article.post .more-link {
  display: inline-block;
  margin-top: 15px;
  padding: 10px 20px;
  background-color: #0073aa;
  color: #fff;
  text-decoration: none;
  border-radius: 5px;
  transition: background-color 0.3s ease;
}

.blog article.post .more-link:hover,
.archive article.post .more-link:hover,
.category-blog article.post .more-link:hover {
  background-color: #005a87;
}

/* Responsive pour la page blog */
@media (max-width: 1024px) {
  .site-main.grid.grid-2 {
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
  }

  .blog .posts-container,
  .archive .posts-container,
  .category-blog .posts-container,
  .blog .post-list,
  .archive .post-list,
  .category-blog .post-list {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
  }

  .blog article.post .entry-image,
  .archive article.post .entry-image,
  .category-blog article.post .entry-image,
  .blog article.post .post-thumbnail,
  .archive article.post .post-thumbnail,
  .category-blog article.post .post-thumbnail,
  .blog article.post .wp-block-image,
  .archive article.post .wp-block-image,
  .category-blog article.post .wp-block-image,
  .blog article.post figure,
  .archive article.post figure,
  .category-blog article.post figure {
    height: 220px;
  }
}

@media (max-width: 768px) {
  .site-main.grid.grid-2 {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .blog .posts-container,
  .archive .posts-container,
  .category-blog .posts-container,
  .blog .post-list,
  .archive .post-list,
  .category-blog .post-list {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .blog article.post .entry-image,
  .archive article.post .entry-image,
  .category-blog article.post .entry-image,
  .blog article.post .post-thumbnail,
  .archive article.post .post-thumbnail,
  .category-blog article.post .post-thumbnail,
  .blog article.post .wp-block-image,
  .archive article.post .wp-block-image,
  .category-blog article.post .wp-block-image,
  .blog article.post figure,
  .archive article.post figure,
  .category-blog article.post figure {
    height: 200px;
  }
}

/* Fallback pour les thèmes qui utilisent d'autres classes */
.posts .post,
.post-list .post,
.blog-posts .post {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.posts .post img,
.post-list .post img,
.blog-posts .post img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  object-position: center;
  display: block;
}
