/*
 * Custom Supreme - User Profile Frontend Styles
 */

: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;
}

/* ===================== Container ===================== */
.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);
    flex-shrink: 0;
}

.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;
    flex-wrap: wrap;
}

.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 ===================== */
.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;
}

.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.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ===================== Info Grid ===================== */
.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,
.csup-info-section h4 {
    color: var(--csup-primary);
    margin-top: 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--csup-border);
}

.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 ===================== */
.csup-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

/* Etichette di gruppo (h3/h4) dentro le colonne del form */
.csup-form-grid > div > h3,
.csup-form-grid > div > h4 {
    color: var(--csup-primary);
    margin: 0 0 1rem 0;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid var(--csup-border);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.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;
    font-family: inherit;
    transition: var(--csup-transition);
    background: white;
    box-sizing: border-box;
    line-height: 1.5;
    min-height: 48px;
}

.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-control.error {
    border-color: var(--csup-danger);
}

.csup-form-error {
    color: var(--csup-danger);
    font-size: 0.85rem;
    margin-top: 0.25rem;
    display: block;
}

/* ===================== Buttons ===================== */
.csup-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--csup-transition);
    text-decoration: none;
    gap: 0.5rem;
    line-height: 1.5;
    height: 48px;
}

.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);
    color: white;
}

.csup-btn-secondary {
    background: #6c757d;
    color: white;
}

.csup-btn-secondary:hover {
    background: #545b62;
    color: white;
}

/* ===================== 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 ===================== */
.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;
}

/* ===================== Tabella Operatori ===================== */
.csup-gestione-operatori h3 {
    color: var(--csup-primary);
    margin-top: 0;
}

.csup-gestione-operatori p {
    color: #666;
    margin-bottom: 1.5rem;
}

.csup-table-container {
    /* Full-bleed: occupa l'intera larghezza del viewport, ignora il max-width del tema */
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 1rem;
    margin-bottom: 1rem;
    border-radius: 0;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: var(--csup-shadow);
}

.csup-operatori-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
    background: white;
    table-layout: fixed;
}

/* Larghezze colonne proporzionali */
.csup-operatori-table th:nth-child(1),
.csup-operatori-table td:nth-child(1) { width: 19%; } /* Operatore */
.csup-operatori-table th:nth-child(2),
.csup-operatori-table td:nth-child(2) { width: 16%; } /* Contatto */
.csup-operatori-table th:nth-child(3),
.csup-operatori-table td:nth-child(3) { width: 9%; }  /* Ambito */
.csup-operatori-table th:nth-child(4),
.csup-operatori-table td:nth-child(4) { width: 14%; } /* Ruolo */
.csup-operatori-table th:nth-child(5),
.csup-operatori-table td:nth-child(5) { width: 12%; } /* Incarico */
.csup-operatori-table th:nth-child(6),
.csup-operatori-table td:nth-child(6) { width: 13%; } /* Ultimo accesso */
.csup-operatori-table th:nth-child(7),
.csup-operatori-table td:nth-child(7) { width: 9%; text-align: center; }  /* Stato */
.csup-operatori-table th:nth-child(8),
.csup-operatori-table td:nth-child(8) { width: 8%; text-align: center; }  /* Azioni */

.csup-operatori-table th {
    background: var(--csup-primary);
    color: white;
    font-weight: 600;
    text-align: left;
    padding: 10px 10px;
    font-size: 0.83rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.csup-operatori-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--csup-border);
    overflow: hidden;
}

.csup-operatori-table tr:hover {
    background: var(--csup-light);
}

.csup-operatori-table tr:last-child td {
    border-bottom: none;
}

.csup-operatori-table td .csup-btn {
    margin: 2px;
}

/* ===================== Modale ===================== */
.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); }
}

.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);
}

.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;
}

/* Body bloccato quando modale aperta */
body.modal-open {
    overflow: hidden;
}

/* ===================== Login Required ===================== */
.csup-login-required {
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: var(--csup-radius);
    box-shadow: var(--csup-shadow);
}

/* ===================== Loading ===================== */
.csup-loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

/* ===================== 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-modal-backdrop { padding: 10px; }

    .csup-modal-content {
        padding: 1.5rem;
        margin-top: 40px;
        margin-bottom: 40px;
        max-height: 90vh;
    }

    .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: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    .csup-operatori-table td:before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--csup-primary);
    }

    .csup-operatori-table td:last-child {
        border-bottom: none;
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
        padding-top: 1rem;
    }

    .csup-operatori-table td .csup-btn {
        width: 100%;
    }
}

/* ===================== Gestione Operatori — Design Moderno ===================== */

.csup-go-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.csup-go-stats {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.csup-go-stat {
    background: white;
    border: 1px solid var(--csup-border);
    border-left: 3px solid var(--csup-primary);
    border-radius: var(--csup-radius);
    padding: 0.65rem 1.1rem;
    text-align: center;
    min-width: 80px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.csup-go-stat--green { border-left-color: var(--csup-success); }
.csup-go-stat--red   { border-left-color: var(--csup-danger);  }

.csup-go-stat-num {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--csup-primary);
    line-height: 1.1;
}

.csup-go-stat--green .csup-go-stat-num { color: var(--csup-success); }
.csup-go-stat--red   .csup-go-stat-num { color: var(--csup-danger);  }

.csup-go-stat-label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
    display: block;
}

.csup-go-toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.csup-go-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.csup-go-search-icon {
    position: absolute;
    left: 0.7rem;
    color: #aaa;
    font-size: 0.8rem;
    pointer-events: none;
}

.csup-go-search {
    padding: 0.55rem 0.75rem 0.55rem 2.1rem;
    border: 1.5px solid var(--csup-border);
    border-radius: 8px;
    font-size: 0.88rem;
    outline: none;
    width: 210px;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.csup-go-search:focus {
    border-color: var(--csup-primary);
    box-shadow: 0 0 0 3px rgba(11,58,111,0.08);
}

.csup-go-filter {
    padding: 0.55rem 0.75rem;
    border: 1.5px solid var(--csup-border);
    border-radius: 8px;
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
    background: white;
    font-family: inherit;
    transition: border-color 0.2s;
}

.csup-go-filter:focus { border-color: var(--csup-primary); }

/* Celle tabella moderna */
.csup-op-cell-user {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.csup-op-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--csup-primary), var(--csup-secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
    flex-shrink: 0;
    letter-spacing: 0.05em;
}

.csup-op-name  { font-weight: 600; color: #1a1a1a; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.csup-op-login { font-size: 0.75rem; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.csup-op-email { font-size: 0.82rem; color: #444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.csup-op-tel   { font-size: 0.75rem; color: #999; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* Permette il troncamento dentro il flex della cella Operatore */
.csup-op-cell-user > div:last-child { min-width: 0; }

/* Badge pill */
.csup-badge-pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
}

.csup-badge-pill--blue   { background: #dbeafe; color: #1d4ed8; }
.csup-badge-pill--purple { background: #ede9fe; color: #6d28d9; }
.csup-badge-pill--green  { background: #dcfce7; color: #15803d; }

/* Date incarico */
.csup-op-date-range {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.83rem;
    color: #444;
    line-height: 1.7;
}

.csup-op-date-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #bbb;
    min-width: 20px;
}

.csup-text-muted { color: #ccc; }

/* Status badge */
.csup-op-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

.csup-op-status::before { content: '●'; font-size: 0.5rem; }
.csup-op-status--active   { background: #dcfce7; color: #15803d; }
.csup-op-status--inactive { background: #f3f4f6; color: #6b7280; }

/* Bottoni icona */
.csup-op-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.csup-btn-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1.5px solid var(--csup-border);
    background: white;
    color: #666;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    transition: all 0.18s ease;
    flex-shrink: 0;
}

.csup-btn-icon:hover {
    background: var(--csup-primary);
    border-color: var(--csup-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(11,58,111,0.2);
}

.csup-btn-icon--edit:hover {
    background: #0073aa;
    border-color: #0073aa;
}

/* ===================== Modal Operatore — Header Identità ===================== */

.csup-modal-header--user {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 0;
    padding-bottom: 1.25rem;
}

.csup-modal-user-identity {
    display: flex;
    align-items: flex-start;
    gap: 1.1rem;
    width: 100%;
    padding-right: 2.5rem;
}

.csup-modal-avatar-lg {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--csup-primary), var(--csup-secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.5rem;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(11,58,111,0.25);
    letter-spacing: 0.05em;
}

.csup-modal-user-info h3 {
    margin: 0 0 6px;
    font-size: 1.25rem;
    color: var(--csup-primary);
}

.csup-modal-user-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 10px;
}

.csup-modal-user-meta-item {
    font-size: 0.86rem;
    color: #555;
    display: flex;
    align-items: center;
    gap: 6px;
}

.csup-modal-user-meta-item i { color: #bbb; width: 14px; text-align: center; }

.csup-modal-user-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

/* Modal cards info */
.csup-modal-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.csup-modal-card {
    background: var(--csup-light);
    border-radius: var(--csup-radius);
    overflow: hidden;
    border: 1px solid var(--csup-border);
}

.csup-modal-card-head {
    background: var(--csup-primary);
    color: white;
    padding: 0.55rem 1rem;
    font-weight: 600;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 7px;
}

.csup-modal-card-body { padding: 0.9rem 1rem; }

.csup-modal-card-body .csup-info-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.86rem;
    margin-bottom: 0.55rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.csup-modal-card-body .csup-info-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.csup-modal-card-body .csup-info-row strong {
    min-width: auto;
    color: #888;
    font-weight: 500;
    white-space: nowrap;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.csup-modal-card-body .csup-info-row span {
    text-align: right;
    color: #222;
}

/* Modal footer */
.csup-modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding-top: 1.1rem;
    border-top: 1px solid var(--csup-border);
}

/* Responsive mobile nuovi elementi */
@media (max-width: 768px) {
    .csup-go-header { flex-direction: column; align-items: stretch; }
    .csup-go-search { width: 100%; }
    .csup-go-filter { width: 100%; }
    .csup-go-toolbar { flex-direction: column; }
    .csup-modal-cards { grid-template-columns: 1fr; }
    .csup-modal-user-identity { flex-direction: column; align-items: center; text-align: center; }
    .csup-modal-avatar-lg { width: 56px; height: 56px; font-size: 1.2rem; }
    .csup-modal-user-badges { justify-content: center; }
    .csup-modal-user-meta-item { justify-content: center; }
}
