/**
 * Aratice Quote Builder - Layout Principal
 * Styles pour le widget Quote Builder (page de devis)
 */

/* === Container Principal === */
.aratice-quote-builder-wrapper {
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* === En-tête de page === */
.aqb-page-header {
    margin-bottom: 30px;
}

.aqb-page-title {
    font-size: 32px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 15px 0;
    line-height: 1.2;
}

.aqb-page-description {
    font-size: 16px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
}

.aqb-page-description strong {
    font-weight: 600;
    color: #333;
}

/* === Layout 3 colonnes === */
.aqb-layout {
    display: grid;
    grid-template-columns: 250px 1fr 600px;
    gap: 16px;
    align-items: flex-start;
}

/* Filtres à gauche */
.aqb-layout .apg-filters {
    order: 1;
}

/* Contenu au centre */
.aqb-main-content {
    order: 2;
    min-width: 0;
}

/* Sidebar droite (Récapitulatif + Aide) */
.aqb-sidebar {
    order: 3;
    position: relative;
}

body:has(.header-hidden) .aqb-sidebar {
    top: 50px !important;
}

.aqb-sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-self: flex-start;
}

/* === Zone Produits === */
.aqb-products-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 30px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* Les attributs data-columns deviennent des suggestions minimales mais s'adaptent */
.aqb-products-grid[data-columns="2"] {
    grid-template-columns: repeat(auto-fit, minmax(max(220px, calc((100% - 20px) / 2)), 1fr));
}

.aqb-products-grid[data-columns="3"] {
    grid-template-columns: repeat(auto-fit, minmax(max(220px, calc((100% - 40px) / 3)), 1fr));
}

.aqb-products-grid[data-columns="4"] {
    grid-template-columns: repeat(auto-fit, minmax(max(220px, calc((100% - 60px) / 4)), 1fr));
}

/* === Aucun produit === */
.aqb-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;
}

.aqb-no-products-icon {
    margin-bottom: 24px;
    color: #cbd5e0;
}

.aqb-no-products-icon svg {
    width: 80px;
    height: 80px;
    stroke-width: 1.5;
}

.aqb-no-products-title {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 12px 0;
}

.aqb-no-products-message {
    font-size: 16px;
    color: #7f8c8d;
    margin: 0;
    max-width: 400px;
    line-height: 1.6;
}

/* === Pagination === */
.aqb-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 30px;
}

.aqb-pagination a,
.aqb-pagination span {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
}

.aqb-pagination a:hover {
    background: #163C79;
    color: #fff;
    border-color: #163C79;
}

.aqb-pagination .current {
    background: #163C79;
    color: #fff;
    border-color: #163C79;
}

/* === Responsive === */
/* Le système auto-fit gère automatiquement l'adaptation des colonnes */

@media (max-width: 1120px) {
    .aqb-layout {
        grid-template-columns: 280px 1fr 440px;
    }
}

@media (max-width: 992px) {

    /* Passer à 2 colonnes : filtres en modal + contenu + sidebar */
    .aqb-layout {
        grid-template-columns: 1fr 400px;
        gap: 30px;
    }

    /* Filtres passent en modal mobile (géré par products-filters.css) */
    .aqb-layout .apg-filters {
        order: 1;
    }

    .aqb-main-content {
        order: 2;
    }

    .aqb-sidebar {
        order: 3;
        position: static;
        max-height: none;
        overflow-y: visible;
    }
}

@media (max-width: 768px) {

    /* Passer à 1 colonne pour le layout principal */
    .aqb-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .aqb-page-title {
        font-size: 24px;
    }

    .aqb-page-description {
        font-size: 14px;
    }

    /* Adapter la grille pour mobile avec auto-fit */
    .aqb-products-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
        gap: 16px;
    }

    .aqb-no-products {
        padding: 60px 20px;
        min-height: 300px;
    }

    .aqb-no-products-icon svg {
        width: 60px;
        height: 60px;
    }

    .aqb-no-products-title {
        font-size: 20px;
    }

    .aqb-no-products-message {
        font-size: 14px;
    }
}

@media (max-width: 600px) {

    /* Passer à 1 colonne pour les produits en dessous de 600px */
    .aqb-products-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 4px;
    }
}

@media (max-width: 576px) {
    .aqb-page-title {
        font-size: 20px;
    }
}

/* === Onglets Mobile === */
.aqb-mobile-tabs {
    display: none;
    background: #fff;
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    gap: 8px;
}

.aqb-tab-text {
    font-size: clamp(10px, 2.5vw, 14px);
}

.aqb-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.aqb-tab-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.aqb-tab-btn.active {
    background: #2B4B7C;
    color: #fff;
}

.aqb-tab-badge {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #ef4444;
    color: #fff;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.aqb-tab-badge.show {
    display: inline-flex;
}

.aqb-tab-btn.active .aqb-tab-badge {
    background: #fff;
    color: #2B4B7C;
}

/* Afficher les onglets en mobile */
@media (max-width: 768px) {
    .aqb-mobile-tabs {
        display: flex;
    }

    /* Cacher le catalogue par défaut (filtres + contenu + bouton filtres mobile) */
    .aratice-quote-builder-wrapper .apg-filters-mobile-toggle,
    .aratice-quote-builder-wrapper .aqb-layout .apg-filters,
    .aratice-quote-builder-wrapper .aqb-main-content {
        display: none !important;
    }

    /* Cacher la sidebar par défaut */
    .aratice-quote-builder-wrapper .aqb-sidebar {
        display: none !important;
    }

    /* Afficher le catalogue quand l'onglet est actif */
    .aratice-quote-builder-wrapper.aqb-tab-catalogue-active .apg-filters-mobile-toggle {
        display: flex !important;
    }

    .aratice-quote-builder-wrapper.aqb-tab-catalogue-active .aqb-layout .apg-filters,
    .aratice-quote-builder-wrapper.aqb-tab-catalogue-active .aqb-main-content {
        display: block !important;
    }

    /* Afficher le devis quand l'onglet est actif */
    .aratice-quote-builder-wrapper.aqb-tab-devis-active .aqb-sidebar {
        display: flex !important;
    }

    /* S'assurer que les filtres et le bouton sont bien masqués sur l'onglet devis */
    .aratice-quote-builder-wrapper.aqb-tab-devis-active .apg-filters-mobile-toggle,
    .aratice-quote-builder-wrapper.aqb-tab-devis-active .aqb-layout .apg-filters,
    .aratice-quote-builder-wrapper.aqb-tab-devis-active .aqb-main-content {
        display: none !important;
    }
}

@media (max-width: 576px) {
    .aqb-tab-btn {
        padding: 8px;
    }
}

@media (max-width: 380px) {
    .aqb-tab-btn {
        padding: 8px;
        gap: 4px;
    }
}

/* === Compteur dans le menu "Mon devis" === */
#my-quote {
    display: flex;
    justify-content: center;
    gap: 8px;
}

#my-quote .quote-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #EAF7FA;
    color: #2B4B7C;
    font-size: 14px;
    font-weight: 700;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 20px;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    font-family: 'Lexend Deca';
}

/* === Compteur mobile dans le header === */
#my-quote-mobile {
    position: relative;
}

#my-quote-mobile .quote-count-mobile {
    position: absolute;
    top: -6px;
    right: -6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #EAF7FA;
    color: #2B4B7C;
    font-size: 12px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 1;
}