/* 
 * Custom Supreme User Profile - Frontend Styles
 * Versione: 1.0.0
 */

:root {
    --csup-primary: #0b3a6f;
    --csup-primary-dark: #082a52;
    --csup-secondary: #1a5296;
    --csup-success: #28a745;
    --csup-danger: #dc3545;
    --csup-warning: #ffc107;
    --csup-info: #17a2b8;
    --csup-light: #f8f9fa;
    --csup-dark: #343a40;
    --csup-border: #dee2e6;
    --csup-shadow: 0 4px 12px rgba(0,0,0,0.08);
    --csup-radius: 8px;
    --csup-transition: all 0.3s ease;
}

/* Reset e Base */
.csup-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Header Profilo */
.csup-profile-header {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, var(--csup-primary), var(--csup-secondary));
    color: white;
    padding: 2rem;
    border-radius: var(--csup-radius);
    margin-bottom: 2rem;
    box-shadow: var(--csup-shadow);
}

.csup-avatar {
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: bold;
    margin-right: 2rem;
    border: 4px solid rgba(255,255,255,0.3);
}

.csup-profile-info h1 {
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
}

.csup-profile-info .email {
    opacity: 0.9;
    margin-bottom: 1rem;
}

.csup-badges {
    display: flex;
    gap: 0.5rem;
}

.csup-badge {
    padding: 0.25rem 0.75rem;
    background: rgba(255,255,255,0.15);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Alert Messages */
.csup-alert {
    padding: 1rem 1.25rem;
    border-radius: var(--csup-radius);
    margin-bottom: 1.5rem;
    display: none;
}

.csup-alert.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.csup-alert.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.csup-alert.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Tabs Navigation */
.csup-tabs {
    display: flex;
    background: white;
    border-radius: var(--csup-radius);
    margin-bottom: 2rem;
    overflow: hidden;
    box-shadow: var(--csup-shadow);
}

.csup-tab-btn {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    background: none;
    font-weight: 600;
    color: var(--csup-dark);
    cursor: pointer;
    transition: var(--csup-transition);
}

.csup-tab-btn:hover {
    background: var(--csup-light);
}

.csup-tab-btn.active {
    background: var(--csup-primary);
    color: white;
}

/* Tab Content */
.csup-tab-content {
    background: white;
    border-radius: var(--csup-radius);
    padding: 2rem;
    box-shadow: var(--csup-shadow);
}

.csup-tab-pane {
    display: none;
}

.csup-tab-pane.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Info Grid Layout */
.csup-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.csup-info-section {
    background: var(--csup-light);
    border-radius: var(--csup-radius);
    padding: 1.5rem;
}

.csup-info-section h3 {
    color: var(--csup-primary);
    margin-top: 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--csup-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.csup-info-row {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.csup-info-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.csup-info-row strong {
    display: inline-block;
    min-width: 160px;
    color: var(--csup-dark);
}

/* Form Styles - CORREZIONE PER ALLINEAMENTO SELECT */
.csup-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .csup-form-grid {
        grid-template-columns: 1fr;
    }
}

.csup-form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

.csup-form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--csup-dark);
}

.csup-form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--csup-border);
    border-radius: 6px;
    font-size: 1rem;
    transition: var(--csup-transition);
    background: white;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
    height: auto;
    min-height: 48px; /* Altezza minima uniforme */
    display: flex;
    align-items: center;
}

/* CORREZIONE SPECIFICA PER SELECT */
.csup-form-control select {
    padding: 0.75rem 1rem;
    line-height: 1.5;
    height: 48px; /* Altezza fissa per allineamento */
    display: flex;
    align-items: center;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

.csup-form-control:focus {
    outline: none;
    border-color: var(--csup-primary);
    box-shadow: 0 0 0 3px rgba(11, 58, 111, 0.1);
}

.csup-form-control[readonly] {
    background: #f5f5f5;
    cursor: not-allowed;
    color: #666;
}

.csup-form-help {
    display: block;
    margin-top: 0.5rem;
    color: #666;
    font-size: 0.85rem;
}

/* Button Styles */
.csup-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--csup-transition);
    text-decoration: none;
    gap: 0.5rem;
    font-family: inherit;
    line-height: 1.5;
    height: 48px; /* Altezza consistente con i form-control */
}

.csup-btn-primary {
    background: var(--csup-primary);
    color: white;
}

.csup-btn-primary:hover {
    background: var(--csup-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.csup-btn-secondary {
    background: #6c757d;
    color: white;
}

.csup-btn-secondary:hover {
    background: #545b62;
}

/* Stats */
.csup-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.csup-stat {
    text-align: center;
    padding: 1rem;
    background: white;
    border-radius: var(--csup-radius);
    border: 2px solid var(--csup-border);
}

.csup-stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: var(--csup-primary);
}

.csup-stat-label {
    font-size: 0.9rem;
    color: #666;
}

/* Activity List */
.csup-activity-list {
    max-height: 400px;
    overflow-y: auto;
}

.csup-activity-item {
    padding: 1rem;
    border-bottom: 1px solid var(--csup-border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.csup-activity-item:last-child {
    border-bottom: none;
}

.csup-activity-icon {
    width: 40px;
    height: 40px;
    background: #f0f7ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--csup-primary);
    flex-shrink: 0;
}

.csup-activity-content {
    flex: 1;
}

.csup-activity-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.csup-activity-description {
    color: #666;
    font-size: 0.9rem;
}

.csup-activity-time {
    color: #999;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Gestione Operatori */
.csup-gestione-operatori {
    padding: 1rem;
}

.csup-gestione-operatori h3 {
    color: var(--csup-primary);
    margin-top: 0;
    margin-bottom: 1rem;
}

.csup-gestione-operatori p {
    color: #666;
    margin-bottom: 1.5rem;
}

/* Tab Gestione Operatori specifico */
#tab-operatori .csup-form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
}

/* Login Required */
.csup-login-required {
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: var(--csup-radius);
    box-shadow: var(--csup-shadow);
}

/* Form row per due campi affiancati */
.csup-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: center;
}

.csup-form-row .csup-form-group {
    margin-bottom: 0;
}

/* Error styles */
.csup-form-error {
    color: var(--csup-danger);
    font-size: 0.85rem;
    margin-top: 0.25rem;
    display: block;
}

.csup-form-control.error {
    border-color: var(--csup-danger);
}

/* Responsive */
@media (max-width: 768px) {
    .csup-profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .csup-avatar {
        margin-right: 0;
        margin-bottom: 1rem;
    }
    
    .csup-tabs {
        flex-direction: column;
    }
    
    .csup-info-grid,
    .csup-form-grid {
        grid-template-columns: 1fr;
    }
    
    .csup-form-row {
        grid-template-columns: 1fr;
    }
    
    .csup-form-control select {
        height: 48px; /* Mantieni altezza consistente su mobile */
    }
}

/* Stili aggiuntivi per uniformità */
input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* Assicura che tutti gli input abbiano la stessa altezza */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="password"],
select {
    min-height: 48px;
    display: flex;
    align-items: center;
}

/* Stili per la tabella operatori */
.csup-table-container {
    margin: 1rem 0;
    border-radius: var(--csup-radius);
    overflow: hidden;
    box-shadow: var(--csup-shadow);
}

.csup-operatori-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.csup-operatori-table th {
    background: var(--csup-primary);
    color: white;
    font-weight: 600;
    text-align: left;
    padding: 12px 15px;
}

.csup-operatori-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--csup-border);
}

.csup-operatori-table tr:hover {
    background: var(--csup-light);
}

.csup-operatori-table tr:last-child td {
    border-bottom: none;
}

/* MODALE CENTRATA */
.csup-modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 9999;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.csup-modal-backdrop.active {
    display: flex !important;
    align-items: flex-start;
    justify-content: center;
    animation: modalFadeIn 0.3s ease;
}

.csup-modal-content {
    background: white;
    border-radius: var(--csup-radius);
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
    margin-top: 60px;
    margin-bottom: 60px;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stili per il pulsante di chiusura */
.csup-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #666;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 10;
}

.csup-modal-close:hover {
    background: var(--csup-light);
    color: var(--csup-danger);
}

/* Header della modale con titolo e pulsante chiusura */
.csup-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--csup-border);
    position: relative;
}

.csup-modal-header h3 {
    margin: 0;
    color: var(--csup-primary);
    font-size: 1.5rem;
}

/* Miglioramenti responsive */
@media (max-width: 768px) {
    .csup-modal-backdrop {
        padding: 10px;
    }
    
    .csup-modal-content {
        padding: 1.5rem;
        margin-top: 40px;
        margin-bottom: 40px;
        max-height: 80vh;
    }
    
    .csup-modal-header h3 {
        font-size: 1.3rem;
    }
    
    .csup-table-container {
        font-size: 0.9rem;
    }
    
    .csup-operatori-table th,
    .csup-operatori-table td {
        padding: 8px 10px;
    }
    
    .csup-operatori-table {
        display: block;
        overflow-x: auto;
    }
    
    .csup-operatori-table thead {
        display: none;
    }
    
    .csup-operatori-table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--csup-border);
        border-radius: var(--csup-radius);
        padding: 1rem;
    }
    
    .csup-operatori-table td {
        display: block;
        text-align: right;
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }
    
    .csup-operatori-table td:before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        color: var(--csup-primary);
    }
    
    .csup-operatori-table td:last-child {
        border-bottom: none;
        text-align: center;
        padding-top: 1rem;
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    
    .csup-operatori-table td .csup-btn {
        width: 100%;
    }
}

/* Stili per modale più piccola su schermi molto grandi */
@media (min-width: 1200px) {
    .csup-modal-content {
        max-width: 700px;
    }
}

/* Overlay di sfondo */
.csup-modal-backdrop:before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: -1;
}

/* Per evitare scroll del body quando la modale è aperta */
body.modal-open {
    overflow: hidden;
}

/* Stili per i pulsanti nella tabella */
.csup-operatori-table td .csup-btn {
    margin: 2px;
    transition: all 0.2s ease;
}

.csup-operatori-table td .csup-btn-primary {
    background: var(--csup-primary);
    border-color: var(--csup-primary);
}

.csup-operatori-table td .csup-btn-secondary {
    background: #6c757d;
    border-color: #6c757d;
}

.csup-operatori-table td .csup-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Pulsanti nel modale */
#viewFromEditBtn {
    background: #6c757d !important;
    border-color: #6c757d !important;
}

#viewFromEditBtn:hover {
    background: #5a6268 !important;
    border-color: #545b62 !important;
}

/* Stili per il form di modifica semplificato */
.csup-operatore-edit-form .csup-form-group:has(input[readonly]) {
    opacity: 0.7;
}

.csup-operatore-edit-form .csup-form-group:has(input[readonly]) .csup-form-label {
    color: #666;
}

.csup-operatore-edit-form .csup-form-group:has(input[readonly]) .csup-form-control {
    background: #f8f9fa;
    cursor: not-allowed;
}

/* Separatore tra campi modificabili e non modificabili */
.csup-operatore-edit-form h4 {
    margin-top: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--csup-border);
    color: var(--csup-primary);
}

.csup-operatore-edit-form h4:first-of-type {
    margin-top: 0;
}