:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #10B981;
    --dark: #0F172A;
    --light: #F8FAFC;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-md: 0.5rem;
    --radius-xl: 1.25rem;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-xl);
}

.loader-container {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; justify-content: center; align-items: center;
    background: rgba(255,255,255,0.8); z-index: 9999;
    transition: opacity 0.3s;
}
.loader-container.hidden { opacity: 0; pointer-events: none; }
.spinner {
    width: 40px; height: 40px;
    border: 4px solid rgba(79, 70, 229, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 1rem; }
.login-panel { width: 100%; max-width: 400px; padding: 3rem 2rem; text-align: center; animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.brand { margin-bottom: 2rem; }
.brand-icon { font-size: 3rem; color: var(--primary); margin-bottom: 1rem; }
.brand h2 { font-size: 1.5rem; font-weight: 700; color: var(--dark); }
.brand p { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.5rem; }

.input-group { position: relative; margin-bottom: 1.5rem; }
.input-group i { position: absolute; left: 1.2rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-group input { width: 100%; padding: 0.9rem 1rem 0.9rem 3rem; border: 1px solid rgba(0,0,0,0.1); border-radius: var(--radius-md); font-family: inherit; font-size: 1rem; background: rgba(255,255,255,0.9); transition: all 0.3s; }
.input-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.9rem 1.5rem; border: none; border-radius: var(--radius-md); font-family: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.3s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-block { width: 100%; }
.error-msg { color: #EF4444; font-size: 0.85rem; margin-bottom: 1rem; min-height: 1.2rem; }

.dashboard-layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 280px; margin: 1.5rem; display: flex; flex-direction: column; }
.brand-sm { padding: 2rem 1.5rem; font-size: 1.25rem; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 0.75rem; }
.sidebar-nav { flex: 1; padding: 0 1rem; display: flex; flex-direction: column; gap: 0.5rem; overflow-y: auto; }
.nav-item { padding: 0.8rem 1rem; text-decoration: none; color: var(--text-muted); font-weight: 500; border-radius: var(--radius-md); transition: all 0.2s; display: flex; align-items: center; gap: 1rem; }
.nav-item:hover, .nav-item.active { background: rgba(79, 70, 229, 0.1); color: var(--primary); }
.sidebar-footer { padding: 1.5rem; border-top: 1px solid rgba(0,0,0,0.05); display: flex; justify-content: space-between; align-items: center; }
.user-info { display: flex; align-items: center; gap: 0.75rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; }
.user-details { display: flex; flex-direction: column; }
.user-details .name { font-weight: 600; font-size: 0.9rem; color: var(--dark); }
.user-details .role { font-size: 0.75rem; color: var(--text-muted); }
.btn-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0.5rem; border-radius: 50%; transition: all 0.2s; font-size: 1.1rem; }
.btn-icon:hover { background: rgba(0,0,0,0.05); color: #EF4444; }

.main-content { flex: 1; display: flex; flex-direction: column; padding: 1.5rem 2rem 1.5rem 0; overflow: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.topbar h1 { font-size: 1.8rem; color: var(--dark); font-weight: 700; }
.content-area { flex: 1; overflow-y: auto; }

@media (max-width: 768px) {
    .dashboard-layout { flex-direction: column; }
    .sidebar { width: auto; margin: 0; border-radius: 0; border-bottom: 1px solid var(--glass-border); padding-bottom: 0; flex-direction: row; justify-content: space-between; align-items: center; }
    .sidebar-nav { display: none; }
    .sidebar-footer { border: none; padding: 1rem; }
    .brand-sm { padding: 1rem; }
    .main-content { padding: 1rem; }
}

/* --- Modali --- */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; z-index: 999; opacity: 1; transition: opacity 0.3s, visibility 0.3s; }
.modal-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.modal-container { width: 100%; max-width: 650px; padding: 1.5rem 2rem; background: rgba(255, 255, 255, 0.95); animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); max-height: 95vh; overflow-y: auto; }
@keyframes scaleUp { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 1rem; }
.modal-header h3 { font-size: 1.25rem; font-weight: 700; color: var(--dark); }

/* --- Form all'interno della modale --- */
.standard-form .input-group { margin-bottom: 1rem; }
.standard-form label { display: block; margin-bottom: 0.5rem; font-size: 0.9rem; font-weight: 500; color: var(--text-main); }
.standard-form input:not([type="time"]), .standard-form select { padding-left: 1rem !important; }
.standard-form .row { display: flex; gap: 1rem; }
.standard-form .col { flex: 1; }
@media (max-width: 600px) {
    .standard-form .row { flex-direction: column; gap: 0; }
    .modal-container { padding: 1rem; }
    #toast-container { left: 20px; right: 20px; bottom: 20px; }
    .toast { min-width: 0; width: 100%; }
}
.form-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid rgba(0,0,0,0.05); }
.custom-select { width: 100%; padding: 0.9rem 1rem; border: 1px solid rgba(0,0,0,0.1); border-radius: var(--radius-md); font-family: inherit; font-size: 1rem; background: rgba(255,255,255,0.9); }
.custom-select.multi { padding: 0.5rem; }

.btn-secondary { background: #E2E8F0; color: var(--text-main); }
.btn-secondary:hover { background: #CBD5E1; }

/* --- FullCalendar Overrides per adattarsi al tema Glassmorphism --- */
.fc-theme-standard .fc-scrollgrid { border-color: rgba(0,0,0,0.05) !important; }
.fc-theme-standard td, .fc-theme-standard th { border-color: rgba(0,0,0,0.05) !important; }
.fc .fc-col-header-cell-cushion { padding: 0.5rem; font-weight: 600; color: var(--text-main); }
.fc .fc-daygrid-day-number { font-weight: 500; color: var(--text-main); padding: 0.5rem; }
.fc .fc-button-primary { background-color: var(--primary) !important; border-color: var(--primary) !important; text-transform: capitalize; border-radius: var(--radius-md) !important; padding: 0.5rem 1rem !important; font-weight: 600 !important; }
.fc .fc-toolbar-title { font-size: 1.25rem !important; font-weight: 700; color: var(--dark); }
.fc .fc-button-primary:hover { background-color: var(--primary-hover) !important; }
.fc .fc-button-primary:disabled { background-color: var(--text-muted) !important; border-color: var(--text-muted) !important; opacity: 0.6; }
.fc .fc-day-today { background: rgba(79, 70, 229, 0.05) !important; }
.fc-event { border: none !important; border-radius: 4px; padding: 2px 4px; cursor: pointer; }

/* --- Responsive Tables --- */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive table { min-width: 600px; } /* Forza lo scroll orizzontale su mobile se sotto i 600px */

/* --- Toast Notifications --- */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: rgba(15, 23, 42, 0.9); color: white; padding: 1rem 1.5rem; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); backdrop-filter: blur(8px); display: flex; align-items: center; gap: 10px; font-weight: 500; animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1); min-width: 250px; }
.toast.success { border-left: 4px solid var(--secondary); }
.toast.error { border-left: 4px solid #EF4444; }
.toast.fade-out { animation: fadeOutRight 0.3s forwards; }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOutRight { to { transform: translateX(100%); opacity: 0; } }
