/**
 * Blog List Section - Liste d'articles avec pagination
 *
 * Section de page builder affichant une liste d'articles avec:
 * - Filtres par catégorie (optionnel)
 * - Grille configurable (2, 3 ou 4 colonnes)
 * - Pagination
 * - Réutilise le composant post-card
 *
 * @package Dioqa_UI_Kit
 */

/* ============================================
   Section principale
   ============================================ */

.blog-list-section {
  /* Padding géré dynamiquement via ACF */
  position: relative;
}

/* ============================================
   Filtres
   ============================================ */

.blog-filters {
  margin-bottom: 3rem;
}

.filters-form {
  display: flex;
  gap: 1.5rem;
  justify-content: start;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 200px;
}

.filter-label {
  display: none;
}

/* Custom Select Styling */
.custom-select {
  position: relative;
}

.custom-select-button {
  width: 100%;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--bs-gray-300, #dee2e6);
  border-radius: var(--bs-border-radius, 6px);
  font-family: var(--font-body, 'Work Sans', sans-serif);
  font-size: var(--text-base, 16px);
  font-weight: 500;
  color: var(--bs-dark, #212529);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
}

.custom-select-button:hover {
  border-color: var(--bs-primary, #002baa);
}

.custom-select.is-open .custom-select-button {
  border-color: var(--bs-primary, #002baa);
}

.custom-select-arrow {
  color: var(--bs-primary, #002baa);
  transition: transform 0.2s ease;
  display: flex;
  align-items: center;
}

.custom-select.is-open .custom-select-arrow {
  transform: rotate(180deg);
}

/* Dropdown */
.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--bs-white, #ffffff);
  border: 1px solid var(--bs-gray-300, #dee2e6);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.2s ease;
}

.custom-select.is-open .custom-select-dropdown {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.custom-select-option {
  padding: 0.75rem 1.25rem;
  font-family: var(--font-body, 'Work Sans', sans-serif);
  font-size: var(--text-base, 16px);
  color: var(--bs-dark, #212529);
  cursor: pointer;
  transition: background 0.2s ease;
}

.custom-select-option:hover {
  background: var(--bs-gray-100, #f8f9fa);
}

.custom-select-option.is-selected {
  background: var(--bs-primary-light, #e6eeff);
  color: var(--bs-primary, #002baa);
  font-weight: 600;
}

/* ============================================
   Post Card (composant réutilisable)
   ============================================ */

.post-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Image */
.post-card-image {
  display: block;
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--bs-gray-200, #e9ecef);
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Content */
.post-card-content {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Categories */
.post-card-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.category-badge {
  font-family: var(--font-body, 'Work Sans', sans-serif);
  font-size: var(--text-xs, 12px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.25rem 0.75rem;
  background: var(--bs-primary, #002baa);
  color: white;
  border-radius: 100px;
  text-decoration: none;
  transition: background 0.2s ease;
}

/* Title */
.post-card-title {
  font-family: var(--font-heading, 'Outfit', sans-serif);
  font-size: var(--text-xl, 24px);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.post-card-title a {
  color: var(--bs-dark, #212529);
  text-decoration: none;
  transition: color 0.2s ease;
}

.post-card-title a:hover {
  color: var(--bs-primary, #002baa);
}

/* Meta */
.post-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-family: var(--font-body, 'Work Sans', sans-serif);
  font-size: var(--text-sm, 14px);
  color: var(--text-gray, #6b687d);
}

.post-card-meta svg {
  width: 16px;
  height: 16px;
  margin-right: 0.25rem;
  opacity: 0.6;
}

.post-card-separator {
  opacity: 0.5;
}

.post-card-date,
.post-card-author {
  display: flex;
  align-items: center;
}

/* Excerpt */
.post-card-excerpt {
  font-family: var(--font-body, 'Work Sans', sans-serif);
  font-size: var(--text-base, 16px);
  line-height: 1.6;
  color: var(--text-gray, #6b687d);
  margin-bottom: 1.5rem;
  flex: 1;
}

/* Link */
.post-card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body, 'Work Sans', sans-serif);
  font-size: var(--text-base, 16px);
  font-weight: 600;
  color: var(--bs-primary, #002baa);
  text-decoration: none;
  margin-top: auto;
}

.post-card-link .btn-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 12px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.post-card-link:hover .btn-link-icon {
  transform: translateX(0.25rem);
}

.post-card-link .btn-link-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: currentColor;
}

/* ============================================
   Grilles d'articles
   ============================================ */

.posts-grid {
  display: grid;
  gap: 2.5rem;
  margin-bottom: 4rem;
}

/* Grille 2 colonnes */
.posts-grid-2-cols {
  grid-template-columns: repeat(2, 1fr);
}

/* Grille 3 colonnes */
.posts-grid-3-cols {
  grid-template-columns: repeat(3, 1fr);
}

/* Grille 4 colonnes */
.posts-grid-4-cols {
  grid-template-columns: repeat(4, 1fr);
}

/* ============================================
   Pagination Bootstrap
   ============================================ */

nav[aria-label*='navigation'] {
  display: flex;
  justify-content: center;
  margin-top: 3rem;
}

.pagination {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.page-item .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 1rem;
  font-family: var(--font-body, 'Work Sans', sans-serif);
  font-size: var(--text-base, 16px);
  font-weight: 500;
  color: var(--bs-dark, #212529);
  background: white;
  border: 1px solid var(--bs-gray-300, #dee2e6);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.page-item .page-link:hover {
  background: var(--bs-primary, #002baa);
  color: white;
  border-color: var(--bs-primary, #002baa);
}

.page-item.active .page-link {
  background: var(--bs-primary, #002baa);
  color: white;
  border-color: var(--bs-primary, #002baa);
}

.page-item.disabled .page-link {
  color: var(--bs-gray-400, #ced4da);
  cursor: not-allowed;
  opacity: 0.6;
}

.page-link svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   Message "Aucun article"
   ============================================ */

.no-posts {
  text-align: center;
  padding: 4rem 2rem;
}

.no-posts h2 {
  font-family: var(--font-heading, 'Outfit', sans-serif);
  font-size: var(--text-2xl, 32px);
  font-weight: 600;
  color: var(--bs-dark, #212529);
  margin-bottom: 1rem;
}

.no-posts p {
  font-family: var(--font-body, 'Work Sans', sans-serif);
  font-size: var(--text-lg, 18px);
  color: var(--text-gray, #6b687d);
}

/* ============================================
   Responsive Design
   ============================================ */

/* Tablettes (< 992px) */
@media (max-width: 991.98px) {
  .posts-grid {
    gap: 2rem;
    margin-bottom: 3rem;
  }

  /* Passer de 4 à 3 colonnes */
  .posts-grid-4-cols {
    grid-template-columns: repeat(3, 1fr);
  }

  .blog-filters {
    margin-bottom: 2.5rem;
  }

  .post-card-title {
    font-size: var(--text-lg, 20px);
  }
}

/* Tablettes moyennes (< 768px) */
@media (max-width: 767.98px) {
  .posts-grid {
    gap: 1.5rem;
    margin-bottom: 2.5rem;
  }

  /* Passer de 3 ou 4 à 2 colonnes */
  .posts-grid-3-cols,
  .posts-grid-4-cols {
    grid-template-columns: repeat(2, 1fr);
  }

  .blog-filters {
    margin-bottom: 2rem;
  }

  .filters-form {
    flex-direction: column;
    gap: 1rem;
  }

  .filter-group {
    min-width: 100%;
  }

  .post-card-content {
    padding: 1.5rem;
  }

  .post-card-title {
    font-size: var(--text-lg, 18px);
  }

  .post-card-meta {
    font-size: var(--text-xs, 12px);
  }
}

/* Mobile (< 576px) */
@media (max-width: 575.98px) {
  .posts-grid {
    gap: 1.5rem;
    margin-bottom: 2rem;
  }

  /* Tout passer en 1 colonne */
  .posts-grid-2-cols,
  .posts-grid-3-cols,
  .posts-grid-4-cols {
    grid-template-columns: 1fr;
  }

  .post-card-content {
    padding: 1.25rem;
  }

  nav[aria-label*='navigation'] {
    margin-top: 2rem;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .page-item .page-link {
    min-width: 40px;
    height: 40px;
    font-size: var(--text-sm, 14px);
  }

  .no-posts {
    padding: 3rem 1.5rem;
  }

  .no-posts h2 {
    font-size: var(--text-xl, 24px);
  }

  .no-posts p {
    font-size: var(--text-base, 16px);
  }
}
