/* Page d'accueil — layout type boutique (desktop) */
.homepage-layout {
    background: #f5f5f5; /* même fond que le body (app2) */
    padding: 1.5rem 0 2.5rem;
    margin-top: 175px; /* header + barre orange + air avant la pub */
    min-height: 50vh;
}

.homepage-layout .homepage-container {
    /* !important : app2 force .container { max-width: 100% } */
    max-width: min(980px, calc(100% - 2rem)) !important;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.homepage-sidebar-card,
.homepage-articles-panel {
    background: transparent;
    border-radius: 0;
    padding: 0.5rem 0;
    box-shadow: none !important;
    border: none;
    outline: none;
    filter: none;
}

.homepage-articles-panel {
    /* Conteneur structurel uniquement — invisible */
    background: transparent !important;
    box-shadow: none !important;
}

.homepage-sidebar-card {
    margin-bottom: 1rem;
}

.homepage-sidebar-card h5 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #f0f0f0;
}

.homepage-sidebar-card h5 i {
    color: #f57c00;
}

.homepage-articles-panel h4 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #333;
    /* Même écart qu’entre la bannière header et les articles */
    margin-bottom: 0.7rem;
}

.homepage-sidebar-form .filter-field {
    margin-bottom: 0.85rem;
}

.homepage-sidebar-form .form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 0.35rem;
}

.homepage-sidebar-form .form-control {
    font-size: 0.875rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.homepage-sidebar-form .input-with-prefix {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.homepage-sidebar-form .input-with-prefix span {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    flex-shrink: 0;
}

.homepage-sidebar-form .filter-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    font-size: 0.8125rem;
    color: #475569;
}

.homepage-sidebar-form .filter-toggle input {
    accent-color: #f57c00;
}

.homepage-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.homepage-sidebar-actions .btn-apply,
.homepage-sidebar-actions .btn-reset {
    width: 100%;
    padding: 0.65rem 1rem;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.9rem;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.homepage-sidebar-actions .btn-apply {
    background: linear-gradient(135deg, #ff9900 0%, #e68900 100%);
    color: #fff;
}

.homepage-sidebar-actions .btn-reset {
    background: #f1f5f9;
    color: #475569;
}

.homepage-sidebar-actions .btn-apply:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 153, 0, 0.35);
}

.homepage-sidebar-ads {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
}

.homepage-sidebar-ads-placeholder {
    font-size: 0.8rem;
    color: #94a3b8;
    text-align: center;
    padding: 1rem 0.5rem;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px dashed #e2e8f0;
}

.homepage-layout #articles-results {
    width: 100%;
    scroll-margin-top: 180px;
}

.homepage-articles-panel {
    scroll-margin-top: 180px;
}

/* Desktop : sidebar compacte figée à gauche, articles scrollables */
@media (min-width: 768px) {
    /*
     * overflow-x:hidden sur html/body/.container casse position:sticky
     * (overflow-y devient auto). clip évite le scroll horizontal sans casser sticky.
     */
    html:has(.homepage-layout),
    body:has(.homepage-layout) {
        overflow-x: clip !important;
    }

    body:has(.homepage-layout) .main-wrapper,
    body:has(.homepage-layout) main.flex-fill {
        overflow: visible !important;
    }

    .homepage-filter-mobile {
        display: none !important;
    }

    .homepage-layout .homepage-container {
        max-width: min(960px, calc(100% - 8rem)) !important;
        padding-left: 0;
        padding-right: 0;
        overflow: visible !important;
    }

    .homepage-row {
        display: flex;
        flex-wrap: nowrap;
        align-items: flex-start;
        justify-content: center;
        gap: 1rem;
        margin-left: 0;
        margin-right: 0;
        overflow: visible;
    }

    .homepage-sidebar-col {
        flex: 0 0 185px;
        width: 185px;
        max-width: 185px;
        padding-left: 0;
        padding-right: 0;
        position: sticky;
        top: 165px;
        align-self: flex-start;
        z-index: 5;
        max-height: calc(100vh - 200px);
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
    }

    .homepage-main-col {
        flex: 1 1 0;
        min-width: 0;
        max-width: calc(100% - 185px - 1rem);
        padding-left: 0;
        padding-right: 0;
    }

    .homepage-sidebar-card {
        padding: 0.75rem 0.85rem;
        border-radius: 12px;
        margin-bottom: 0;
        position: relative;
        top: auto;
    }

    .homepage-sidebar-card h5 {
        font-size: 0.9rem;
        margin-bottom: 0.65rem;
        padding-bottom: 0.5rem;
    }

    .homepage-sidebar-form .filter-field {
        margin-bottom: 0.6rem;
    }

    .homepage-sidebar-form .form-label {
        font-size: 0.72rem;
        margin-bottom: 0.25rem;
    }

    .homepage-sidebar-form .form-control {
        font-size: 0.78rem;
        padding: 0.35rem 0.5rem;
        border-radius: 6px;
    }

    .homepage-sidebar-form .input-with-prefix span {
        font-size: 0.65rem;
    }

    .homepage-sidebar-form .filter-toggle {
        font-size: 0.72rem;
        gap: 0.35rem;
        margin-bottom: 0.35rem;
    }

    .homepage-sidebar-form .filter-toggle input {
        width: 14px;
        height: 14px;
    }

    .homepage-sidebar-actions {
        margin-top: 0.65rem;
        gap: 0.35rem;
    }

    .homepage-sidebar-actions .btn-apply,
    .homepage-sidebar-actions .btn-reset {
        padding: 0.45rem 0.6rem;
        font-size: 0.78rem;
        border-radius: 8px;
    }

    .homepage-sidebar-ads {
        margin-top: 0.85rem;
        padding-top: 0.65rem;
    }
}

@media (min-width: 1200px) {
    .homepage-layout .homepage-container {
        max-width: min(940px, calc(100% - 14rem)) !important;
    }
}

@media (min-width: 1600px) {
    .homepage-layout .homepage-container {
        max-width: min(920px, calc(100% - 20rem)) !important;
    }
}

/* Mobile : pas de sidebar, bouton filtre d'origine */
@media (max-width: 767.98px) {
    .homepage-layout {
        margin-top: 180px; /* sans boutons cadeau / WhatsApp + air avant la pub */
        padding: 0.5rem 0 2rem;
        background: #f5f5f5;
    }

    /* Marges latérales = articles similaires (detail-container : 20px) */
    .homepage-layout .homepage-container {
        max-width: calc(100% - 12px) !important;
        width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    body.is-search-active .homepage-layout {
        margin-top: 175px;
    }

    body.is-search-active .homepage-articles-panel h4 {
        display: none;
    }

    .homepage-sidebar-col {
        display: none !important;
    }

    .homepage-articles-panel {
        border-radius: 0;
        box-shadow: none !important;
        border: none;
        padding: 0.5rem 0 0;
        background: transparent !important;
    }

    .homepage-articles-panel h4 {
        margin-top: 0.25rem;
        margin-bottom: 0.65rem;
        padding-left: 2px;
    }

    /* Même écart que les articles similaires (Bootstrap g-3 = 1rem) */
    .homepage-layout #articles-results .row {
        --bs-gutter-x: 1rem;
        --bs-gutter-y: 1rem;
    }

    .homepage-filter-mobile {
        position: relative;
        height: 0;
        margin: 0;
        pointer-events: none;
    }

    .homepage-filter-mobile .filter-btn {
        position: fixed;
        top: 172px; /* sous la barre orange (évite le chevauchement) */
        right: 10px;
        z-index: 99;
        display: none;
        align-items: center;
        gap: 6px;
        padding: 4px 10px;
        background: #3498db;
        border: 1px solid #fff;
        color: #fff;
        cursor: pointer;
        border-radius: 6px;
        box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
        transform-origin: right center;
        pointer-events: auto;
    }

    .homepage-filter-mobile .filter-btn.is-fixed {
        position: fixed;
        top: 172px;
        right: 10px;
        box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
        animation: filterBtnSlideIn 0.7s ease-out forwards;
    }

    .homepage-filter-mobile .filter-btn.is-unfixing {
        position: fixed;
        top: 172px;
        right: 10px;
        animation: filterBtnSlideOut 0.7s ease-in forwards;
    }

    .homepage-filter-mobile .filter-btn:hover {
        background: #2980b9;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
    }

    .homepage-filter-mobile .filter-btn:active {
        transform: scale(0.98);
    }

    #openFilter.disparaitre {
        opacity: 0;
        height: 0;
        overflow: hidden;
    }
}

/* Très petits écrans : même padding que detail-container (articles similaires) */
@media (max-width: 480px) {
    .homepage-layout .homepage-container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
}

@keyframes filterBtnSlideIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes filterBtnSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}
