:root {
    --border-light: #dee2e6;
    --shadow-hover: rgba(0, 0, 0, 0.08);
    --shadow-focus: rgba(0, 0, 0, 0.1);
    --bg-hover: rgba(0, 0, 0, 0.02);
}

/* === DOCUMENT PAGE === */
.at-doc-card-row {
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.at-doc-card-row:hover {
    box-shadow: 0 4px 14px var(--shadow-hover) !important;
    transform: translateY(-2px);
}

.at-doc-icon {
    width: 2rem;
    height: 2rem;
}

.at-doc-card-info {
    min-width: 0;
}

.at-doc-card-text {
    min-width: 0;
}

.at-doc-filename {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 767px) {
    .at-doc-card-row {
        flex-wrap: wrap;
        gap: .75rem !important;
    }

    .at-doc-filename {
        white-space: normal;
        word-break: break-word;
    }

    .at-doc-buttons {
        flex-direction: column;
        width: 100%;
    }

    .at-doc-buttons .btn {
        width: 100%;
        justify-content: center;
    }
}

/* === QUICK FILTER BAR === */
#quick-filter-bar .btn {
    font-size: .8rem;
    transition: all .15s ease;
}

#quick-filter-bar .btn:hover {
    transform: translateY(-1px);
}

/* === FILTER CHIPS === */
.at-filter-chip {
    font-size: .8rem;
    padding: .3rem .6rem;
    border-radius: 2rem !important;
}

.at-chip-remove {
    opacity: .7;
    transition: opacity .15s;
}

.at-chip-remove:hover {
    opacity: 1;
}

/* === RICERCA === */
#at-search-input {
    transition: all 0.3s ease;
    font-weight: 550;
}

#at-search-input:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

#at-search-input:focus {
    transform: translateY(-2px);
    border-color: var(--border-light) !important;
    box-shadow: 0 4px 12px var(--shadow-hover) !important;
}

#at-search-input::placeholder {
    font-style: italic;
}

#at-search-input::-webkit-search-cancel-button {
    display: none;
}

/* === DESCRIZIONE SEZIONE (longDescriptionParent) === */
.at-description {
    border-left: 3px solid var(--bs-primary, #0066cc);
    padding-left: 1rem;
    position: relative;
}

.at-description-body {
    font-size: .9375rem;
    line-height: 1.7;
    color: #3d3d3d;
    overflow: hidden;
    transition: max-height .3s ease;
}

/* Stato espanso: nessun limite */
.at-description-body { max-height: none; }

/* Stato collassato */
.at-description.is-collapsed .at-description-body {
    max-height: 120px;
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

/* Prosa: normalizza l'HTML in arrivo dal backend */
.at-description-body p       { margin-bottom: .6rem; }
.at-description-body p:last-child { margin-bottom: 0; }
.at-description-body ul,
.at-description-body ol      { padding-left: 1.25rem; margin-bottom: .6rem; }
.at-description-body li      { margin-bottom: .25rem; }
.at-description-body a       { color: var(--bs-primary, #0066cc); text-decoration: underline; }
.at-description-body a:hover { opacity: .8; }
.at-description-body strong,
.at-description-body b       { font-weight: 700; }
.at-description-body h3,
.at-description-body h4      { font-size: 1rem; font-weight: 700; margin: .75rem 0 .35rem; }
.at-description-body table   { font-size: .875rem; width: 100%; border-collapse: collapse; margin-bottom: .6rem; }
.at-description-body td,
.at-description-body th      { border: 1px solid #dee2e6; padding: .35rem .6rem; }
.at-description-body th      { background: #f8f9fa; font-weight: 600; }

/* Bottone Leggi di più */
.at-description-toggle {
    display: inline-flex;
    align-items: center;
    margin-top: .5rem;
    background: none;
    border: none;
    padding: 0;
    font-size: .8rem;
    font-weight: 600;
    color: var(--bs-primary, #0066cc);
    cursor: pointer;
    transition: opacity .15s;
}

.at-description-toggle:hover { opacity: .75; }

.at-description-toggle .icon {
    width: .8rem;
    height: .8rem;
    fill: currentColor;
}

/* === AVVERTENZE SEZIONE (AvvertenzeParent) === */
.at-avvertenze {
    border-left: 3px solid #b0bec5;
    padding-left: 1rem;
}

.at-avvertenze-body {
    font-size: .9375rem;
    line-height: 1.7;
    color: #3d3d3d;
}

.at-avvertenze-body p         { margin-bottom: .6rem; }
.at-avvertenze-body p:last-child { margin-bottom: 0; }
.at-avvertenze-body ul,
.at-avvertenze-body ol        { padding-left: 1.25rem; margin-bottom: .6rem; }
.at-avvertenze-body li        { margin-bottom: .25rem; }
.at-avvertenze-body a         { color: var(--bs-primary, #0066cc); text-decoration: underline; }
.at-avvertenze-body strong,
.at-avvertenze-body b         { font-weight: 700; }

/* === CARD HOVER (sottosezioni) === */
.at-card-hover {
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.at-card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12) !important;
}

/* === BARRA DI RICERCA HOME AT === */
.at-search-wrap {
    display: flex;
    align-items: center;
}

.at-search-icon {
    position: absolute;
    left: 16px;
    color: #6c757d;
    pointer-events: none;
    z-index: 2;
    font-size: 1rem;
}

.at-search-input-field {
    padding: 14px 48px 14px 44px !important;
    transition: all 0.3s ease;
}

.at-search-clear {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    z-index: 2;
}

.at-search-clear:hover {
    color: #212529;
}

.attachment-item-hover {
    cursor: pointer;
    transition: all 0.3s ease;
}

.attachment-item-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-focus);
}

.at-sort-bar-label {
    font-size: .72rem;
    font-weight: 700;
    color: #5c6f82;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

/* === LISTA DOCUMENTI === */
.at-list {
    display: flex;
    flex-direction: column;
    gap: .625rem;
}

.at-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: .5rem;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    outline: none;
}

.at-list-item:hover {
    border-color: var(--bs-primary, #0066cc);
    box-shadow: 0 4px 14px var(--shadow-hover);
    transform: translateY(-1px);
}

.at-list-item:focus-visible {
    outline: 3px solid var(--bs-primary, #0066cc);
    outline-offset: 2px;
}

.at-list-item-inner {
    flex: 1;
    min-width: 0;
}

.at-list-item-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-bottom: .45rem;
}

.at-badge {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .03em;
}

.at-badge-filter {
    cursor: pointer;
    transition: opacity .15s, transform .1s;
}

.at-badge-filter:hover {
    opacity: .85;
    transform: translateY(-1px);
}

.at-list-item-title {
    font-size: .9375rem;
    font-weight: 600;
    line-height: 1.4;
    color: #1a1a1a;
    /* Tronca a 2 righe su desktop */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.at-attach-meta {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    border: 1px solid var(--bs-primary, #0066cc);
    border-radius: 2rem;
    padding: .05rem .45rem;
    color: var(--bs-primary, #0066cc);
    font-size: .72rem;
    font-weight: 500;
    line-height: 1.4;
    flex-shrink: 0;
    margin-left: auto;
    white-space: nowrap;
}

@media (max-width: 575px) {
    .at-attach-label { display: none; }
    .at-attach-meta { margin-left: 0; }
}

.at-highlight-amount {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    margin: .25rem 0 .35rem;
    border: 1px solid var(--bs-primary, #0066cc);
    border-radius: 2rem;
    padding: .1rem .55rem;
    color: var(--bs-primary, #0066cc);
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
}

.at-sec-label {
    font-weight: 600;
    color: #5c6f82;
    font-size: .8rem;
}

.at-list-item-secondary {
    font-size: .875rem;
    color: #5c6f82;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.at-list-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: .35rem;
}

.at-list-meta-item {
    font-size: .8rem;
    color: #5c6f82;
}

.at-list-meta-item strong {
    color: #1a1a1a;
}

.at-list-item-arrow {
    flex-shrink: 0;
    color: var(--bs-primary, #0066cc);
    opacity: .5;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.at-list-item:hover .at-list-item-arrow {
    opacity: 1;
    transform: translateX(3px);
}

/* === RESPONSIVE === */
@media (max-width: 767px) {
    #at-search-input {
        font-size: 16px;
    }

    .at-card-hover .card-body {
        padding: 1rem !important;
        min-height: 100px !important;
    }

    /* Su mobile mostra il testo completo, senza troncatura */
    .at-list-item-title,
    .at-list-item-secondary {
        -webkit-line-clamp: unset;
        overflow: visible;
        display: block;
    }

    .at-list-item {
        padding: .875rem 1rem;
    }



    /* Paginazione mobile: counter pagina leggibile */
    .at-pagination-counter {
        font-weight: 600;
        white-space: nowrap;
    }

    /* Paginazione: touch target più grande */
    .pagination .page-link {
        min-width: 2.5rem;
        min-height: 2.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* === BADGE ESTENSIONE FILE === */
.at-file-ext-badge {
    display: inline-block;
    font-size: .6rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: .3rem .5rem;
    border-radius: .3rem;
    min-width: 2.75rem;
    text-align: center;
    line-height: 1.2;
    flex-shrink: 0;
}

.at-file-ext-badge { background: #5c6f82; color: #fff; }
.at-file-ext-badge--link { background: #0073e6; color: #fff; }

/* === BOTTONI DOCUMENTO === */
.at-doc-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .9rem;
    border-radius: 2rem;
    border: 1.5px solid;
    font-size: .78rem;
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
    white-space: nowrap;
    line-height: 1.4;
}

.at-doc-btn .icon {
    width: .8rem;
    height: .8rem;
    fill: currentColor;
    flex-shrink: 0;
}

.at-doc-btn--primary {
    background: var(--bs-primary, #0066cc);
    border-color: var(--bs-primary, #0066cc);
    color: #fff;
}

.at-doc-btn--primary:hover {
    background: #0052a3;
    border-color: #0052a3;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,102,204,.3);
}

.at-doc-btn--outline {
    background: transparent;
    border-color: var(--bs-primary, #0066cc);
    color: var(--bs-primary, #0066cc);
}

.at-doc-btn--outline:hover {
    background: var(--bs-primary, #0066cc);
    border-color: var(--bs-primary, #0066cc);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,102,204,.2);
}

.at-doc-btn:focus-visible {
    outline: 3px solid var(--bs-primary, #0066cc);
    outline-offset: 2px;
}

/* === ALLEGATI INLINE (dentro accordion dettagli) === */
.at-inline-attachment {
    max-width: 100%;
}


@media (max-width: 767px) {
    .at-inline-attachment {
        flex-wrap: wrap;
        gap: .5rem !important;
    }
}

/* === TOGGLE CESSATI === */
.at-cessati-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .9rem;
    border-radius: 2rem;
    border: 1.5px solid #e8a800;
    background: transparent;
    color: #7a5500;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    line-height: 1.4;
}

.at-cessati-btn .icon {
    width: .85rem;
    height: .85rem;
    fill: currentColor;
    flex-shrink: 0;
}

.at-cessati-btn:hover {
    background: #fff8e1;
    border-color: #c98a00;
}

.at-cessati-btn.is-active {
    background: #f0a800;
    border-color: #f0a800;
    color: #3d2900;
}

.at-cessati-btn.is-active:hover {
    background: #d49200;
    border-color: #d49200;
    color: #3d2900;
}

.at-cessati-btn:focus-visible {
    outline: 3px solid #f0a800;
    outline-offset: 2px;
}

/* === RECORD CESSATO === */
.at-list-item--cessato {
    border-color: #f0a800 !important;
    background: #fffdf0 !important;
}

.at-list-item--cessato .at-list-item-arrow {
    color: #f0a800;
}

/* === PUBBLICAZIONE ANNULLATA === */
.at-list-item--annullata {
    border-color: #dc3545 !important;
    background: #fff8f8 !important;
}

.at-list-item--annullata .at-list-item-arrow {
    color: #dc3545;
}

.at-title-annullata {
    opacity: .6;
    text-decoration: line-through;
}

/* === TOOLBAR === */
.at-toolbar {
    padding: .5rem 0 .6rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: .75rem;
}

.at-toolbar-btn-filtri,
.at-toolbar-btn-export {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .8rem;
    font-weight: 600;
    padding: .35rem 1rem;
    border-radius: 2rem;
    border: 1.5px solid;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    background: transparent;
    line-height: 1.4;
}

.at-toolbar-btn-filtri {
    color: var(--bs-primary, #0066cc);
    border-color: var(--bs-primary, #0066cc);
}

.at-toolbar-btn-filtri:hover,
.at-toolbar-btn-filtri.is-open {
    background: var(--bs-primary, #0066cc);
    color: #fff;
}

.at-toolbar-btn-filtri .icon {
    width: .9rem;
    height: .9rem;
    fill: currentColor;
    flex-shrink: 0;
}

.at-toolbar-btn-export {
    color: #5c6f82;
    border-color: #dee2e6;
    font-weight: 500;
}

.at-toolbar-btn-export:hover {
    border-color: #5c6f82;
    color: #1a1a1a;
}

.at-toolbar-btn-filtri:focus-visible,
.at-toolbar-btn-export:focus-visible {
    outline: 3px solid var(--bs-primary, #0066cc);
    outline-offset: 2px;
}

.at-toolbar-btn-export .icon {
    width: .9rem;
    height: .9rem;
    fill: currentColor;
    flex-shrink: 0;
}

.filter-count-badge {
    font-size: .65rem;
    padding: .15em .5em;
    border-radius: 2rem;
    background: #fff !important;
    color: var(--bs-primary, #0066cc) !important;
    border: 1px solid var(--bs-primary, #0066cc);
    font-weight: 700;
    line-height: 1.2;
}

.at-toolbar-btn-filtri.is-open .filter-count-badge {
    background: rgba(255,255,255,.25) !important;
    border-color: rgba(255,255,255,.5);
    color: #fff !important;
}

/* === SORT BAR === */
.at-sort-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .3rem;
    padding: .4rem 0 .55rem;
    border-bottom: 1px solid #eee;
}

/* --- Pill desktop --- */
.at-sort-pill {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .22rem .7rem;
    border-radius: 2rem;
    border: 1.5px solid #dee2e6;
    background: #fff;
    font-size: .75rem;
    font-weight: 500;
    color: #5c6f82;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
    line-height: 1.4;
}

.at-sort-pill:hover {
    border-color: var(--bs-primary, #0066cc);
    color: var(--bs-primary, #0066cc);
    box-shadow: 0 1px 4px rgba(0,102,204,.12);
}

.at-sort-pill:focus-visible {
    outline: 3px solid var(--bs-primary, #0066cc);
    outline-offset: 2px;
}

.at-sort-pill--asc,
.at-sort-pill--desc {
    background: var(--bs-primary, #0066cc);
    border-color: var(--bs-primary, #0066cc);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,102,204,.25);
}

.at-sort-pill--asc:hover,
.at-sort-pill--desc:hover {
    background: #0052a3;
    border-color: #0052a3;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,102,204,.35);
}

.at-sort-icon {
    font-size: .68rem;
    line-height: 1;
    opacity: .35;
    transition: opacity .15s;
    min-width: .6rem;
    text-align: center;
}

.at-sort-pill:hover .at-sort-icon {
    opacity: .7;
}

.at-sort-pill--asc .at-sort-icon,
.at-sort-pill--desc .at-sort-icon {
    opacity: 1;
}

/* --- Select + direzione mobile --- */
.at-sort-select {
    flex: 1;
    min-width: 0;
    border: 1.5px solid #dee2e6;
    border-radius: 2rem;
    font-size: .75rem;
    padding: .22rem .9rem;
    color: #5c6f82;
    background-color: #fff;
    height: auto;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color .15s;
}

.at-sort-select:focus {
    border-color: var(--bs-primary, #0066cc);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,102,204,.15);
}

.at-sort-dir-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1.5px solid #dee2e6;
    background: #fff;
    color: #5c6f82;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color .15s, background .15s, color .15s;
    padding: 0;
}

.at-sort-dir-btn:not(:disabled):hover {
    border-color: var(--bs-primary, #0066cc);
    color: var(--bs-primary, #0066cc);
}

.at-sort-dir-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.at-sort-dir-btn .icon {
    width: .85rem;
    height: .85rem;
    fill: currentColor;
    transition: transform .2s ease;
}

.at-sort-dir-btn.is-desc .icon {
    transform: rotate(180deg);
}

@media (max-width: 767px) {
    .at-sort-bar {
        flex-wrap: nowrap;
        gap: .4rem;
    }
    .at-toolbar-btn-filtri,
    .at-toolbar-btn-export {
        font-size: .75rem;
        padding: .3rem .8rem;
    }
}

/* === BOTTONE CIG / BDNCP === */
.at-cig-btn {
    display: inline-flex;
    align-items: center;
    font-size: .65rem;
    font-weight: 700;
    padding: .1rem .4rem;
    border-radius: .25rem;
    border: 1px solid var(--bs-primary, #0066cc);
    color: var(--bs-primary, #0066cc);
    background: transparent;
    text-decoration: none;
    letter-spacing: .03em;
    transition: background .15s, color .15s;
    vertical-align: middle;
    white-space: nowrap;
}

.at-cig-btn:hover {
    background: var(--bs-primary, #0066cc);
    color: #fff;
}

.at-cig-btn .icon {
    width: .75rem;
    height: .75rem;
    fill: currentColor;
}
