/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #ca8a04;
    --warning-light: #fef9c3;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.5;
}

/* ==================== LOGIN PAGE ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: white;
    color: #1e293b;
    padding: 14px 30px 10px;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
}

.login-header img.login-logo {
    max-width: 220px;
    height: auto;
    margin-bottom: 0;
}

.login-header .version-inline {
    font-size: 10px;
    color: #0f172a;
    opacity: 0.5;
    letter-spacing: 0.5px;
    margin-top: -2px;
    margin-bottom: 2px;
    text-align: right;
    margin-right: calc(50% - 110px);
}

.login-header h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.login-header p {
    opacity: 0.7;
    font-size: 12px;
    color: #475569;
    margin-top: 2px;
    margin-bottom: 0;
}

.login-body {
    padding: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-700);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input::placeholder {
    color: var(--gray-400);
}

/* Checkbox Ricordami CF */
.remember-cf-group {
    margin-bottom: 16px;
    margin-top: -8px;
}

.remember-cf-group .checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 400;
    user-select: none;
}

.remember-cf-group .checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.remember-cf-group .checkbox-custom {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--gray-300);
    border-radius: 4px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: white;
}

.remember-cf-group .checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.remember-cf-group .checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.remember-cf-group .checkbox-label:hover .checkbox-custom {
    border-color: var(--primary);
}

.remember-cf-group .checkbox-text {
    font-size: 14px;
    color: var(--gray-600);
}

.otp-input {
    text-align: center;
    font-size: 24px !important;
    letter-spacing: 8px;
    font-weight: 600;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fca5a5;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #86efac;
}

.alert-info {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid #93c5fd;
}

.email-hint {
    text-align: center;
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 20px;
}

.back-link {
    text-align: center;
    margin-top: 16px;
}

.back-link a {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}

.back-link a:hover {
    text-decoration: underline;
}

/* ==================== DASHBOARD ==================== */
.dashboard {
    min-height: 100vh;
}

.navbar {
    background: white;
    box-shadow: var(--shadow);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-name {
    font-weight: 500;
    color: var(--gray-700);
}

.session-info {
    font-size: 12px;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 4px 10px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.session-info::before {
    content: '\23F1';
    font-size: 11px;
}

.btn-logout {
    padding: 8px 16px;
    font-size: 14px;
    width: auto;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    overflow-x: hidden;
}

.welcome-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 24px;
}

.welcome-card h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.welcome-card p {
    opacity: 0.9;
}

.welcome-card .welcome-update {
    font-size: 13px;
    opacity: 0.75;
    margin-left: 8px;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.data-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.data-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.data-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.data-card-icon.ferie {
    background: var(--success-light);
}

.data-card-icon.rol {
    background: var(--primary-light);
}

.data-card-icon.festivita {
    background: var(--warning-light);
}

.data-card-title {
    font-size: 14px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-card-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.data-card-unit {
    font-size: 16px;
    font-weight: 400;
    color: var(--gray-500);
}

.data-card-details {
    border-top: 1px solid var(--gray-200);
    margin-top: 16px;
    padding-top: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 8px;
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-label {
    color: var(--gray-500);
}

.detail-value {
    font-weight: 500;
    color: var(--gray-700);
}

.reference-info {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    color: var(--gray-600);
    font-size: 14px;
}

.reference-info strong {
    color: var(--gray-800);
}

/* ==================== ADMIN TABLE ==================== */
.admin-section {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.admin-section-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-section-header h3 {
    font-size: 18px;
    color: var(--gray-800);
}

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Colonne sortabili */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.data-table th.sortable:hover {
    background: var(--gray-100);
    color: var(--primary-color);
}

.data-table th.sortable .sort-icon {
    display: inline-block;
    margin-left: 4px;
    opacity: 0.3;
    font-size: 10px;
}

.data-table th.sortable .sort-icon::after {
    content: '▼';
}

.data-table th.sortable.sort-asc .sort-icon,
.data-table th.sortable.sort-desc .sort-icon {
    opacity: 1;
    color: var(--primary-color);
}

.data-table th.sortable.sort-asc .sort-icon::after {
    content: '▲';
}

.data-table th.sortable.sort-desc .sort-icon::after {
    content: '▼';
}

.data-table tr:hover {
    background: var(--gray-50);
}

/* Riga filtri nelle intestazioni (Gestione Ferie) */
.data-table thead .vac-filter-row th {
    padding: 6px 12px 10px;
    background: var(--gray-50);
    text-transform: none;
    letter-spacing: 0;
}
.data-table thead .vac-filter-row:hover th { background: var(--gray-50); }
.vac-filter {
    width: 100%;
    min-width: 70px;
    box-sizing: border-box;
    padding: 6px 8px;
    font-size: 13px;
    font-weight: 400;
    color: var(--gray-700, #374151);
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 6px;
    background: #fff;
}
.vac-filter:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.vac-filter.attivo { border-color: var(--primary-color); background: #eff6ff; }
.data-table thead .vac-filter-row th.numeric .vac-filter { text-align: right; }

.data-table .numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Colonne Residui Anno Precedente - stile più tenue */
.data-table .ap-column {
    color: var(--gray-500);
    font-size: 0.9em;
}

.data-table th[title*="Anno Precedente"] {
    color: var(--gray-500);
    font-size: 0.85em;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-admin {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-user {
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-info {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-warning {
    background: #fef3c7;
    color: #b45309;
}

.badge-purple {
    background: #ede9fe;
    color: #7c3aed;
}

.badge-success {
    background: #d1fae5;
    color: #059669;
}

.badge-error {
    background: #fee2e2;
    color: #dc2626;
}

/* ==================== STATS ROW ==================== */
.stats-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 20px;
    min-width: 150px;
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 14px;
    color: var(--gray-600);
    margin-top: 5px;
}

/* ==================== CONFIG TABLE ==================== */
.config-input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    width: 200px;
}

.config-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Select per ruolo utente */
.role-select {
    width: 140px;
    cursor: pointer;
}

.role-select:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    width: auto;
}

.btn-icon {
    padding: 6px;
    width: 32px;
    height: 32px;
}

/* ==================== TABS ==================== */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.tabs::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.tab {
    flex: 0 0 auto; /* Non ridurre, non crescere, dimensione automatica */
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab:hover {
    color: var(--gray-800);
}

.tab.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ==================== SUB-TABS ==================== */
.sub-tabs {
    display: flex;
    gap: 8px;
    background: white;
    padding: 8px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.sub-tab {
    padding: 10px 16px;
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.sub-tab:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--gray-800);
}

.sub-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.subtab-content {
    display: none;
}

.subtab-content.active {
    display: block;
}

/* ==================== LOADING ==================== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--gray-500);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    .navbar {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .container {
        padding: 16px;
        max-width: 100%;
        overflow-x: hidden;
    }

    .tabs {
        margin-left: -16px;
        margin-right: -16px;
        padding: 4px 16px;
        border-radius: 0;
    }

    .tab {
        padding: 10px 14px;
        font-size: 13px;
    }

    .sub-tabs {
        padding: 6px;
        gap: 6px;
    }

    .sub-tab {
        padding: 8px 12px;
        font-size: 12px;
    }

    .admin-section {
        margin-bottom: 16px;
    }

    .table-wrapper {
        margin-left: -16px;
        margin-right: -16px;
        padding: 0 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-grid {
        grid-template-columns: 1fr;
    }

    .data-table {
        min-width: 600px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 12px;
        white-space: nowrap;
    }

    .config-input {
        width: 120px;
    }

    /* Bottoni test connessione più compatti */
    .admin-section [style*="display: inline-flex"] {
        display: flex !important;
        flex-direction: column;
        gap: 8px;
    }

    .admin-section [style*="display: inline-flex"] .btn {
        width: 100%;
    }

    /* Header admin section responsive */
    .admin-section-header {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .admin-section-header .btn {
        width: 100%;
        margin-top: 12px;
    }

    /* Form nuovo utente responsive */
    #new-user-form > div[style*="grid"] {
        grid-template-columns: 1fr !important;
    }
}

/* ==================== MODAL SCELTA METODO OTP ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

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

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    margin-bottom: 8px;
    color: var(--gray-800);
}

.modal-content p {
    color: var(--gray-600);
    margin-bottom: 24px;
}

.method-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.btn-method {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-method:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-cancel-modal {
    margin-top: 8px;
    background: transparent;
    color: var(--gray-500);
    border: none;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 14px;
}

.btn-cancel-modal:hover {
    color: var(--gray-700);
}

/* ==================== HIDDEN ==================== */
.hidden {
    display: none !important;
}

/* ==================== VACATION CALENDAR ==================== */
.calendar-section {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.calendar-header h3 {
    font-size: 18px;
    color: var(--gray-800);
    margin: 0;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calendar-nav button {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-600);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-nav button:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.calendar-month-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    min-width: 140px;
    text-align: center;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.calendar-weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    padding: 8px 4px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: auto;
    min-height: 60px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    background: var(--gray-50);
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    border: 2px solid transparent;
}

.calendar-day:hover:not(.empty):not(.weekend):not(.past) {
    background: var(--primary-light);
    border-color: var(--primary);
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

.calendar-day.weekend {
    background: var(--gray-100);
    color: var(--gray-400);
    cursor: not-allowed;
}

.calendar-day.past {
    color: var(--gray-400);
    cursor: not-allowed;
}

.calendar-day.today {
    border-color: var(--primary);
    font-weight: 700;
}

.calendar-day.pending {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--warning);
}

.calendar-day.approved {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

.calendar-day.rejected {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
    text-decoration: line-through;
}

.calendar-day.half-day::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 3px;
    background: currentColor;
    border-radius: 2px;
    opacity: 0.6;
}

.calendar-day .day-number {
    font-size: 14px;
    line-height: 1;
}

.calendar-day .day-indicator {
    font-size: 8px;
    margin-top: 2px;
}

/* Mostra persone nel giorno - calendario admin */
.calendar-day .day-people {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
    align-items: center;
    margin-top: 4px;
    max-height: 44px;
    overflow: hidden;
}

/* Badge colorato per ogni persona - colori come export Excel */
.calendar-day .person-badge {
    display: inline-block;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
    white-space: nowrap;
    font-size: 9px;
    line-height: 1.3;
}

/* Colori tipo assenza - stessi dell'export Excel */
.person-badge.tipo-ferie {
    background: #90EE90;
    color: #1a5a1a;
}

.person-badge.tipo-rol {
    background: #87CEEB;
    color: #1a4a6e;
}

.person-badge.tipo-festivita {
    background: #FFA500;
    color: #5a3d00;
}

.person-badge.tipo-malattia {
    background: #FF6B6B;
    color: #5a1a1a;
}

.person-badge.tipo-altro {
    background: #B0C4DE;
    color: #2c3e50;
}

/* Pending: bordo tratteggiato + sfondo giallo */
.person-badge.stato-pending {
    background: #FFF59D !important;
    color: #5a5000 !important;
    border: 1px dashed #c9a800;
}

/* Indicatore overflow "+N" */
.calendar-day .more-badge {
    display: inline-block;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 700;
    font-size: 9px;
    background: var(--gray-200);
    color: var(--gray-700);
}

/* Giorni con richieste - sfondo neutro */
.calendar-day.has-requests {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

/* Festività nazionali - viola/magenta */
.calendar-day.holiday {
    background: #E1BEE7;
    border-color: #9C27B0;
    color: #6A1B9A;
    cursor: not-allowed;
}

.calendar-day .holiday-name {
    font-size: 7px;
    line-height: 1.2;
    text-align: center;
    margin-top: 2px;
    font-weight: 600;
    color: #6A1B9A;
    max-height: 24px;
    overflow: hidden;
    word-break: break-word;
}

/* Autoscaling font per celle con molti dipendenti */
.calendar-day.scale-small .person-badge,
.calendar-day.scale-small .more-badge {
    font-size: 8px;
    padding: 1px 3px;
}

.calendar-day.scale-tiny .person-badge,
.calendar-day.scale-tiny .more-badge {
    font-size: 7px;
    padding: 0px 2px;
}

/* Badge per visualizzare durata/orario sul giorno */
.calendar-day .day-badge {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
    background: currentColor;
    color: white;
    white-space: nowrap;
    line-height: 1.2;
}

.calendar-day .day-badge.time {
    font-size: 7px;
    padding: 1px 3px;
}

.calendar-day.pending .day-badge {
    background: var(--warning);
}

.calendar-day.approved .day-badge {
    background: var(--success);
}

.calendar-day.rejected .day-badge {
    background: var(--danger);
}

/* Stile per richieste orarie */
.calendar-day.hourly {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--gray-100) 100%);
}

.calendar-day.hourly.pending {
    background: linear-gradient(135deg, var(--warning-light) 0%, var(--gray-100) 50%);
}

.calendar-day.hourly.approved {
    background: linear-gradient(135deg, var(--success-light) 0%, var(--gray-100) 50%);
}

/* Giorni non lavorativi per part-time */
.calendar-day.non-working {
    background: #e5e7eb;
    color: #9ca3af;
}

.calendar-day.non-working .day-number {
    color: #9ca3af;
}

/* Mezza giornata lavorativa */
.calendar-day.partial-working {
    background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
}

.calendar-day .work-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 9px;
    color: #6b7280;
    background: #e5e7eb;
    padding: 1px 4px;
    border-radius: 3px;
}

/* Calendar Legend */
.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--gray-600);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    border: 2px solid;
}

.legend-dot.pending {
    background: var(--warning-light);
    border-color: var(--warning);
}

.legend-dot.approved {
    background: var(--success-light);
    border-color: var(--success);
}

.legend-dot.rejected {
    background: var(--danger-light);
    border-color: var(--danger);
}

/* Colori legenda calendario admin - stesso stile export Excel */
.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    display: inline-block;
}

.calendar-legend-admin {
    flex-wrap: wrap;
}

.legend-dot.half-day {
    background: var(--gray-200);
    border-color: var(--gray-400);
    position: relative;
}

.legend-dot.half-day::after {
    content: '';
    position: absolute;
    bottom: 1px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 2px;
    background: var(--gray-500);
    border-radius: 1px;
}

/* New Request Button */
.btn-new-request {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-new-request:hover {
    background: var(--primary-dark);
}

/* My Requests List */
.my-requests-section {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.my-requests-section h3 {
    font-size: 18px;
    color: var(--gray-800);
    margin-bottom: 16px;
}

.requests-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.request-card {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    border-left: 4px solid var(--gray-300);
}

.request-card.pending {
    border-left-color: var(--warning);
}

.request-card.approved {
    border-left-color: var(--success);
}

.request-card.rejected {
    border-left-color: var(--danger);
}

.request-info {
    flex: 1;
    min-width: 200px;
}

.request-dates {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.request-details {
    font-size: 13px;
    color: var(--gray-600);
}

.request-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.pending {
    background: var(--warning-light);
    color: var(--warning);
}

.status-badge.approved {
    background: var(--success-light);
    color: var(--success);
}

.status-badge.rejected {
    background: var(--danger-light);
    color: var(--danger);
}

.request-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.btn-delete-request {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 0;
    transition: all 0.2s;
}

.btn-delete-request:hover {
    color: #b91c1c;
    text-decoration: underline;
}

.no-requests {
    text-align: center;
    color: var(--gray-500);
    padding: 24px;
    font-size: 14px;
}

/* ==================== REQUEST MODAL ==================== */
.modal-request {
    max-width: 450px;
}

.modal-request h3 {
    margin-bottom: 20px;
    color: var(--gray-800);
}

.modal-request .form-group {
    text-align: left;
}

.modal-request .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.modal-request select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 16px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.modal-request select:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-request textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 16px;
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

.modal-request textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-buttons .btn {
    flex: 1;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--gray-800);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    max-width: 350px;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.warning {
    background: var(--warning);
}

.toast-icon {
    font-size: 20px;
}

.toast-message {
    font-size: 14px;
    font-weight: 500;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* ==================== ADMIN VACATION MANAGEMENT ==================== */
.admin-calendar-section {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
}

.filters-row select {
    padding: 10px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    min-width: 150px;
}

.filters-row select:focus {
    outline: none;
    border-color: var(--primary);
}

.stat-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-50);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
}

.stat-badge-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-badge-label {
    color: var(--gray-600);
}

.stat-badge.pending {
    background: var(--warning-light);
}

.stat-badge.pending .stat-badge-value {
    color: var(--warning);
}

.stat-badge.approved {
    background: var(--success-light);
}

.stat-badge.approved .stat-badge-value {
    color: var(--success);
}

/* Admin Vacation Table */
.vacation-table {
    width: 100%;
    border-collapse: collapse;
}

.vacation-table th,
.vacation-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.vacation-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
    text-transform: uppercase;
}

.vacation-table tr:hover {
    background: var(--gray-50);
}

.vacation-details {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
}

.btn-action {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-approve {
    background: var(--success-light);
    color: var(--success);
}

.btn-approve:hover {
    background: var(--success);
    color: white;
}

.btn-reject {
    background: var(--danger-light);
    color: var(--danger);
}

.btn-reject:hover {
    background: var(--danger);
    color: white;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* Admin Calendar Grid */
.admin-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.admin-calendar-day {
    min-height: 80px;
    border-radius: 8px;
    background: var(--gray-50);
    padding: 8px;
    font-size: 12px;
}

.admin-calendar-day.empty {
    background: transparent;
}

.admin-calendar-day.weekend {
    background: var(--gray-100);
}

.admin-calendar-day .day-header {
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.admin-calendar-day .vacation-chip {
    background: var(--warning-light);
    color: var(--warning);
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.admin-calendar-day .vacation-chip.approved {
    background: var(--success-light);
    color: var(--success);
}

.admin-calendar-day .vacation-chip.rejected {
    background: var(--danger-light);
    color: var(--danger);
}

/* Action Modal */
.modal-action {
    max-width: 450px;
}

.modal-action h3 {
    margin-bottom: 20px;
}

.modal-action .request-summary {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    text-align: left;
}

.modal-action .request-summary p {
    margin: 4px 0;
    color: var(--gray-700);
}

.modal-action .request-summary strong {
    color: var(--gray-800);
}

/* General Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal .modal-content {
    position: relative;
    z-index: 1001;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
    color: var(--gray-800);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-800);
}

.modal-small {
    max-width: 350px;
}

/* Fix larghezza select nel modal admin inserimento */
#modal-admin-insert .modal-content {
    max-width: 450px;
}

#modal-admin-insert select,
#modal-admin-insert input,
#modal-admin-insert textarea {
    max-width: 100%;
    box-sizing: border-box;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

.form-actions .btn {
    flex: none;
    width: auto;
    min-width: 100px;
}

/* Time range inputs per ROL/Festività */
.time-range-inputs {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.time-input-wrapper {
    flex: 1;
}

.time-input-wrapper label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.time-input-wrapper input[type="time"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s;
}

.time-input-wrapper input[type="time"]:focus {
    outline: none;
    border-color: var(--primary);
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 6px;
}

.btn-block {
    display: block;
    width: 100%;
    margin-top: 20px;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #15803d;
}

.vacation-details {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.vacation-details p {
    margin: 6px 0;
    color: var(--gray-700);
    font-size: 14px;
}

.vacation-details strong {
    color: var(--gray-800);
}

/* Calendar weekday span styling */
.calendar-weekdays span {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    padding: 8px 4px;
}

/* Calendar container */
.calendar-container {
    margin-bottom: 20px;
}

/* Legend half dot */
.legend-dot.half {
    background: var(--gray-200);
    border-color: var(--gray-400);
    position: relative;
}

.legend-dot.half::after {
    content: '';
    position: absolute;
    bottom: 1px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 2px;
    background: var(--gray-500);
    border-radius: 1px;
}

/* Legend badge per AM/PM e orari */
.legend-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 3px;
    background: var(--gray-600);
    color: white;
}

.legend-badge.time {
    font-size: 8px;
    background: var(--primary);
}

/* ==================== RESPONSIVE CALENDAR ==================== */
@media (max-width: 768px) {
    .calendar-header {
        flex-direction: column;
        align-items: stretch;
    }

    .calendar-nav {
        justify-content: center;
    }

    .btn-new-request {
        width: 100%;
        justify-content: center;
    }

    .calendar-day {
        min-height: 36px;
        font-size: 12px;
    }

    .calendar-weekday {
        font-size: 10px;
        padding: 4px 2px;
    }

    .calendar-legend {
        justify-content: center;
    }

    .request-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .request-actions {
        width: 100%;
        justify-content: space-between;
    }

    .modal-request .form-row {
        grid-template-columns: 1fr;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        max-width: none;
    }

    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-row select {
        width: 100%;
    }

    .stat-badges {
        justify-content: center;
    }

    .admin-calendar-day {
        min-height: 60px;
        padding: 4px;
    }

    .admin-calendar-day .vacation-chip {
        font-size: 8px;
        padding: 1px 4px;
    }

    .vacation-table {
        font-size: 13px;
    }

    .vacation-table th,
    .vacation-table td {
        padding: 8px 12px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn-action {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .calendar-day {
        min-height: 32px;
        font-size: 11px;
        border-radius: 4px;
    }

    .calendar-month-label {
        font-size: 14px;
        min-width: 120px;
    }

    .admin-calendar-grid {
        display: none; /* Show list view instead on very small screens */
    }

    /* Nasconde il testo dei badge eventi su mobile, mostra solo colore */
    .calendar-day .person-badge {
        font-size: 0;
        padding: 0;
        width: 100%;
        height: 4px;
        border-radius: 2px;
        display: block;
        margin-top: 2px;
    }

    /* Mantiene bordo per pending */
    .calendar-day .person-badge.stato-pending {
        border-width: 1px;
        height: 4px;
    }

    /* Nasconde nome festività su mobile */
    .calendar-day .holiday-name {
        font-size: 0;
    }
    .calendar-day.holiday {
        background: #E1BEE7;
    }
}

/* ==================== EXPORT SECTION (employee_export) ==================== */
.export-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.export-section .section-header {
    margin-bottom: 20px;
}

.export-section .section-header h3 {
    font-size: 18px;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.export-section .section-header small {
    color: var(--gray-500);
    font-size: 13px;
}

.export-section .export-card {
    background: var(--gray-50);
    padding: 20px;
    border-radius: 8px;
}

/* ==================== BUSTE PAGA SECTION ==================== */
.payslips-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.payslips-section .section-header {
    margin-bottom: 20px;
}

.payslips-section .section-header h3 {
    font-size: 18px;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.payslips-section .section-header small {
    color: var(--gray-500);
    font-size: 13px;
}

.payslips-list {
    max-height: 400px;
    overflow-y: auto;
}

.payslips-list::-webkit-scrollbar {
    width: 6px;
}

.payslips-list::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 3px;
}

.payslips-list::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.payslips-list::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

.payslip-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.payslip-item:hover {
    background: var(--gray-50);
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.payslip-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.payslip-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.payslip-details {
    display: flex;
    flex-direction: column;
}

.payslip-name {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 14px;
}

.payslip-date {
    font-size: 12px;
    color: var(--gray-500);
}

.payslip-download {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.payslip-download:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.payslip-download:active {
    transform: translateY(0);
}

.payslips-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

.payslips-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.payslips-empty p {
    font-size: 14px;
}

/* Responsive */
@media (max-width: 600px) {
    .payslip-item {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .payslip-download {
        width: 100%;
        justify-content: center;
    }
}

/* ==================== SEZIONE DOCUMENTI ==================== */
.documents-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-top: 20px;
}

.documents-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.documents-section .section-header h3 {
    font-size: 18px;
    color: var(--gray-800);
    margin: 0;
}

.documents-list {
    max-height: 350px;
    overflow-y: auto;
}

.documents-list::-webkit-scrollbar {
    width: 6px;
}

.documents-list::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 3px;
}

.documents-list::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.document-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.document-item:hover {
    border-color: var(--primary);
    background: var(--gray-50);
}

.document-item.rejected {
    opacity: 0.6;
    background: var(--danger-light);
    border-color: var(--danger);
}

.document-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.document-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.document-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.document-name {
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.document-type-badge {
    background: var(--gray-200);
    color: var(--gray-700);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.status-badge.pending {
    background: var(--warning-light);
    color: var(--warning);
}

.status-badge.processed {
    background: var(--primary-light);
    color: var(--primary);
}

.status-badge.approved {
    background: var(--success-light);
    color: var(--success);
}

.status-badge.rejected {
    background: var(--danger-light);
    color: var(--danger);
}

.document-expiry {
    font-size: 11px;
    color: var(--gray-500);
}

.document-expiry.expiring {
    color: var(--warning);
    font-weight: 600;
}

.document-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.document-download,
.document-note {
    background: var(--primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.document-download:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.document-note {
    background: var(--gray-400);
}

.document-note:hover {
    background: var(--gray-500);
}

.documents-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

.documents-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.documents-empty p {
    font-size: 14px;
    margin-bottom: 8px;
}

/* Responsive documenti */
@media (max-width: 600px) {
    .document-item {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .document-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .document-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* ==================== TOGGLE SWITCH ==================== */
.filter-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-300);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px var(--primary-light);
}

.toggle-label {
    font-size: 14px;
    color: var(--gray-600);
    font-weight: 500;
}

@media (max-width: 768px) {
    .admin-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .filter-toggle {
        width: 100%;
    }
}

/* ==================== IMPERSONATION ==================== */
.impersonation-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

.impersonation-icon {
    font-size: 20px;
}

.impersonation-text {
    font-size: 14px;
    font-weight: 500;
}

.impersonation-text strong {
    font-weight: 700;
}

.btn-exit-impersonate {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    padding: 6px 16px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-exit-impersonate:hover {
    background: white;
    color: #d97706;
}

.btn-impersonate {
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-impersonate:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

/* Sposta la navbar quando c'è il banner */
body:has(.impersonation-banner) .navbar {
    margin-top: 48px;
}

body:has(.impersonation-banner) .login-container {
    padding-top: 60px;
}

@media (max-width: 768px) {
    .impersonation-banner {
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 8px;
    }

    .impersonation-text {
        font-size: 12px;
    }

    .btn-exit-impersonate {
        padding: 4px 12px;
        font-size: 12px;
    }
}

/* ==================== AGREEMENT PAGE ==================== */
.agreement-card {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    overflow: hidden;
}

.agreement-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 24px 30px;
    text-align: center;
}

.agreement-header h1 {
    font-size: 22px;
    margin-bottom: 6px;
}

.agreement-header p {
    opacity: 0.9;
    font-size: 14px;
}

.agreement-body {
    padding: 24px 30px;
}

.agreement-scroll-container {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 20px;
    background: var(--gray-50);
}

.agreement-text {
    padding: 20px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--gray-700);
    white-space: pre-wrap;
}

.agreement-checkbox-container {
    margin-bottom: 20px;
}

.agreement-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 15px;
    color: var(--gray-700);
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.agreement-checkbox-label:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.agreement-checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    accent-color: var(--primary);
    cursor: pointer;
}

.agreement-checkbox-label input[type="checkbox"]:checked + .checkmark + .checkbox-text {
    color: var(--primary);
    font-weight: 600;
}

.btn-accept-agreement {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
}

.btn-accept-agreement:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-accept-agreement:not(:disabled) {
    background: linear-gradient(135deg, var(--success) 0%, #15803d 100%);
}

.btn-accept-agreement:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.agreement-footer {
    text-align: center;
    margin-top: 16px;
    color: var(--gray-500);
}

.agreement-footer a {
    color: var(--primary);
    text-decoration: none;
}

.agreement-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 480px) {
    .agreement-card {
        border-radius: 0;
        max-width: 100%;
    }

    .agreement-scroll-container {
        max-height: 250px;
    }

    .agreement-header h1 {
        font-size: 18px;
    }
}

/* ==================== MODAL RICHIESTA FERIE - STILE MIGLIORATO ==================== */
#modal-request .modal-content {
    max-width: 420px;
    padding: 0;
    border-radius: 20px;
    overflow: hidden;
    text-align: left;
}

#modal-request .modal-header {
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    color: white;
    padding: 20px 24px;
    margin-bottom: 0;
}

#modal-request .modal-header h3 {
    color: white;
    font-size: 20px;
    margin: 0;
}

#modal-request .modal-close {
    color: rgba(255,255,255,0.8);
    font-size: 28px;
}

#modal-request .modal-close:hover {
    color: white;
}

#modal-request form {
    padding: 24px;
}

#modal-request .form-group {
    margin-bottom: 20px;
}

#modal-request .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#modal-request input[type="date"],
#modal-request select,
#modal-request textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.2s;
    background: var(--gray-50);
    box-sizing: border-box;
}

#modal-request input[type="date"]:focus,
#modal-request select:focus,
#modal-request textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

#modal-request .time-select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 16px;
    background: var(--gray-50);
    box-sizing: border-box;
}

#modal-request .time-select:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

#modal-request .time-range-inputs {
    display: flex;
    gap: 12px;
}

#modal-request .time-input-wrapper {
    flex: 1;
}

#modal-request .time-input-wrapper label {
    font-size: 11px;
    color: var(--gray-500);
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 6px;
}

#modal-request textarea {
    resize: none;
    min-height: 60px;
}

#modal-request .form-actions {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
}

#modal-request .btn-secondary {
    flex: 1;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
}

#modal-request .btn-primary {
    flex: 2;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#modal-request .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

#modal-request .alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
}

/* Responsive per mobile */
@media (max-width: 480px) {
    #modal-request .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    #modal-request .modal-header {
        padding: 16px 20px;
        flex-shrink: 0;
    }

    #modal-request form {
        padding: 20px;
        flex: 1;
        overflow-y: auto;
    }

    #modal-request .form-group label {
        font-size: 12px;
    }

    #modal-request input[type="date"],
    #modal-request select,
    #modal-request textarea,
    #modal-request .time-select {
        padding: 12px 14px;
        font-size: 16px; /* Previene zoom su iOS */
    }

    #modal-request .form-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }

    #modal-request .btn-secondary,
    #modal-request .btn-primary {
        flex: none;
        width: 100%;
    }
}

/* ==================== GDPR STYLES ==================== */

.row-anonymized {
    background: #fef2f2 !important;
    opacity: 0.7;
}

.row-anonymized td {
    color: #991b1b;
}

.badge-primary {
    background: #2563eb;
    color: white;
}

.badge-warning {
    background: #f59e0b;
    color: white;
}

.badge-success {
    background: #16a34a;
    color: white;
}

.badge-danger {
    background: #dc2626;
    color: white;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.text-muted {
    color: #94a3b8;
}

#tab-gdpr .admin-section-header h4 {
    margin-bottom: 12px;
    color: var(--gray-700);
    font-size: 16px;
}

#tab-gdpr code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* Modal GDPR export */
#modal-gdpr-export .modal-content,
#modal-gdpr-anonymize .modal-content {
    max-width: 500px;
}

#modal-gdpr-anonymize .modal-header {
    border-bottom: 2px solid #dc2626;
}

/* ==================== UPLOAD DOCUMENTO MODAL ==================== */
.modal-upload-doc {
    max-width: 480px;
}

.modal-upload-doc .modal-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 12px 12px 0 0;
    padding: 16px 20px;
}

.modal-upload-doc .modal-header h3 {
    color: white;
    font-size: 18px;
    font-weight: 600;
}

.modal-upload-doc .modal-close {
    color: white;
    opacity: 0.8;
}

.modal-upload-doc .modal-close:hover {
    opacity: 1;
}

.modal-upload-doc form {
    padding: 20px;
}

/* Dropzone area */
.upload-dropzone {
    border: 2px dashed var(--gray-300);
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--gray-50);
    position: relative;
    margin-bottom: 20px;
}

.upload-dropzone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-dropzone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.02);
}

.upload-dropzone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.dropzone-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dropzone-main {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-700);
}

.dropzone-sub {
    font-size: 13px;
    color: var(--gray-500);
}

.dropzone-hint {
    margin-top: 12px;
    font-size: 11px;
    color: var(--gray-400);
}

/* Selected file info */
.selected-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--success-light);
    border: 1px solid var(--success);
    border-radius: 8px;
    margin-bottom: 20px;
}

.selected-file .file-icon {
    font-size: 24px;
}

.selected-file .file-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.selected-file .file-name {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-file .file-size {
    font-size: 12px;
    color: var(--gray-500);
}

.selected-file .file-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.selected-file .file-remove:hover {
    transform: scale(1.1);
}

/* Form styling in upload modal */
.modal-upload-doc .form-group {
    margin-bottom: 16px;
}

.modal-upload-doc .form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.modal-upload-doc select,
.modal-upload-doc textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-upload-doc select:focus,
.modal-upload-doc textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.modal-upload-doc textarea {
    resize: vertical;
    min-height: 60px;
}

.modal-upload-doc .form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.modal-upload-doc .form-actions .btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
}

.modal-upload-doc .btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.modal-upload-doc .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

/* ==================== DEMO BANNER ==================== */
/* Tooltip demo ancorato al logo */
.demo-tooltip {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #1e40af 0%, #7c3aed 50%, #059669 100%);
    color: white;
    padding: 14px 36px 14px 16px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    width: 320px;
    max-width: 90vw;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    z-index: 10000;
    text-align: left;
    animation: tooltipFadeIn 0.4s ease;
}

.demo-tooltip.hidden {
    display: none;
}

.demo-tooltip-arrow {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 9px solid #7c3aed;
}

.demo-tooltip-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
}

.demo-tooltip-close:hover {
    color: white;
}

@keyframes tooltipFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Legacy - placeholder nascosto per compatibilità JS */
.demo-tooltip-placeholder {
    display: none;
}

/* Responsive tooltip demo */
@media (max-width: 400px) {
    .demo-tooltip {
        width: 280px;
        font-size: 12px;
        padding: 12px 32px 12px 12px;
    }
}

/* Card demo utenti */
.demo-users-grid { display: flex; flex-direction: column; gap: 6px; }
.demo-user-card {
    padding: 8px 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}
.demo-user-card:hover { background: #fef3c7; }

/* Bottoni con icona su mobile */
.btn-icon-mobile .label-icon { display: none; }
.btn-icon-mobile .label-full { display: inline; }

@media (max-width: 768px) {
    .btn-icon-mobile .label-icon { display: inline; }
    .btn-icon-mobile .label-full { display: none; }
    .btn-icon-mobile { padding: 4px 8px !important; min-width: auto !important; font-size: 16px !important; }
}

/* ===== Tooltip di aiuto per amministratori (admin-help.js) ===== */
.admin-help-tooltip {
    position: absolute;
    z-index: 10000;
    display: none;
    max-width: 360px;
    padding: 12px 14px;
    background: #1e293b;
    color: #f1f5f9;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35);
    font-size: 13px;
    line-height: 1.45;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.admin-help-tooltip.visible { opacity: 1; }
.admin-help-tooltip .admin-help-title {
    font-weight: 700;
    font-size: 13.5px;
    margin-bottom: 6px;
    color: #fbbf24;
}
.admin-help-tooltip p { margin: 0 0 6px 0; }
.admin-help-tooltip p:last-child { margin-bottom: 0; }
@media (max-width: 768px) {
    .admin-help-tooltip { max-width: calc(100vw - 32px); }
}
