/* =============== 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;
    }
}

.select-simple {
    min-width: 100px;
    padding: 8px;
  }

  .stat-male {
    color: #0066cc; /* Azzurro */
}

.stat-female {
    color: #ff66b3; /* Rosa */
}

.file-link:hover {
    color: #135e96 !important;
    text-decoration: underline !important;
}
.file-link .file-icon {
    transition: transform 0.2s;
}
.file-link:hover .file-icon {
    transform: translateY(-2px);
}

.supporti-responsive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.support-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  background-color: #fafafa;
  box-shadow: 1px 1px 5px rgba(0,0,0,0.05);
}

.support-title {
  font-weight: bold;
  font-size: 1.2em;
  margin-bottom: 8px;
  color: #222;
}

.support-body p {
  margin: 4px 0;
}

.risultati-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.form-group {
    border: 1px solid #ddd;
    padding: 1rem;
    border-radius: 6px;
    background: #f9f9f9;
}

.form-group .form-subfield {
    margin-bottom: 0.75rem;
}

.form-label {
  display: block;
  font-weight: bold;
  white-space: normal !important;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.risultati-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.risultati-grid .form-group {
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.risultati-responsive-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  margin-bottom: 2rem;
}

.result-card {
  border: 1px solid #ccc;
  border-left: 5px solid #0073aa;
  border-radius: 6px;
  padding: 1rem;
  background: #f9f9f9;
}

.result-title {
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.result-body p {
  margin: 0.3rem 0;
}

.periodo-supporto-wrapper {
  text-align: center;
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 15px;
}

.periodo-supporto-wrapper .label {
  margin-right: 5px;
}

.periodo-supporto-wrapper .value em {
  font-style: normal;
  text-decoration: underline;
}

.periodo-supporto-globale-edit {
  text-align: center;
  margin: 1.5em auto;
  background: #f9f9f9;
  border-radius: 8px;
  padding: 1.2em;
  max-width: 500px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.periodo-supporto-globale-edit label {
  display: block;
  font-weight: bold;
  margin-bottom: 0.6em;
  font-size: 1.1em;
}

.form-periodo-date-group {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5em;
  flex-wrap: wrap;
}

.form-periodo-date-group input[type="date"] {
  padding: 0.4em;
  font-size: 1em;
}

.form-periodo-prefix {
  font-weight: bold;
  font-size: 1.05em;
}

.supporti-responsive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 25px;
  margin-top: 20px;
}

.support-card {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.support-card h4 {
  margin-top: 0;
  font-size: 16px;
}

.support-card .form-row {
  margin-bottom: 12px;
}

/* =============== RISULTATI - STILE SIMILE A SUPPORTI =============== */

/* Sovrascrivi lo stile esistente dei risultati per renderli simili ai supporti */
.risultati-grid .form-group {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    background-color: #fafafa;
    box-shadow: 1px 1px 5px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    margin-bottom: 0;
}

.risultati-grid .form-group:hover {
    box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

/* Stile per il titolo del risultato */
.risultati-grid .form-group .form-label {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 12px;
    color: #2c3e50;
    border-bottom: 1px solid #eaeaea;
    padding-bottom: 8px;
}

/* Stile per i risultati non coerenti */
.risultati-grid .form-group.risultato-non-coerente {
    border-left: 4px solid #e74c3c;
    background-color: #fff5f5;
}

.risultati-grid .form-group.risultato-non-coerente .form-label {
    color: #e74c3c;
}

/* Messaggio di avviso per risultati non coerenti */
.warning-icon {
    display: block;
    background: #fff3cd;
    color: #856404;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    margin-bottom: 10px;
    border-left: 3px solid #ffc107;
}

/* Stile per il select dei risultati */
.risultati-grid .form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 0.95em;
}

.risultati-grid .form-group select:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.2);
}

/* Layout a griglia migliorato per risultati */
.risultati-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Responsive per risultati */
@media (max-width: 768px) {
    .risultati-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .risultati-grid .form-group {
        padding: 12px;
    }
}

/* Miglioramenti per la sezione modifica risultati */
.form-subsection .risultati-grid {
    margin-top: 15px;
}

/* Allineamento con lo stile dei supporti */
.form-subsection .risultati-grid .form-group {
    background: #fff;
    border: 1px solid #e0e0e0;
}

/* Effetto hover consistente con i supporti */
.form-subsection .risultati-grid .form-group:hover {
    background: #f8f9fa;
}

/* =============== PULSANTI PERSONALIZZATI =============== */

/* Pulsante Esporta Scheda CPT */
.button.button-primary[type="submit"] {
    background: #0073aa !important;
    color: white !important;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    margin: 10px 0;
}

.button.button-primary[type="submit"]:hover {
    background: #005a87 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.button.button-primary[type="submit"]::before {
    content: "📊";
    font-size: 1.1em;
}

/* Pulsante Elimina */
.btn-delete {
    background: #dc3545 !important;
    color: white !important;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-delete:hover {
    background: #c82333 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(220, 53, 69, 0.3);
}

.btn-delete i {
    color: white !important;
}

/* Pulsante Scarica Scheda Anagrafica */
.btn-download {
    background: #28a745 !important;
    color: white !important;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-download:hover {
    background: #218838 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(40, 167, 69, 0.3);
}

.btn-download i {
    color: white !important;
}

/* Responsive per i pulsanti */
@media (max-width: 768px) {
    .button.button-primary[type="submit"],
    .btn-delete,
    .btn-download {
        padding: 8px 12px;
        font-size: 0.9em;
        min-width: auto;
    }
    
    .detail-action-buttons .btn-delete,
    .detail-action-buttons .btn-download {
        flex-grow: 1;
        justify-content: center;
    }
}

/* Stili per i bottoni questionario */
.btn-new-questionario {
    background: #28a745 !important;
    color: white !important;
    border: 1px solid #218838 !important;
}

.btn-new-questionario:hover {
    background: #218838 !important;
}

.btn-edit-questionario {
    background: #17a2b8 !important;
    color: white !important;
    border: 1px solid #138496 !important;
}

.btn-edit-questionario:hover {
    background: #138496 !important;
}

/* Nella tabella, rendi i bottoni più compatti */
.actions .btn-action {
    margin: 2px;
    padding: 6px 10px;
    font-size: 0.85em;
}

/* Nel dettaglio, bottoni più grandi */
.detail-action-buttons .btn-action {
    margin: 5px;
    padding: 10px 15px;
    font-size: 0.95em;
}

/* Badge completato */
.badge-questionario-completato {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #28a745;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
    vertical-align: middle;
}

/* Effetti hover per pulsanti questionario */
.btn-action.btn-edit-questionario:hover {
    background-color: #138496 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
}

.btn-action.btn-new-questionario:hover {
    background-color: #218838 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
}

/* Per il pulsante nella modifica */
.form-subsection a[href*="questionario"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
}

/* Stili per il menu Profilo con sottomenu */
.menu-item-profile {
    position: relative;
}

.menu-item-profile .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 4px;
    z-index: 1000;
    margin: 0;
    padding: 0;
    list-style: none;
}

.menu-item-profile:hover .sub-menu {
    display: block;
}

.menu-item-profile .sub-menu li {
    margin: 0;
    padding: 0;
}

.menu-item-profile .sub-menu a {
    display: block;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
    white-space: nowrap;
}

.menu-item-profile .sub-menu a:hover {
    background: #f5f5f5;
}

/* Icone */
.profile-icon, .login-icon, .logout-icon {
    margin-right: 5px;
    display: inline-block;
}