/**
 * Aratice Products Grid - Main Content Styles
 * Styles pour products-grid-main.php
 */

/* === Zone Produits === */
.apg-products-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Grille - 3 colonnes par défaut avec adaptation automatique */
.apg-products-grid[data-view="grid"] {
    grid-template-columns: repeat(auto-fill, minmax(max(220px, calc((100% - 40px) / 3)), 1fr));
}

.apg-products-grid[data-view="grid"][data-columns="2"] {
    grid-template-columns: repeat(auto-fill, minmax(max(220px, calc((100% - 20px) / 2)), 1fr));
}

.apg-products-grid[data-view="grid"][data-columns="4"] {
    grid-template-columns: repeat(auto-fill, minmax(max(220px, calc((100% - 60px) / 4)), 1fr));
}

/* Liste - 1 colonne - Force un seul produit par ligne */
.apg-products-grid[data-view="list"] {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Sans filtres - grille pleine largeur avec adaptation */
.apg-products-grid.apg-no-filters[data-view="grid"] {
    grid-template-columns: repeat(auto-fill, minmax(max(220px, calc((100% - 60px) / 4)), 1fr));
}

/* === Aucun produit === */
.apg-no-products {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 40px;
    min-height: 400px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 16px;
    border: 2px dashed #e0e0e0;
    grid-column: 1 / -1;
    /* Prend toute la largeur de la grille */
}

.apg-no-products-icon {
    margin-bottom: 24px;
    color: #cbd5e0;
    animation: fadeInScale 0.5s ease-out;
}

.apg-no-products-icon svg {
    width: 80px;
    height: 80px;
    stroke-width: 1.5;
}

.apg-no-products-title {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 12px 0;
    animation: fadeInUp 0.6s ease-out;
}

.apg-no-products-message {
    font-size: 16px;
    color: #7f8c8d;
    margin: 0;
    max-width: 400px;
    line-height: 1.6;
    animation: fadeInUp 0.7s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Pagination === */
.apg-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 30px;
}

.apg-pagination a,
.apg-pagination span {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
}

.apg-pagination a:hover {
    background: #163C79;
    color: #fff;
    border-color: #163C79;
}

.apg-pagination .current {
    background: #163C79;
    color: #fff;
    border-color: #163C79;
}

/* ===== Load More (remplace la pagination) ===== */
.apg-load-more-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 20px 16px;
}

.apg-load-more-wrapper[hidden] {
    display: none;
}

.apg-load-more-counter {
    font-size: 13px;
    font-weight: 500;
    color: #7F8C8D;
    margin: 0;
    font-family: 'Lexend', sans-serif;
    letter-spacing: 0.2px;
    text-align: center;
}

.apg-load-more-loaded,
.apg-load-more-total {
    font-weight: 700;
    color: #163C79;
}

.apg-load-more-progress {
    width: 100%;
    max-width: 280px;
    height: 4px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 4px;
}

.apg-load-more-progress-bar {
    height: 100%;
    background: #163C79;
    border-radius: 999px;
    transition: width 0.4s ease;
}

.apg-load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px 28px;
    background: #163C79;
    color: #ffffff;
    border: 1px solid #163C79;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Lexend', sans-serif;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apg-load-more-btn:hover:not(:disabled) {
    background: #0f2a5a;
    border-color: #0f2a5a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 60, 121, 0.2);
}

.apg-load-more-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(22, 60, 121, 0.15);
}

.apg-load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.apg-load-more-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: apgLoadMoreSpin 0.7s linear infinite;
}

.apg-load-more-btn.is-loading .apg-load-more-icon {
    display: none;
}

.apg-load-more-btn.is-loading .apg-load-more-spinner {
    display: inline-block;
}

@keyframes apgLoadMoreSpin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 576px) {
    .apg-load-more-wrapper {
        margin-top: 32px;
    }

    .apg-load-more-btn {
        padding: 11px 22px;
        font-size: 13px;
    }

    .apg-load-more-counter {
        font-size: 12px;
    }
}

/* Fallback SEO (<noscript>) : pagination classique pour bots/JS désactivé */
.apg-seo-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.apg-seo-pagination a,
.apg-seo-pagination span {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #163C79;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.apg-seo-pagination a:hover {
    background: #163C79;
    color: #fff;
    border-color: #163C79;
}

.apg-seo-pagination .current {
    background: #163C79;
    color: #fff;
    border-color: #163C79;
}

/* Mise en valeur temporaire de la carte visitée au retour */
.apg-product-card.apg-restored-highlight {
    animation: apgRestoredPulse 2s ease-out;
    position: relative;
    z-index: 1;
}

@keyframes apgRestoredPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(22, 60, 121, 0.5);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(22, 60, 121, 0.15);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(22, 60, 121, 0);
    }
}

/* === Loader === */
.apg-loading {
    position: relative;
    opacity: 0.5 !important;
    pointer-events: none;
}

.apg-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

.apg-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0066cc;
    border-radius: 50%;
    animation: apg-spin 1s linear infinite;
}

/* Petit spinner pour les boutons */
.apg-spinner-small {
    width: 16px;
    height: 16px;
    border-width: 2px;
    vertical-align: middle;
    margin-right: 4px;
}

@keyframes apg-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* === Responsive === */
/* Le système auto-fit gère automatiquement l'adaptation, 
   mais on force certains comportements sur petits écrans */

@media (max-width: 550px) {

    /* Vue liste : Assurer la vue en colonne */
    .apg-products-grid[data-view="list"] {
        grid-template-columns: 1fr !important;
    }

    .apg-products-grid[data-view="list"] .apg-product-card {
        flex-direction: column !important;
    }
}

@media (max-width: 768px) {
    .apg-no-products {
        padding: 60px 20px;
        min-height: 300px;
    }

    .apg-no-products-icon svg {
        width: 60px;
        height: 60px;
    }

    .apg-no-products-title {
        font-size: 20px;
    }

    .apg-no-products-message {
        font-size: 14px;
    }
}

@media (max-width: 600px) {

    /* Passer à 1 colonne sur petit mobile */
    .apg-products-grid[data-view="grid"] {
        grid-template-columns: 1fr 1fr !important;
    }

    .apg-products-grid.apg-no-filters[data-view="grid"] {
        grid-template-columns: 1fr !important;
    }
}