/**
 * Stili per il frontend del plugin Tabella Albo Mestieri GLEM
 */

/* Container principale */
.tamg-frontend-wrapper {
    width: 100%;
    max-width: none;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    box-sizing: border-box;
}

/* Controlli di ricerca e filtri */
.tamg-frontend-controls {
    width: 100%;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e1e5e9;
    box-sizing: border-box;
}

.tamg-search-container {
    position: relative;
    margin-bottom: 15px;
}

.tamg-search-field {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 16px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.tamg-search-field:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.tamg-search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 18px;
    pointer-events: none;
}

/* Layout nuovi filtri a righe */
.tamg-controls-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 15px;
}

.tamg-controls-row:last-child {
    margin-bottom: 0;
}

/* Responsive breakpoints per una migliore distribuzione */
@media (max-width: 1400px) {
    .tamg-controls-row-1 .tamg-search-compact {
        flex: 1.5;
    }
}

@media (max-width: 1200px) {
    .tamg-controls-row {
        gap: 10px;
    }
    
    .tamg-controls-row-1 .tamg-search-compact {
        min-width: 180px;
    }
    
    .tamg-controls-row-1 .tamg-filter-compact,
    .tamg-controls-row-2 .tamg-filter-compact {
        min-width: 120px;
    }
}

/* Prima riga: ricerca compatta + professione + settore */
.tamg-controls-row-1 .tamg-search-compact {
    flex: 2;
    min-width: 200px;
    margin-bottom: 0;
}

.tamg-controls-row-1 .tamg-filter-compact {
    flex: 1;
    min-width: 140px;
}

/* Seconda riga: nazione + provincia + provenienza + città */
.tamg-controls-row-2 .tamg-filter-compact {
    flex: 1;
    min-width: 140px;
}

/* Fallback per container vecchio */
.tamg-filters-container {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.tamg-filter-group {
    flex: 1;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tamg-filter-compact {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tamg-filter-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.tamg-filter-select {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.tamg-filter-select:focus {
    outline: none;
    border-color: #0073aa;
}

/* Dropdown personalizzato per province */
.tamg-custom-select {
    position: relative;
    width: 100%;
    cursor: pointer;
    user-select: none;
}

.tamg-custom-select-trigger {
    /* Stile identico ai dropdown standard */
    width: 100%;
    padding: 10px 30px 10px 15px;
    box-sizing: border-box;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s ease;
    color: #333;
    display: block;
    line-height: 1.4;
    cursor: pointer;
}

.tamg-custom-select-trigger:hover {
    border-color: #999;
}

.tamg-custom-select-trigger:focus,
.tamg-custom-select-trigger.active {
    outline: none;
    border-color: #0073aa;
}

.tamg-custom-select-trigger.active {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.tamg-custom-select-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.2s;
    font-size: 12px;
    color: #666;
    pointer-events: none;
}

.tamg-custom-select-trigger.active .tamg-custom-select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.tamg-custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 2px solid #0073aa;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: none;
}

.tamg-custom-option {
    padding: 8px 12px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: background-color 0.2s;
}

.tamg-custom-option:hover {
    background-color: #f0f8ff;
}

.tamg-custom-option.highlighted {
    background-color: #e6f3ff;
    color: #333;
}

.tamg-custom-option.selected {
    background-color: #0073aa;
    color: #fff;
}

.tamg-custom-option.selected:hover {
    background-color: #005a8c;
}

/* Scrollbar personalizzato per il dropdown */
.tamg-custom-select-options::-webkit-scrollbar {
    width: 8px;
}

.tamg-custom-select-options::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.tamg-custom-select-options::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.tamg-custom-select-options::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Visibilità responsive */
/* Desktop: mostra custom, nasconde nativo */
@media (min-width: 769px) {
    .tamg-profession-native,
    .tamg-sector-native,
    .tamg-provenienza-native,
    .tamg-province-native,
    .tamg-country-native {
        display: none;
    }
    
    .tamg-profession-desktop,
    .tamg-sector-desktop,
    .tamg-provenienza-desktop,
    .tamg-province-desktop,
    .tamg-country-desktop {
        display: block;
    }
}

/* Mobile: mostra nativo, nasconde custom */
@media (max-width: 768px) {
    .tamg-profession-native,
    .tamg-sector-native,
    .tamg-provenienza-native,
    .tamg-province-native,
    .tamg-country-native {
        display: block;
    }
    
    .tamg-profession-desktop,
    .tamg-sector-desktop,
    .tamg-provenienza-desktop,
    .tamg-province-desktop,
    .tamg-country-desktop {
        display: none;
    }
}

/* Container per l'autocomplete città */
.tamg-city-autocomplete-container {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.tamg-city-autocomplete {
    width: 100%;
    cursor: pointer;
    box-sizing: border-box;
}

.tamg-city-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #0073aa;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    max-width: 100%;
}

.tamg-city-suggestion {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.tamg-city-suggestion:hover,
.tamg-city-suggestion.tamg-city-selected {
    background-color: #f8f9fa;
}

.tamg-city-suggestion:last-child {
    border-bottom: none;
}

/* Informazioni sui risultati */
.tamg-results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 0;
}

#tamg-results-count {
    font-weight: 600;
    color: #333;
}

.tamg-loading {
    display: inline-flex;
    align-items: center;
    color: #666;
    font-style: italic;
}

.tamg-loading::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: tamg-spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes tamg-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tabella */
.tamg-table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.tamg-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.tamg-table th {
    background: #f8f9fa;
    color: #495057;
    font-weight: 600;
    padding: 15px 12px;
    text-align: left;
    border-bottom: 2px solid #e1e5e9;
    white-space: nowrap;
}

.tamg-table td {
    padding: 12px;
    border-bottom: 1px solid #e1e5e9;
    vertical-align: top;
}

.tamg-table tr:last-child td {
    border-bottom: none;
}

.tamg-table tr:hover {
    background-color: #f8f9fa;
}

.tamg-table tbody tr:nth-child(even) {
    background-color: #fdfdfd;
}

.tamg-table tbody tr:nth-child(even):hover {
    background-color: #f8f9fa;
}

/* Professioni con indicatore "altro" */
.tamg-more-professions {
    display: inline-block;
    background: #6c757d;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 4px;
}

/* Pulsante "Leggi tutto" */
.tamg-btn-details {
    background: #0073aa;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.tamg-btn-details:hover {
    background: #005a87;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tamg-btn-details:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.3);
}

/* Paginazione */
.tamg-pagination-container {
    margin-top: 25px;
    display: flex;
    justify-content: center;
}

.tamg-pagination {
    display: flex;
    gap: 5px;
    align-items: center;
}

.tamg-pagination .page-btn,
.tamg-pagination .current-page {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.tamg-pagination .page-btn:hover {
    background: #f8f9fa;
    border-color: #0073aa;
    color: #0073aa;
    text-decoration: none;
}

.tamg-pagination .current-page {
    background: #0073aa;
    color: white;
    border-color: #0073aa;
    font-weight: 600;
}

.tamg-pagination .dots {
    padding: 8px 4px;
    color: #666;
}

/* Popup per i dettagli */
.tamg-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.tamg-popup-content {
    background: white;
    border-radius: 8px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: tamg-popup-show 0.3s ease-out;
}

/* Desktop: popup centrale con blur */
@media (min-width: 768px) {
    .tamg-popup-overlay {
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        background: rgba(0, 0, 0, 0.6);
    }
    
    .tamg-popup-content {
        width: 95%;
        max-width: 1400px;
        max-height: 90vh;
        border-radius: 12px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }
}

@keyframes tamg-popup-show {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Desktop: animazione più fluida e semplice */
@media (min-width: 768px) {
    @keyframes tamg-popup-show-desktop {
        from {
            opacity: 0;
            transform: scale(0.95);
        }
        to {
            opacity: 1;
            transform: scale(1);
        }
    }
    
    .tamg-popup-content {
        animation: tamg-popup-show-desktop 0.3s ease-out;
    }
}

.tamg-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
    flex-shrink: 0;
}

.tamg-popup-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

/* Desktop: header più elegante */
@media (min-width: 768px) {
    .tamg-popup-header {
        padding: 25px 30px;
        background: white;
        border-bottom: 2px solid #f1f1f1;
    }
    
    .tamg-popup-header h3 {
        color: #0073aa;
        font-size: 22px;
        font-weight: 700;
    }
}

.tamg-popup-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.tamg-popup-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    transition: all 0.3s ease;
}

.tamg-popup-close:hover {
    background: #e9ecef;
    color: #333;
}

/* Desktop: X in alto a destra più elegante */
@media (min-width: 768px) {
    .tamg-popup-close {
        font-size: 28px;
        width: 36px;
        height: 36px;
        border-radius: 18px;
        color: #999;
    }
    
    .tamg-popup-close:hover {
        background: #f1f1f1;
        color: #333;
        transform: scale(1.1);
    }
}

.tamg-popup-body {
    padding: 25px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

/* Desktop: layout a 2 colonne semplice */
@media (min-width: 768px) {
    .tamg-popup-body {
        padding: 30px;
        max-height: calc(90vh - 100px);
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 40px;
        align-content: start;
    }
}

/* Desktop large: layout a 3 colonne per schermi grandi */
@media (min-width: 1200px) {
    .tamg-popup-body {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 30px;
    }
}

/* Desktop: layout a tabella per i dettagli (usato solo su desktop) */
@media (min-width: 768px) {
    /* Il blocco della tabella occupa tutta la larghezza del popup */
    .tamg-desktop-table-layout {
        grid-column: 1 / -1;
        overflow: auto;
    }

    .tamg-desktop-details-table {
        width: 100%;
        border-collapse: collapse;
        table-layout: fixed;
        background: white;
        border: 1px solid #e8e8e8;
        border-radius: 8px;
        overflow: hidden;
        font-size: 14px;
    }

    .tamg-desktop-details-table tr {
        border-bottom: 1px solid #f0f0f0;
    }

    .tamg-desktop-details-table tr:last-child {
        border-bottom: none;
    }

    .tamg-desktop-details-table td {
        padding: 10px 14px;
        vertical-align: top;
        word-break: break-word;
    }

    .tamg-desktop-section-header td {
        background: #f7f9fb;
        color: #0073aa;
        font-weight: 700;
        padding: 14px 16px;
        border-bottom: 1px solid #e6eef4;
    }

    .tamg-desktop-section-header h3 {
        margin: 0;
        font-size: 16px;
        color: inherit;
    }

    .tamg-desktop-table-label {
        width: 22%;
        font-weight: 600;
        color: #555;
        background: #fafafa;
    }

    .tamg-desktop-table-value {
        width: 28%;
        color: #333;
    }

    /* Righe professioni semplificate: [Num. Professione Settore] */
    .tamg-desktop-prof-row td {
        border-top: 1px solid #f0f0f0;
        border-bottom: 1px solid #f0f0f0;
        background: #fff;
        font-size: 14px;
        padding: 8px 12px; /* più compatto */
    }
    .tamg-desktop-prof-grid {
        display: grid;
        grid-template-columns: 36px minmax(140px, 0.2fr) minmax(120px, 0.8fr);
        align-items: center;
        column-gap: 16px; /* colonne più vicine */
    }
    .tamg-desktop-prof-num {
        justify-self: end;
        color: #666;
        font-weight: 600;
        white-space: nowrap;
    }
    .tamg-desktop-prof-name {
        font-weight: 600;
        color: #2c3e50;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .tamg-desktop-prof-sector {
        color: #34495e;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    /* Spazio finale sotto le professioni per consentire lo scroll completo */
    .tamg-desktop-prof-spacer td {
        height: 100px;
        border: none;
        padding: 0;
        background: transparent;
    }
}

/* Sezioni dei dettagli */
.tamg-detail-section {
    margin-bottom: 25px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.tamg-detail-section:last-child {
    margin-bottom: 0;
}

.tamg-detail-section h4 {
    margin: 0 0 15px 0;
    color: #0073aa;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 2px solid #e1e5e9;
    padding-bottom: 8px;
}

/* Desktop: sezioni più pulite */
@media (min-width: 768px) {
    .tamg-detail-section {
        background: #fafafa;
        border: 1px solid #e8e8e8;
        margin-bottom: 0;
        height: fit-content;
        min-width: 0; /* Permette shrinking del grid */
    }
    
    .tamg-detail-section h4 {
        background: #f1f1f1;
        color: #0073aa;
        margin: 0;
        padding: 15px 20px;
        font-size: 17px;
        border-bottom: 1px solid #ddd;
        font-weight: 700;
    }
    
    .tamg-detail-section .tamg-detail-grid,
    .tamg-detail-section .tamg-professions-list {
        padding: 20px;
        background: white;
    }
}

.tamg-detail-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 10px 20px;
    align-items: start;
}

/* Layout inline per mobile */
.tamg-detail-inline-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tamg-detail-inline-item {
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.tamg-detail-inline-label {
    font-weight: 600;
    color: #000000;
    font-size: 16px;
}

.tamg-detail-inline-value {
    color: #333;
    font-size: 16px;
    word-break: break-word;
}

.tamg-detail-inline-value a {
    color: #0073aa;
    text-decoration: none;
}

.tamg-detail-inline-value a:hover {
    text-decoration: underline;
}

/* Container per le note */
.tamg-notes-container {
    display: block;
}

.tamg-notes-content {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
    line-height: 1.6;
    word-break: break-word;
}

.tamg-detail-label {
    font-weight: 600;
    color: #000000;
    font-size: 18px;
}

.tamg-detail-value {
    color: #333;
    word-break: break-word;
}

.tamg-detail-value a {
    color: #0073aa;
    text-decoration: none;
}

.tamg-detail-value a:hover {
    text-decoration: underline;
}

/* Desktop: layout dettagli semplificato */
@media (min-width: 768px) {
    .tamg-detail-grid {
        grid-template-columns: auto 1fr;
        gap: 8px 15px;
    }
    
    .tamg-detail-label {
        font-size: 13px;
        font-weight: 600;
        color: #666;
        white-space: nowrap;
    }
    
    .tamg-detail-value {
        font-size: 14px;
        line-height: 1.5;
        word-break: break-word;
    }
}

/* Professioni nel popup */
.tamg-professions-list {
    display: grid;
    gap: 15px;
}

.tamg-profession-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #0073aa;
}

.tamg-profession-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.tamg-profession-sector {
    color: #666;
    font-size: 13px;
}

/* Desktop: professioni semplici */
@media (min-width: 768px) {
    .tamg-professions-list {
        gap: 12px;
    }
    
    .tamg-profession-item {
        background: #f9f9f9;
        padding: 12px 15px;
        border-radius: 4px;
        border-left: 3px solid #0073aa;
    }
    
    .tamg-profession-name {
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .tamg-profession-sector {
        font-size: 12px;
        color: #777;
    }
}

/* Stati vuoti */
.tamg-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

.tamg-error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #f5c6cb;
    margin: 20px 0;
}

/* Responsive */
@media (max-width: 768px) {
    .tamg-frontend-controls {
        padding: 15px;
    }
    
    /* Layout mobile per i controlli a righe - tutti in colonna con stessa larghezza */
    .tamg-controls-row {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 15px;
        width: 100%;
    }
    
    /* Tutti gli elementi con la stessa larghezza in colonna */
    .tamg-controls-row-1 .tamg-search-compact,
    .tamg-controls-row-1 .tamg-filter-compact,
    .tamg-controls-row-2 .tamg-filter-compact {
        flex: none;
        width: 100%;
        min-width: auto;
        margin-bottom: 0;
        box-sizing: border-box;
    }
    
    /* Campo di ricerca mobile */
    .tamg-controls-row-1 .tamg-search-compact .tamg-search-field {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Tutti i filtri con larghezza uniforme */
    .tamg-filter-compact .tamg-filter-select,
    .tamg-filter-compact .tamg-custom-select,
    .tamg-filter-compact .tamg-custom-select-trigger,
    .tamg-filter-compact .tamg-city-autocomplete {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Stili uniformi per custom select trigger su mobile */
    .tamg-filter-compact .tamg-custom-select-trigger {
        padding: 10px 30px 10px 15px;
        font-size: 14px;
        border: 2px solid #ddd;
        border-radius: 6px;
    }
    
    /* Fallback per container vecchio */
    .tamg-filters-container {
        flex-direction: column;
    }
    
    .tamg-filter-group {
        min-width: auto;
        width: 100%;
        margin-bottom: 12px;
    }
    
    .tamg-filter-select {
        min-width: auto;
        width: 100%;
    }
    
    .tamg-city-autocomplete-container {
        min-width: auto;
        max-width: 100%;
        width: 100%;
    }
    
    .tamg-table th,
    .tamg-table td {
        padding: 8px 6px;
        font-size: 13px;
    }
    
    .tamg-table th {
        font-size: 12px;
    }
    
    .tamg-btn-details {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .tamg-popup-content {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }
    
    .tamg-popup-header,
    .tamg-popup-body {
        padding: 15px 20px;
    }
    
    .tamg-detail-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .tamg-detail-label {
        font-weight: 600;
        margin-bottom: 2px;
    }
    
    .tamg-pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Desktop: filtro province più stretto */
@media (min-width: 769px) {
    #tamg-province-filter {
        flex: 0 0 110px;
        min-width: 110px;
        max-width: 130px;
    }
}

@media (max-width: 480px) {
    .tamg-table-container {
        font-size: 12px;
    }
    
    .tamg-results-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .tamg-popup-overlay {
        padding: 10px;
    }
    
    .tamg-popup-header h3 {
        font-size: 16px;
    }
}

/* Blocca scroll del body quando popup è aperto (solo desktop) */
@media (min-width: 768px) {
    body.tamg-popup-open {
        overflow: hidden;
        height: 100vh;
    }
}

/* Accessibilità */
@media (prefers-reduced-motion: reduce) {
    .tamg-btn-details:hover,
    .tamg-popup-content {
        transform: none;
        animation: none;
    }
    
    .tamg-loading::before {
        animation: none;
    }
}

/* Focus visibile per navigazione da tastiera */
.tamg-search-field:focus,
.tamg-filter-select:focus,
.tamg-btn-details:focus,
.tamg-popup-close:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Indicatore caricamento per la tabella */
.tamg-table-loading {
    position: relative;
}

.tamg-table-loading::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

.tamg-table-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: tamg-spin 1s linear infinite;
    z-index: 11;
}

/* Stili per la stampa */
@media print {
    .tamg-frontend-controls,
    .tamg-pagination-container,
    .tamg-btn-details,
    .tamg-btn-export,
    .tamg-btn-print,
    .tamg-btn-favorite {
        display: none !important;
    }
    
    .tamg-table {
        width: 100% !important;
        font-size: 10px !important;
    }
    
    .tamg-table th,
    .tamg-table td {
        padding: 4px 2px !important;
        border: 1px solid #000 !important;
    }
    
    .tamg-table th {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .tamg-popup-overlay {
        display: none !important;
    }
    
    .tamg-frontend-wrapper {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .tamg-table-container {
        border: none !important;
        box-shadow: none !important;
        overflow: visible !important;
    }
    
    .tamg-results-info {
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
        margin-bottom: 10px;
        font-weight: bold;
    }
}

/* Stili per pulsanti utility */
.tamg-btn-export,
.tamg-btn-print {
    margin-left: 10px;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.tamg-btn-export {
    background: #28a745;
    color: white;
}

.tamg-btn-export:hover {
    background: #218838;
    color: white;
    text-decoration: none;
}

.tamg-btn-print {
    background: #6c757d;
    color: white;
}

.tamg-btn-print:hover {
    background: #5a6268;
    color: white;
    text-decoration: none;
}

.tamg-btn-favorite {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tamg-btn-favorite:hover {
    transform: scale(1.2);
}

/* Stato di caricamento nel popup */
.tamg-popup-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    font-style: italic;
    color: #666;
}

.tamg-popup-loading::before {
    content: "";
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: tamg-spin 1s linear infinite;
    margin-right: 12px;
}

/* Scrollbar personalizzata per desktop */
@media (min-width: 768px) {
    .tamg-popup-body::-webkit-scrollbar {
        width: 8px;
    }
    
    .tamg-popup-body::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }
    
    .tamg-popup-body::-webkit-scrollbar-thumb {
        background: #0073aa;
        border-radius: 4px;
    }
    
    .tamg-popup-body::-webkit-scrollbar-thumb:hover {
        background: #005a87;
    }
}

/* Miglioramenti per schermi ultra-wide */
@media (min-width: 1800px) {
    .tamg-popup-body {
        padding: 60px 80px;
        gap: 60px;
    }
    
    .tamg-detail-section h4 {
        font-size: 20px;
        padding: 18px 25px;
    }
    
    .tamg-detail-section .tamg-detail-grid,
    .tamg-detail-section .tamg-professions-list {
        padding: 25px;
    }
    
    .tamg-popup-header {
        padding: 40px 80px;
    }
    
    .tamg-popup-header h3 {
        font-size: 28px;
    }
}

/* Stato di caricamento nel popup */
.tamg-popup-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    font-style: italic;
    color: #666;
}

.tamg-popup-loading::before {
    content: "";
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: tamg-spin 1s linear infinite;
    margin-right: 12px;
}