/* ====================================
   Sistema Filtraggio Articoli - CSS
   Versione: 1.10.3
   ==================================== */

.article-filter-system {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* === MESSAGGIO AUTH === */
.article-filter-auth-message {
    text-align: center;
    padding: 40px 20px;
    color: #82908D;
    font-size: 16px;
    background: #f8f9fa;
    border-radius: 12px;
    margin: 20px 0;
}

/* === SEZIONE FILTRI === */
.filter-section {
    margin-bottom: 40px;
}

.articles-grid {
    min-height: 300px;
}

.filters-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-label {
    font-size: 21px;
    color: #82908D;
    margin-bottom: 0;
    margin-right: 20px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-group {
    position: relative;
    flex-shrink: 0;
}

.filter-group select {
    padding: 7px 13px 7px 13px;
    border: 2px solid #2FC3B2;
    border-radius: 16px;
    font-size: 16px !important;
    background-color: white;
    color: #82908D !important;
    min-width: 264px;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.filter-group > #filter-tipologia {
    min-width: 329px;
}

.filter-group select:focus {
    outline: none;
    border-color: #2FC3B2;
}

.filter-group::after {
    content: "▼";
    position: absolute;
    right: 15px;
    top: 60%;
    transform: translateY(-50%);
    color: #2FC3B2;
    pointer-events: none;
    font-size: 12px;
}

/* Nasconde la freccia ▼ nel gruppo ricerca (input testuale) */
.filter-search-group::after {
    display: none;
}

.filter-group select:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

/* === RESET COMBO === */
.combo-reset-anno,
.combo-reset-tipologia,
.combo-reset-search {
    position: absolute;
    top: -8px;
    right: -14px;
    background: #2FC3B2;
    color: white;
    border: none;
    width: 24px;
    height: 30px;
    border-radius: 50%;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    display: none;
    z-index: 10;
    line-height: 1;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(47, 195, 178, 0.3);
    align-items: center;
    justify-content: center;
    text-align: center;
}

.combo-reset-anno:hover,
.combo-reset-tipologia:hover,
.combo-reset-search:hover {
    background: #26b8a8;
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(47, 195, 178, 0.4);
}

.combo-reset-anno.show,
.combo-reset-tipologia.show,
.combo-reset-search.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-group select,
.filter-group .filter-search,
.filter-label {
    margin-top: 8px;
}

/* === CAMPO RICERCA === */
.filter-search-group {
    position: relative;
}

.filter-search {
    padding: 7px 35px 7px 13px;
    border: 2px solid #2FC3B2;
    border-radius: 16px;
    font-size: 16px;
    background-color: white;
    color: #82908D;
    min-width: 264px;
    transition: border-color 0.3s ease;
}

.filter-search:focus {
    outline: none;
    border-color: #2FC3B2;
}

.filter-search::placeholder {
    color: #82908D;
    opacity: 0.7;
}

.filter-search:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

/* === ANIMAZIONE RICERCA SCIENTIFICA === */
.scientific-loading {
    position: relative;
    text-align: center;
    padding: 80px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    overflow: hidden;
}

.scientific-loading::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(78, 205, 196, 0.1), transparent);
    animation: scanLine 2s infinite;
}

.loading-content {
    position: relative;
    z-index: 2;
}

.magnifying-glass {
    width: 60px;
    height: 60px;
    border: 4px solid #2FC3B2;
    border-radius: 50%;
    position: relative;
    margin: 0 auto 20px;
    animation: magnifyRotate 2s infinite ease-in-out;
}

.magnifying-glass::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 4px;
    background: #2FC3B2;
    bottom: -10px;
    right: -10px;
    border-radius: 2px;
    transform: rotate(45deg);
    animation: handleMove 1s infinite ease-in-out;
}

.research-docs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.doc-icon {
    width: 30px;
    height: 40px;
    background: #2FC3B2;
    border-radius: 4px;
    position: relative;
    animation: docFloat 1.5s infinite ease-in-out;
}

.doc-icon:nth-child(1) { animation-delay: 0s; background: #2FC3B2; }
.doc-icon:nth-child(2) { animation-delay: 0.3s; background: #45b7d1; }
.doc-icon:nth-child(3) { animation-delay: 0.6s; background: #96ceb4; }
.doc-icon:nth-child(4) { animation-delay: 0.9s; background: #feca57; }

.doc-icon::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 4px;
    right: 4px;
    height: 2px;
    background: white;
    border-radius: 1px;
    box-shadow: 0 6px 0 white, 0 12px 0 white, 0 18px 0 white;
}

.loading-text {
    font-size: 16px;
    color: #666;
    font-weight: 600;
    margin-top: 15px;
    animation: textPulse 2s infinite ease-in-out;
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    margin: 15px auto 0;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2FC3B2, #45b7d1, #96ceb4);
    border-radius: 2px;
    animation: progressMove 2s infinite ease-in-out;
}

@keyframes scanLine {
    0% { left: -100%; }
    100% { left: 100%; }
}

@keyframes magnifyRotate {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(10deg) scale(1.1); }
}

@keyframes handleMove {
    0%, 100% { transform: rotate(45deg) translateY(0); }
    50% { transform: rotate(45deg) translateY(-3px); }
}

@keyframes docFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(2deg); }
}

@keyframes textPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes progressMove {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200px); }
}

/* === INFO RISULTATI === */
.results-info {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 25px;
    padding: 15px 0;
}

.results-count {
    font-weight: 600;
    color: #82908D;
    font-size: 14px;
}

/* === GRIGLIA ARTICOLI === */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 37px 57px;
    margin-bottom: 40px;
}

/* Carosello: usa flexbox per navigazione */
.article-carousel .articles-grid {
    display: flex;
    gap: 37px 57px;
    justify-content: start;
    align-items: center;
    transition: transform 0.4s ease;
    width: fit-content;
    position: relative;
}

.article-carousel .article-card {
    width: 342px;
    flex-shrink: 0;
    min-width: 342px;
    display: none;
    opacity: 0;
    transform: translateX(30px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.article-carousel .article-card.carousel-animate {
    display: block;
    transform: translateX(0);
    animation: carouselSlideIn 0.3s ease-in-out forwards;
}

.article-card {
    border-radius: 15px;
    overflow: hidden;
    opacity: 1;
}

/* === IMMAGINE ARTICOLO === */
.article-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    overflow: hidden;
}

/* Overlay gradiente sopra l'immagine - usa CSS var */
.article-image::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--afs-overlay-color, linear-gradient(180deg, #37CCDC 0%, #FFD23E 50%, #F26700 100%));
    opacity: var(--afs-overlay-opacity, 0.34);
    z-index: 1;
    pointer-events: none;
    border-radius: 15px;
}

.article-tags {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    max-width: calc(100% - 30px);
    z-index: 2;
}

.article-tag {
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--afs-tag-text-color, white);
    background-color: var(--afs-tag-color, #2FC3B2);
    white-space: nowrap;
}

/* === CONTENUTO ARTICOLO === */
.article-content {
    padding-top: 10px;
}

.article-title {
    font-size: 26px;
    font-weight: bold;
    margin-bottom: 10px;
    line-height: 1.3;
}

.article-title a {
    color: var(--afs-title-color, #2FC3B2);
    text-decoration: none;
    transition: color 0.3s ease;
}

.article-title a:hover {
    color: var(--afs-title-color, #45b5aa);
    opacity: 0.85;
}

.article-date {
    font-size: 14px;
    color: #2FC3B2;
    margin-bottom: 11px;
    font-weight: 500;
}

.article-excerpt {
    color: var(--afs-excerpt-color, #82908D);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 22px;
    font-weight: 500;
    min-height: 60px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.article-button {
    display: inline-block;
    background: var(--afs-button-color, transparent linear-gradient(282deg, #8CD4DA 0%, #2FC3B2 100%) 0% 0% no-repeat padding-box);
    color: var(--afs-button-text-color, white);
    border: none;
    padding: 12px;
    border-radius: 17px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 159px;
    text-align: center;
    text-decoration: none;
}

.article-button:hover {
    color: var(--afs-button-text-color, white);
    text-decoration: none;
    opacity: 0.9;
}

/* === PAGINAZIONE === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 40px;
}

.pagination-arrow {
    background: none;
    border: none;
    color: #2FC3B2;
    font-size: 68px;
    font-weight: 300;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s ease, transform 0.2s ease;
}

.pagination-arrow:hover:not(.disabled) {
    color: #26a89a;
    transform: scale(1.2);
    background-color: transparent;
}

.pagination-arrow.disabled {
    color: rgba(47, 195, 178, 0.3);
    cursor: not-allowed;
    background-color: transparent;
}

.pagination-num {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(47, 195, 178, 0.2);
    color: white;
}

.pagination-num:hover:not(.active) {
    background: rgba(47, 195, 178, 0.35);
}

.pagination-num.active {
    background: #2FC3B2;
    color: white;
    box-shadow: 0 4px 12px rgba(47, 195, 178, 0.4);
}

/* === STATI SPECIALI === */
.loading {
    text-align: center;
    padding: 60px;
    color: #999;
    font-size: 16px;
}

.no-results {
    text-align: center;
    padding: 80px 20px;
    color: #999;
}

.no-results h3 {
    margin-bottom: 15px;
    color: #82908D;
    font-size: 24px;
}

/* === ANIMAZIONI === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* === HOVER === */
.filter-group select:hover {
    border-color: #2FC3B2;
}

/* === PLACEHOLDER PER IMMAGINI === */
.article-image:not([style*="background-image"]) {
    background: linear-gradient(135deg, #2FC3B2 0%, #45b7d1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: 600;
    border-radius: 15px;
}

.article-image:not([style*="background-image"])::before {
    content: "📄";
    font-size: 48px;
    opacity: 0.7;
    z-index: 0;
}

.article-image:not([style*="background-image"])::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--afs-overlay-color, linear-gradient(180deg, #37CCDC 0%, #FFD23E 50%, #F26700 100%));
    opacity: var(--afs-overlay-opacity, 0.34);
    z-index: 1;
}

/* === CAROSELLO === */
.article-carousel-container {
    margin-top: 60px;
    margin-bottom: 40px;
}

.article-carousel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 71px;
}

.article-carousel-header h3 {
    font-size: 43px;
    color: var(--afs-title-color, #2FC3B2);
    margin: 0;
    font-weight: 700;
    text-align: left;
}

.article-carousel {
    position: relative;
    overflow: hidden;
    border-radius: 15px;
}

.carousel-track {
    position: relative;
}

.carousel-nav-header {
    display: flex;
    align-items: center;
    gap: 15px;
}

.carousel-nav-header-mobile {
    display: none;
}

.carousel-nav-header button,
.carousel-nav-header-mobile button {
    background: var(--afs-arrow-color, transparent linear-gradient(129deg, #2FC3B2 0%, #8CD4DA 100%) 0% 0% no-repeat padding-box);
    color: var(--afs-arrow-text-color, white);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(47, 195, 178, 0.3);
}

.carousel-nav-header button:hover:not(.disabled),
.carousel-nav-header-mobile button:hover:not(.disabled) {
    background: var(--afs-arrow-color, transparent linear-gradient(129deg, #2FC3B2 0%, #8CD4DA 100%) 0% 0% no-repeat padding-box);
    color: var(--afs-arrow-text-color, white);
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(47, 195, 178, 0.4);
}

.carousel-nav-header button.disabled,
.carousel-nav-header-mobile button.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.carousel-no-slides {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 16px;
}

/* === SUBFILTER TABS === */
.subfilter-tabs-wrapper {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    padding: 8px;
    margin-bottom: 40px;
    overflow: hidden;
}

.subfilter-tabs {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    -webkit-overflow-scrolling: touch;
}

.subfilter-tabs::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.subfilter-tab {
    position: relative;
    flex: 1 0 auto;
    min-width: max-content;
    padding: 22px 32px 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--afs-title-color, #A8136B);
    transition: color 0.25s ease, opacity 0.25s ease;
    text-align: center;
    white-space: nowrap;
    font-family: inherit;
    opacity: 0.65;
    line-height: 1.2;
    box-shadow: none;
}

/* Override forzato contro temi che applicano background/box-shadow su hover/focus
   (es. Royal theme). La sottolineatura compare SOLO sulla tab attiva. */
.subfilter-tab:hover,
.subfilter-tab:focus,
.subfilter-tab:active,
.article-filter-system .subfilter-tab:hover,
.article-filter-system .subfilter-tab:focus,
.article-filter-system .subfilter-tab:active {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    outline: none !important;
    color: var(--afs-title-color, #A8136B) !important;
    opacity: 0.65;
}

/* Wrapper interno per misurare la larghezza del testo */
.subfilter-tab-text {
    position: relative;
    display: inline-block;
}

/* Tab attiva: piena opacità + sottolineatura visibile */
.subfilter-tab.active,
.subfilter-tab.active:hover,
.subfilter-tab.active:focus,
.article-filter-system .subfilter-tab.active,
.article-filter-system .subfilter-tab.active:hover,
.article-filter-system .subfilter-tab.active:focus {
    opacity: 1 !important;
    color: var(--afs-title-color, #A8136B) !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
}

.subfilter-tab-underline {
    position: absolute;
    bottom: -8px;
    left: 0;
    right: 0;
    height: 6px;
    border-radius: 3px;
    background: var(--afs-button-color, var(--afs-title-color, transparent linear-gradient(282deg, #8CD4DA 0%, #2FC3B2 100%) 0% 0% no-repeat padding-box));
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.subfilter-tab.active .subfilter-tab-underline {
    transform: scaleX(1);
}


/* === RESPONSIVE === */
@media (max-width: 1024px) {

    .carousel-nav-header {
        display: none;
    }

    .carousel-nav-header-mobile {
        display: flex;
        justify-content: center;
        gap: 15px;
    }

    .combo-reset-anno,
    .combo-reset-tipologia,
    .combo-reset-search {
        top: -14px;
        right: 6px;
        width: 24px;
        height: 30px;
        font-size: 16px;
        z-index: 999;
    }

    .filter-group select,
    .filter-group .filter-search {
        margin-top: 6px;
    }

    .article-filter-system {
        padding: 15px;
    }

    .articles-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .article-carousel .article-card {
        width: 100%;
        min-width: 100%;
        flex-shrink: 0;
    }

    .article-carousel-header h3 {
        font-size: 28px;
        line-height: 42px;
    }

    .article-carousel-header {
        flex-direction: column;
        align-items: center;
        gap: 30px;
        margin-bottom: 40px;
    }

    .carousel-nav-header {
        order: 2;
        justify-content: center;
        width: 100%;
    }

    .article-card {
        min-width: 100%;
    }

    .article-image {
        height: 0;
        padding-bottom: 100%;
    }

    .filters-row {
        flex-direction: row;
        gap: 4px;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group > #filter-tipologia {
        min-width: 100%;
    }

    .filter-label {
        margin-top: 8px;
        font-size: 16px;
    }

    .filter-group select,
    .filter-group .filter-search {
        width: 100%;
        min-width: 100%;
        font-size: 14px !important;
    }

    .results-info {
        flex-direction: column;
        gap: 15px;
    }

    .article-content {
        padding: 10px 0px 10px 0px;
    }

    .article-title {
        font-size: 18px;
    }

    .pagination {
        gap: 12px;
    }

    .pagination-num {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }

    .pagination-arrow {
        font-size: 24px;
    }

    /* === SUBFILTER TABS - MOBILE (layout verticale) === */
    .subfilter-tabs-wrapper {
        border-radius: 20px;
        padding: 6px;
        margin-bottom: 30px;
    }

    /* In verticale: niente scroll orizzontale, tab impilate a tutta larghezza */
    .subfilter-tabs {
        flex-direction: column;
        justify-content: flex-start;
        gap: 4px;
        overflow-x: hidden;
        overflow-y: visible;
    }

    .subfilter-tab {
        width: 100%;
        flex: none;
        min-width: 0;
        padding: 14px 18px 14px 24px;
        font-size: 15px;
        letter-spacing: 0.5px;
        text-align: left;
        white-space: normal;
        line-height: 1.3;
    }

    /* Rendo lo span del testo non-relative così l'underline si aggancia
       direttamente al button (.subfilter-tab) e occupa tutta l'altezza riga */
    .subfilter-tab-text {
        position: static;
        display: block;
    }

    /* L'underline diventa una barretta verticale a sinistra dell'item attivo */
    .subfilter-tab-underline {
        top: 8px;
        bottom: 8px;
        left: 0;
        right: auto;
        width: 4px;
        height: auto;
        border-radius: 0 3px 3px 0;
    }
}

/* === SMARTPHONE PICCOLI (≤480px) === */
/* iPhone SE, Android economici. Affinamento finale di font e padding. */
@media (max-width: 480px) {
    .article-filter-system {
        padding: 12px;
    }

    .article-carousel-header h3 {
        font-size: 24px;
        line-height: 32px;
    }

    .article-carousel-header {
        gap: 24px;
        margin-bottom: 32px;
    }

    .article-title {
        font-size: 17px;
    }

    .article-excerpt {
        font-size: 14px;
        margin-bottom: 18px;
    }

    .filter-label {
        font-size: 15px;
        margin-right: 0;
    }

    .pagination {
        gap: 8px;
    }

    .pagination-num {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }

    .pagination-arrow {
        font-size: 22px;
    }

    .subfilter-tabs-wrapper {
        padding: 5px;
        margin-bottom: 24px;
    }

    .subfilter-tab {
        padding: 12px 14px 12px 22px;
        font-size: 13px;
        letter-spacing: 0.3px;
    }

    .no-results {
        padding: 50px 15px;
    }

    .no-results h3 {
        font-size: 20px;
    }
}