/* =============== TABELLA =============== */
/* Container principale */
.cf7-container {
    max-width: 100vw;
    margin: 1rem auto;
    padding: 0 0.5rem;
    overflow-x: auto;
}

/* Tabella compatta */
.cf7-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 6px;
    font-size: 0.9rem; /* Riduci la dimensione del testo */
}

/* Header della tabella */
.cf7-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #0073aa;
}

.cf7-table th {
    padding: 0.6rem 0.8rem; /* Riduci il padding */
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
    font-size: 0.9rem; /* Testo più piccolo */
}

/* Celle della tabella */
.cf7-table td {
    padding: 0.6rem 0.8rem; /* Riduci il padding */
    border-top: 1px solid #f0f0f0;
    vertical-align: middle;
    font-size: 0.9rem; /* Testo più piccolo */
}

/* Hover sulle righe */
.cf7-table tr:hover {
    background-color: #f8f9fa;
}

/* Fissare la colonna Azioni */
.cf7-table td.actions {
    position: sticky;
    right: 0;
    background: white; /* Sfondo per evitare trasparenza */
    z-index: 1; /* Sovrapponi la colonna alle altre */
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1); /* Ombra per separazione visiva */
}

/* Aggiungi ombra alle celle della colonna Azioni */
.cf7-table td.actions::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent);
}

/* Bottoni uniformi */
.btn-action {
    width: 100%; /* Occupa tutta la larghezza disponibile */
    padding: 0.5rem 0.8rem;
    margin: 4px 0; /* Margine solo sopra e sotto */
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
    transition: all 0.2s;
    display: block; /* Ogni bottone su una nuova riga */
    box-sizing: border-box; /* Include padding nella larghezza */
}

/* Icone più piccole */
.btn-action i {
    font-size: 0.9em;
    margin-right: 6px;
}

/* Bottone Modifica */
.btn-edit {
    background: #0073aa;
    color: white !important;
}

/* Bottoni Stato e Facilita */
.status-btn.btn-success, .facilita-btn.btn-success {
    background: #28a745;
    color: white !important;
}

.status-btn.btn-danger, .facita-btn.btn-danger {
    background: #dc3545;
    color: white !important;
}

/* Effetto hover */
.btn-action:hover {
    filter: brightness(0.9);
    transform: translateY(-1px);
}

/* Pulsante Chiudi */
.btn-close {
    background-color: #6c757d;
    color: white !important;
    padding: 8px 15px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.btn-close:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
}

/* =============== Form di ricerca avanzato =============== */
.search-form {
    margin-bottom: 1rem;
}

.search-container {
    display: flex;
    gap: 8px; /* Riduci lo spazio tra input e bottone */
    /* max-width: 800px; */
}

.search-container input {
    flex: 1;
    padding: 0.6rem 1rem; /* Riduci il padding */
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.9rem; /* Testo più piccolo */
}

.search-btn {
    background: #0073aa;
    color: white !important;
    padding: 0.6rem 1.2rem; /* Riduci il padding */
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem; /* Testo più piccolo */
}

.search-btn:hover {
    background: #005a87;
}

/* =============== PAGINAZIONE =============== */
.pagination-wrapper {
    margin: 2rem 0;
    display: flex;
    justify-content: center;
}

.pagination {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
}

.page-item {
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.2s;
}

.page-item:hover {
    transform: translateY(-2px);
}

.page-link {
    padding: 0.75rem 1.25rem;
    background: #f8f9fa;
    color: #0073aa !important;
    text-decoration: none;
    border: 1px solid #dee2e6;
}

.page-item.active .page-link {
    background: #0073aa !important;
    color: white !important;
    border-color: #0073aa;
}

.view-container { background: #fff; padding: 20px; margin: 20px 0; }
.view-header {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: space-between;
}

.view-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
/* Layout principale */
.view-details {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    align-items: start;
}

.detail-section {
    background: #ffffff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e3e8ee;
    margin-bottom: 20px;
}
.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f4f9;
}

.section-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #1a365d;
}

.detail-grid-inner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem;
}

.detail-item {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.25rem;
    padding: 0.5rem;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #edf2f7;
}

.detail-item.colspan-2 {
    grid-column: span 2;
}

.detail-label {
    font-size: 0.8rem;
    color: #4a5568;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.detail-value {
    font-size: 0.9rem;
    color: #1a202c;
    line-height: 1.4;
    word-break: break-word;
}

.detail-value a {
    color: #2b6cb0;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-value a:hover {
    text-decoration: underline;
}

.detail-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.detail-list li {
    background: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid #e2e8f0;
}

.empty-value {
    color: #a0aec0;
    font-style: italic;
}

/* Responsive */
@media (max-width: 1200px) {
    .view-details {
        grid-template-columns: 1fr;
    }
}


/* Bottoni Dettaglio */
.detail-action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
}

.detail-action-buttons .btn-action {
    padding: 6px 12px;
    font-size: 0.9em;
    min-width: 100px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.detail-action-buttons .btn-action i {
    font-size: 0.9em;
}

.modal { display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); }
.modal-content { background: white; margin: 15% auto; padding: 20px; width: 400px; border-radius: 5px; }
.modal-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.fa-spin {
    animation: fa-spin 2s infinite linear;
}

@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(359deg); }
}

/* ============= MOBILE ================ */
@media (max-width: 768px) {
    .cf7-table {
        font-size: 0.8rem; /* Testo ancora più piccolo */
    }

    .btn-action {
        padding: 0.4rem 0.6rem; /* Bottoni più compatti */
        font-size: 0.8rem; /* Testo più piccolo */
    }

    .cf7-table td.actions {
        width: 150px; /* Riduci ulteriormente la larghezza */
    }
    .view-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .view-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .detail-action-buttons {
        width: 100%;
        justify-content: flex-end;
        gap: 6px;
    }
    
    .detail-action-buttons .btn-action {
        padding: 6px 10px;
        min-width: auto;
        font-size: 0.85em;
        flex-grow: 1;
        justify-content: center;
    }
    
    .detail-action-buttons .btn-action i {
        display: none;
    }

    .detail-grid-inner {
        grid-template-columns: 1fr;
    }
    
    .detail-item {
        grid-column: span 1 !important;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* =============== STATISTICHE =============== */
.search-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-group {
    display: flex;
    gap: 8px;
    flex-grow: 1;
    max-width: 600px;
}

.stats-container {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    margin-left: auto;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.4rem 0.8rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    min-width: 90px;
}

.stat-distinct {
    color: #4a90e2;
    font-weight: bold;
    font-size: 1.4em;
}

.stat-value {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    line-height: 1.2;
    white-space: nowrap;
}

.stat-positive { color: #28a745; }
.stat-negative { color: #dc3545; }

/* Responsive */
@media (max-width: 1200px) {
    .stats-container {
        gap: 0.6rem;
    }
    .stat-item {
        min-width: 80px;
        padding: 0.4rem 0.6rem;
    }
}

@media (max-width: 992px) {
    .search-container {
        flex-direction: row;
    }
    .search-group {
        max-width: none;
    }
    .stats-container {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 768px) {
    .search-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-group {
        width: 100%;
    }
    
    .stats-container {
        justify-content: space-between;
    }
    
    .stat-item {
        flex-grow: 1;
        min-width: auto;
        padding: 0.5rem;
    }
    
    .stat-label {
        white-space: normal;
        text-align: center;
    }
}

@media (max-width: 576px) {
    .stats-container {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .stat-item {
        flex-basis: calc(50% - 0.4rem);
        margin-bottom: 0.5rem;
    }
}

.notice-info {
    padding: 15px;
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.notice-info i {
    margin-right: 10px;
    color: #2196f3;
}

/* Stili per la selezione utente */
/* Sezione selezione utente */
.user-type-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.user-type-selector .wpcf7-list-item {
    margin: 0 20px 10px 0;
    display: inline-flex;
    align-items: center;
}

.user-type-radio input[type="radio"] {
    margin-right: 8px;
}

#existing-user-fields {
    margin-top: 20px;
    padding: 20px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.button-group {
    display: flex;
    gap: 10px;
}

.cf-search-btn {
    background: #28a745 !important;
    color: white !important;
    padding: 12px 20px !important;
    border: none !important;
    transition: background 0.3s !important;
}

.cf-search-btn:hover {
    background: #218838 !important;
}

.cf-search-btn:disabled {
    background: #6c757d !important;
    cursor: not-allowed !important;
}

.cf-clear-btn {
    background: #dc3545 !important;
    color: white !important;
    padding: 12px 20px !important;
    border: none !important;
    transition: background 0.3s !important;
}

.cf-clear-btn:hover {
    background: #c82333 !important;
}

/* Messaggi di feedback */
.loading {
    color: #007bff;
    padding: 10px;
    border-left: 3px solid #007bff;
    margin-top: 10px;
}

.success {
    color: #28a745;
    padding: 10px;
    border-left: 3px solid #28a745;
    margin-top: 10px;
}

.error {
    color: #dc3545;
    padding: 10px;
    border-left: 3px solid #dc3545;
    margin-top: 10px;
}

/* Campi auto-compilati */
.auto-filled {
    background-color: #e8f4fc !important;
    border-color: #17a2b8 !important;
    box-shadow: 0 0 8px rgba(23, 162, 184, 0.1);
}

.auto-filled:focus {
    box-shadow: 0 0 8px rgba(23, 162, 184, 0.3);
}

/* Nuove regole CSS */
#new-user-fields {
    margin-top: 20px;
    transition: all 0.3s ease;
}

.highlight-section {
    position: relative;
    padding: 20px;
    background-color: #f8ffff;
    border: 2px solid #2185d0;
    border-radius: 8px;
}

.highlight-section::before {
    content: "Campi precompilati - Modificabili";
    position: absolute;
    top: -12px;
    left: 20px;
    background: #2185d0;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.9em;
}

.auto-filled-label {
    display: block !important;
    color: #2185d0 !important;
    font-weight: bold !important;
    margin-bottom: 8px !important;
}

.auto-filled-label::after {
    content: " (precompilato)";
    font-weight: normal;
    color: #666;
    font-size: 0.9em;
}

.info-message {
    padding: 15px;
    background: #e8f4fc;
    border-left: 4px solid #2185d0;
    margin-bottom: 20px;
    border-radius: 4px;
}

.info-message i {
    margin-right: 10px;
    color: #2185d0;
}

/* Stili per il reset */
#reset-fields {
    transition: all 0.3s ease;
    position: relative;
}

#reset-fields:after {
    content: "⟳";
    margin-left: 5px;
    font-size: 1.1em;
}

#reset-fields:active {
    transform: scale(0.95);
}

.file-preview {
    color: #666;
    font-size: 0.9em;
    padding: 5px 0;
    font-style: italic;
}