.formule-tabs {
    max-width: 100vw;
    width: 100%;
    overflow-x: hidden;
    position: relative;
    margin-bottom: 10em;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

.tab-buttons {
    display: flex;
    justify-content: center;
    margin: 8em auto 4em auto;
    max-width: min(80%, 1000px);
    border: 1px solid #ccc;
    border-radius: 37px;
    padding: 0.3em;
}

.tab-button {
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    flex: 1;
    text-align: center;
    border-radius: 37px;
    transition: background-color 0.3s, color 0.3s;
    background-color: rgb(240, 244, 247);
}

.tab-button.active-tab {
    background: #ff5100;
    color: white;
}

.tab-content {
    padding: 2em;
    background-color: white;
    border-radius: 8px;
}

.tab-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.tab-header .icon {
    flex: 0 0 25%;
    max-width: 14%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    aspect-ratio: 1 / 1;
    margin-right: 5em;
}

.tab-header .text {
    flex: 0 0 75%;
    max-width: 75%;
    padding-left: 1rem;
}

.tab-header .text h2 {
    margin: 0;
}

.tab-header .text p {
    margin: 0.5em 0 0 0;
    text-align: left;
    line-height: 1.5em;
    opacity: 60%;
}

h4 {
    font-size: 1.2em;
    margin-bottom: 1em;
    font-weight: 500;
}

.icon-line {
    padding-left: 2em;
    background-repeat: no-repeat;
    background-position: left center;
    background-size: 1em;
}

hr.section-line {
    border: 0;
    border-top: 2px solid rgba(109, 149, 174, 0.1);
    margin-bottom: 20px;
}

.why-blocks, .when-blocks {
    margin-bottom: 20px;
}

.why-blocks p, .when-blocks p {
    text-align: left;
    line-height: 1.5em;
    opacity: 60%;
}

/*HOMEPAGE FORMULA*/

#home-formula-title {
    text-align: center;
    width: min(90%, 800px);
    margin: 3em auto -1em auto;
    font-size: clamp(1.8em, 4vw, 2.5em);
}

.homepage-formulas h2 {
    line-height: 1.2;
}

.homepage-formulas .tab-header {
    display: flex;
    margin-bottom: 0;
    background: white;
    border-radius: 16px;
}

.homepage-formulas .tab-header .text {
    flex: 0 0 60%;
    max-width: 60%;
    display: flex;
    flex-direction: column;
    padding-right: 2em;
}

.homepage-formulas .tab-header .text h2{
    font-size: clamp(1.5em, 3vw, 2em);
}

.homepage-formulas .tab-header .icon {
    flex: 0 0 40%;
    max-width: 40%;
    border-radius: 8px;
}

.homepage-formulas .tab-header .icon-inner {
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-position: center;
}
.homepage-formulas .tab-content {
    padding: 0;
}

.homepage-formulas .swiper-slide {
    max-width: min(52vw, 800px);
}

.homepage-formulas .cta-button {
    margin-top: 3em;
}

/* Tablet responsive fixes */
@media (max-width: 1024px) {
    .tab-buttons {
        margin: 4em auto 2em auto;
        max-width: 90%;
    }
    
    .homepage-formulas .swiper-slide {
        max-width: 70vw;
    }
    
    .tab-header .icon {
        margin-right: 3em;
    }
}

/* Small tablet adjustments */
@media (max-width: 820px) {
    .tab-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .tab-header .icon {
        max-width: 60%;
        margin-right: 0;
        margin-bottom: 1em;
    }
    
    .tab-header .text {
        max-width: 100%;
        padding-left: 0;
    }
    
    .homepage-formulas .swiper-slide {
        max-width: 85vw;
    }
}

@media (max-width: 768px) {
    .tab-buttons {
        flex-direction: column;
        margin: 2em auto;
        padding: 0.5em;
        border-radius: 20px;
        max-width: calc(100vw - 4em);
        width: fit-content;
        align-self: center;
        box-sizing: border-box;
    }

    .tab-button {
        margin: 0.2em 0;
        font-size: 1em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .swiper {
        padding: 0 1em;
        margin-top: 2em;
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .homepage-formulas .swiper-slide {
        max-width: 95vw;
        margin: 0 auto;
    }

    .swiper-slide {
        max-width: 100%;
        margin: 0 auto;
    }

    .tab-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .tab-header .icon {
        max-width: 40%;
        margin-right: 0;
        margin-bottom: 1em;
    }

    .tab-header .text {
        max-width: 100%;
        padding-left: 0;
    }

    .tab-content {
        padding: 1em;
        margin: 0 auto;
        max-width: calc(100vw - 2em);
        width: calc(100vw - 2em);
        box-sizing: border-box;
    }

    .icon-line {
        padding-left: 2em;
        background-position: left top;
        line-height: 1.2em;
        display: block;
        margin-top: 1em;
    }

    .swiper-wrapper {
        transform: none !important;
        display: block !important;
    }

    .swiper-slide {
        visibility: hidden;
        height: 0;
        overflow: hidden;
        pointer-events: none;
    }

    .swiper-slide.swiper-slide-active {
        visibility: visible;
        height: auto;
        overflow: visible;
        pointer-events: auto;
        margin: 0 auto;
        text-align: center;
    }

    #home-formula-title {
        font-size: 1.8em;
        width: 100%;
        margin-bottom: 1em;
        margin-top: 1em;
        text-align: center;
    }
    
    /* Ensure all content is centered on mobile */
    .formule-tabs {
        text-align: center;
        padding: 0;
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    /* Make sure tab content is centered */
    .formule-tabs .tab-content {
        margin: 0 auto;
        max-width: 100%;
        text-align: left;
    }
    
    .homepage-formulas {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .homepage-formulas .tab-content {
        width: 100%;
        max-width: 95vw;
        margin: 0 auto;
    }
    
    /* Specific fix for formula page (non-homepage) */
    .formule-tabs:not(.homepage-formulas) {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }
    
    .formule-tabs:not(.homepage-formulas) .tab-content {
        width: calc(100vw - 2em);
        max-width: calc(100vw - 2em);
        margin: 0 auto;
        box-sizing: border-box;
    }
    
    /* Prevent horizontal scroll issues */
    body {
        overflow-x: hidden;
    }
    
    .tab-header .text,
    .tab-header .icon,
    .why-blocks,
    .when-blocks {
        max-width: 100%;
        box-sizing: border-box;
    }
}