/**
 * Styles améliorés pour le plugin Catalogue Manager v2.0
 */

/* === Conteneur principal === */
.cm-catalogue-wrapper {
  width: 100%;
  margin: 0 auto;
}

/* === Filtres Améliorés === */
.cm-filters {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
  align-items: center;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
}

.cm-filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 200px;
}

.cm-filter-group label {
  font-weight: 600;
  color: #333;
  white-space: nowrap;
}

.cm-filter-select {
  flex: 1;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 5px;
  background: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.cm-filter-select:hover {
  border-color: #0073aa;
}

.cm-filter-select:focus {
  outline: none;
  border-color: #0073aa;
  box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

/* === Grille de produits === */
.cm-products-grid {
  display: grid;
  gap: 20px;
  margin-bottom: 30px;
}

/* Responsive columns */
@media (max-width: 1200px) {
  .cm-products-grid[data-columns="6"],
  .cm-products-grid[data-columns="5"] {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

@media (max-width: 992px) {
  .cm-products-grid[data-columns="6"],
  .cm-products-grid[data-columns="5"],
  .cm-products-grid[data-columns="4"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

@media (max-width: 768px) {
  .cm-products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 480px) {
  .cm-products-grid {
    grid-template-columns: 1fr !important;
  }
}

/* === Carte produit === */
.cm-product-card {
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.cm-product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

/* === Image produit === */
.cm-product-image {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #f5f5f5;
}

.cm-product-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.cm-product-card:hover .cm-product-image img {
  transform: scale(1.05);
}

/* === Contenu produit === */
.cm-product-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.cm-product-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0;
  line-height: 1.4;
  min-height: 50px;
}

.cm-product-price {
  font-size: 24px;
  font-weight: 700;
  color: #0073aa;
  margin: 0;
}

/* Masquer les prix si désactivé */
.cm-prices-hidden .cm-product-price {
  display: none;
}

.cm-product-excerpt {
  font-size: 14px;
  color: #666;
  line-height: 1.6;
  flex: 1;
}

/* === Bouton === */
.cm-product-button {
  display: inline-block;
  width: 100%;
  padding: 12px 20px;
  background: #156a2b;
  color: white;
  text-align: center;
  text-decoration: none;
  border-radius: 5px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
}

.cm-product-button:hover {
  background: #218838;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

/* États dynamiques du bouton panier */
.cm-product-button.in-cart {
  background: #28a745;
}

.cm-product-button.in-cart:hover {
  background: #218838;
}

/* === Message aucun produit === */
.cm-no-products {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  font-size: 18px;
  color: #666;
  background: #f8f9fa;
  border-radius: 8px;
}

/* === Loading state === */
.cm-products-grid.cm-loading {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

.cm-products-grid.cm-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #0073aa;
  border-radius: 50%;
  animation: cm-spin 1s linear infinite;
}

@keyframes cm-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* === Responsive filters === */
@media (max-width: 768px) {
  .cm-filters-container {
    flex-direction: column;
    gap: 15px;
  }

  .cm-filter-group {
    width: 100%;
    min-width: 100%;
  }
  
  .cm-filter-reset {
    width: 100%;
    justify-content: center;
  }
}

/* === Styles du panier améliorés === */
.cm-cart-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.cm-cart-title {
    font-size: 32px;
    font-weight: 700;
    color: #333;
    margin: 0 0 30px 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.cm-cart-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.cm-cart-empty {
    text-align: center;
    padding: 60px 20px;
    font-size: 18px;
    color: #666;
}

.cm-cart-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

.cm-cart-table thead th {
    text-align: left;
    padding: 15px;
    border-bottom: 2px solid #e0e0e0;
    font-weight: 600;
    color: #333;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cm-cart-table tbody td {
    padding: 20px 15px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.cm-cart-item-title {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.cm-cart-item-price,
.cm-cart-item-subtotal {
    font-weight: 600;
    color: #0073aa;
    font-size: 16px;
}

/* Masquer les prix du panier si désactivé */
.cm-prices-hidden .cm-cart-item-price,
.cm-prices-hidden .cm-cart-item-subtotal,
.cm-prices-hidden .cm-cart-total {
    display: none;
}

.cm-prices-hidden .cm-cart-table thead th:nth-child(2),
.cm-prices-hidden .cm-cart-table thead th:nth-child(4) {
    display: none;
}

.cm-qty-input {
    width: 70px;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    transition: border-color 0.3s ease;
}

.cm-qty-input:focus {
    outline: none;
    border-color: #0073aa;
}

.cm-remove-item {
    width: 32px;
    height: 32px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cm-remove-item:hover {
    background: #cc0000;
    transform: rotate(90deg) scale(1.1);
}

.cm-cart-table tfoot td {
    padding: 25px 15px;
    font-size: 20px;
    border-top: 2px solid #e0e0e0;
}

.cm-cart-total {
    color: #0073aa;
    font-size: 24px;
}

.cm-cart-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.cm-cart-button {
    padding: 15px 30px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cm-cart-button:hover {
    background: #005a87;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.cm-clear-cart {
    background: #dc3545;
}

.cm-clear-cart:hover {
    background: #c82333;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.cm-request-quote {
    background: #28a745;
}

.cm-request-quote:hover {
    background: #218838;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* Responsive panier */
@media (max-width: 768px) {
    .cm-cart-table {
        font-size: 14px;
    }

    .cm-cart-table thead {
        display: none;
    }

    .cm-cart-table tbody tr {
        display: block;
        margin-bottom: 20px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 15px;
    }

    .cm-cart-table tbody td {
        display: block;
        text-align: right;
        padding: 10px 0;
        border-bottom: none;
    }

    .cm-cart-table tbody td::before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
    }

    .cm-cart-table tfoot {
        display: block;
    }

    .cm-cart-table tfoot tr {
        display: block;
    }

    .cm-cart-table tfoot td {
        display: block;
        text-align: center;
    }

    .cm-cart-actions {
        flex-direction: column;
    }
    
    .cm-cart-button {
        width: 100%;
        justify-content: center;
    }
}

/* === Bouton retour catalogue (pour single-produit) === */
.cm-back-to-catalogue {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: #f8f9fa;
    color: #333;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-bottom: 30px;
    border: 2px solid #e0e0e0;
}

.cm-back-to-catalogue:hover {
    background: #e0e0e0;
    border-color: #d0d0d0;
    transform: translateX(-5px);
}

.cm-back-to-catalogue svg {
    width: 20px;
    height: 20px;
}

/* === Styles pour les états des boutons === */
.cm-add-to-cart-btn {
    position: relative;
    overflow: hidden;
}

.cm-add-to-cart-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.cm-add-to-cart-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Actions des produits avec boutons horizontaux */
.cm-product-actions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: auto;
}

.cm-product-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
}

.cm-product-button svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.cm-product-view-more {
    background: #28a745 !important;
}

.cm-product-view-more:hover {
    background: #218838 !important;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.cm-product-button.in-cart {
    background: #28a745;
    cursor: not-allowed;
}

.cm-product-button.in-cart:hover {
    background: #218838;
    transform: none;
}

/* Responsive - empiler sur mobile */
@media (max-width: 480px) {
    .cm-product-actions {
        flex-direction: column;
    }
}

/* Style de base pour la pagination */
.cm-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 40px 0 20px;
    padding: 0;
    list-style: none;
    gap: 8px;
    flex-wrap: wrap;
}

.cm-pagination a,
.cm-pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    color: #333;
    background-color: #f8f9fa;
}

.cm-pagination a:hover {
    background-color: #156A2B;
    color: #ffffff !important;
    border-color: #156A2B;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
}

.cm-pagination span.current {
    background-color: #156A2B;
    color: #ffffff !important;
    border-color: #156A2B;
    font-weight: 600;
}

.cm-pagination span.dots {
    background-color: transparent;
    border: none;
    color: #666;
    min-width: auto;
}

/* Style pour les boutons précédent/suivant */
.cm-pagination .prev,
.cm-pagination .next {
    font-weight: 600;
    padding: 0 16px;
}

.cm-pagination .prev:hover,
.cm-pagination .next:hover {
    background-color: #156A2B;
}

/* États désactivés */
.cm-pagination .disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f8f9fa;
    color: #999;
}

.cm-pagination .disabled:hover {
    background-color: #f8f9fa;
    color: #999;
    border-color: #ddd;
    transform: none;
    box-shadow: none;
}

/* Responsive */
@media (max-width: 768px) {
    .cm-pagination {
        gap: 6px;
        margin: 30px 0 15px;
    }
    
    .cm-pagination a,
    .cm-pagination span {
        min-width: 36px;
        height: 36px;
        padding: 0 10px;
        font-size: 13px;
    }
    
    .cm-pagination .prev,
    .cm-pagination .next {
        padding: 0 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .cm-pagination {
        gap: 4px;
    }
    
    .cm-pagination a,
    .cm-pagination span {
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        font-size: 12px;
    }
    
    .cm-pagination .prev,
    .cm-pagination .next {
        padding: 0 10px;
        font-size: 12px;
    }
}

/* Animation de chargement pour la pagination AJAX (optionnel) */
.cm-pagination.loading {
    opacity: 0.7;
    pointer-events: none;
}

.cm-pagination.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Style alternatif pour la pagination */
.cm-pagination.style-minimal a,
.cm-pagination.style-minimal span {
    background-color: transparent;
    border: none;
    color: #666;
}

.cm-pagination.style-minimal a:hover,
.cm-pagination.style-minimal span.current {
    background-color: transparent;
    color: #0073aa;
    text-decoration: underline;
}

/* Style avec bordures arrondies */
.cm-pagination.style-rounded a,
.cm-pagination.style-rounded span {
    border-radius: 20px;
}

/* Style avec ombres */
.cm-pagination.style-shadow a {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cm-pagination.style-shadow a:hover {
    box-shadow: 0 4px 8px rgba(0, 115, 170, 0.3);
}

/* Variante moderne */
.cm-pagination.modern {
    gap: 12px;
}

.cm-pagination.modern a,
.cm-pagination.modern span {
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Variante discrète */
.cm-pagination.subtle a,
.cm-pagination.subtle span {
    background-color: transparent;
    border: 1px solid #e9ecef;
    color: #6c757d;
}

.cm-pagination.subtle a:hover,
.cm-pagination.subtle span.current {
    background-color: #0073aa;
    color: #ffffff;
    border-color: #0073aa;
}

/* Variante avec icônes */
.cm-pagination.with-icons .prev::before {
    content: '←';
    margin-right: 6px;
}

.cm-pagination.with-icons .next::after {
    content: '→';
    margin-left: 6px;
}