/* ============================================================
   EasyGym - Stylesheet Principale
   Design System: Variabili CSS + Dark/Light Mode
   ============================================================ */

/* --- Font Import --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   VARIABILI CSS - TEMA SCURO (default)
   ============================================================ */
:root,
[data-theme="dark"] {
    /* Colori base */
    --bg-primary:    #0f1117;
    --bg-secondary:  #171b26;
    --bg-tertiary:   #1e2435;
    --bg-card:       #1a1f2e;
    --bg-hover:      #252b3b;
    --bg-input:      #1e2435;

    /* Bordi */
    --border:        #2a3047;
    --border-light:  #333d55;

    /* Testo */
    --text-primary:  #e8eaf6;
    --text-secondary:#9aa0b5;
    --text-muted:    #5f6680;
    --text-inverse:  #0f1117;

    /* Accento principale (viola/indigo) */
    --accent:        #6366f1;
    --accent-hover:  #4f51cc;
    --accent-light:  rgba(99, 102, 241, 0.15);
    --accent-glow:   rgba(99, 102, 241, 0.3);

    /* Colori semantici */
    --success:       #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --warning:       #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --danger:        #ef4444;
    --danger-light:  rgba(239, 68, 68, 0.15);
    --info:          #3b82f6;
    --info-light:    rgba(59, 130, 246, 0.15);

    /* Sidebar */
    --sidebar-width:       260px;
    --sidebar-bg:          #13172080;
    --sidebar-border:      #2a3047;
    --sidebar-text:        #9aa0b5;
    --sidebar-text-active: #e8eaf6;
    --sidebar-active-bg:   rgba(99, 102, 241, 0.12);
    --sidebar-icon:        #6b7280;

    /* Navbar */
    --navbar-bg:     rgba(15, 17, 23, 0.85);
    --navbar-border: #2a3047;

    /* Shadow */
    --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg:   0 8px 32px rgba(0,0,0,0.5);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.3);

    /* Gradients */
    --gradient-accent: linear-gradient(135deg, #6366f1, #8b5cf6);
    --gradient-bg:     linear-gradient(135deg, #0f1117 0%, #13172a 100%);

    /* Scrollbar */
    --scrollbar-track: #171b26;
    --scrollbar-thumb: #2a3047;

    /* Transizione */
    --transition: 0.2s ease;
    --transition-slow: 0.35s ease;

    /* Border Radius */
    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  16px;
    --radius-xl:  24px;
    --radius-full: 9999px;
}

/* ============================================================
   VARIABILI CSS - TEMA CHIARO
   ============================================================ */
[data-theme="light"] {
    --bg-primary:    #f3f4f8;
    --bg-secondary:  #ffffff;
    --bg-tertiary:   #eef0f7;
    --bg-card:       #ffffff;
    --bg-hover:      #f0f1f8;
    --bg-input:      #f8f9fc;

    --border:        #e2e4ef;
    --border-light:  #ced1e0;

    --text-primary:  #1a1d2e;
    --text-secondary:#5a6380;
    --text-muted:    #9199b3;
    --text-inverse:  #ffffff;

    --accent:        #6366f1;
    --accent-hover:  #4f51cc;
    --accent-light:  rgba(99, 102, 241, 0.10);
    --accent-glow:   rgba(99, 102, 241, 0.2);

    --success:       #059669;
    --success-light: rgba(5, 150, 105, 0.10);
    --warning:       #d97706;
    --warning-light: rgba(217, 119, 6, 0.10);
    --danger:        #dc2626;
    --danger-light:  rgba(220, 38, 38, 0.10);
    --info:          #2563eb;
    --info-light:    rgba(37, 99, 235, 0.10);

    --sidebar-bg:          rgba(255,255,255,0.95);
    --sidebar-border:      #e2e4ef;
    --sidebar-text:        #5a6380;
    --sidebar-text-active: #1a1d2e;
    --sidebar-active-bg:   rgba(99, 102, 241, 0.08);
    --sidebar-icon:        #9199b3;

    --navbar-bg:     rgba(255,255,255,0.92);
    --navbar-border: #e2e4ef;

    --shadow-sm:   0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.10);
    --shadow-lg:   0 8px 32px rgba(0,0,0,0.12);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.06);

    --gradient-bg:     linear-gradient(135deg, #f3f4f8 0%, #eef0f7 100%);

    --scrollbar-track: #eef0f7;
    --scrollbar-thumb: #ced1e0;
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition-slow), color var(--transition-slow);
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar personalizzata */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ============================================================
   LAYOUT PRINCIPALE (sidebar + main)
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform var(--transition-slow), background var(--transition-slow);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    text-decoration: none;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.sidebar-logo-text {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.sidebar-logo-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: -2px;
    display: block;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-section {
    margin-bottom: 4px;
}

.sidebar-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 20px 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0;
    margin: 1px 10px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    position: relative;
}

.sidebar-link:hover {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--accent);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.sidebar-link:hover svg,
.sidebar-link.active svg {
    opacity: 1;
}

.sidebar-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--bg-hover);
    cursor: pointer;
    transition: background var(--transition);
    text-decoration: none;
}

.sidebar-user:hover { background: var(--border); }

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ============================================================
   CONTENUTO PRINCIPALE
   ============================================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* ============================================================
   NAVBAR TOP
   ============================================================ */
.navbar {
    height: 64px;
    background: var(--navbar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--navbar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background var(--transition-slow);
}

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

.navbar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { opacity: 0.4; }

.navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    position: relative;
}

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

.navbar-btn .notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--navbar-bg);
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
    flex: 1;
    padding: 28px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: background var(--transition-slow), border-color var(--transition-slow);
}

.card-header {
    padding: 20px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body { padding: 24px; }
.card-body-sm { padding: 16px; }

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Stat card */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: 0.05;
    background: currentColor;
    transform: translate(20px, -20px);
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.accent { background: var(--accent-light); color: var(--accent); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-light);  color: var(--danger); }
.stat-icon.info    { background: var(--info-light);    color: var(--info); }

.stat-content { flex: 1; min-width: 0; }

.stat-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -1px;
}

.stat-change {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   GRID
   ============================================================ */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    line-height: 1.4;
    font-family: inherit;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-sm  { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg  { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-icon-only {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition);
}
.btn-icon-only:hover { color: var(--text-primary); }

.btn-primary {
    background: var(--gradient-accent);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover {
    opacity: 0.9;
    box-shadow: 0 6px 20px var(--accent-glow);
    transform: translateY(-1px);
}

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

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}
.btn-success:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}
.btn-danger:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-warning {
    background: var(--warning);
    color: white;
}
.btn-warning:hover { opacity: 0.9; }

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}
.btn-outline:hover {
    background: var(--accent-light);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-loading { display: flex; align-items: center; gap: 8px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
    letter-spacing: 0.01em;
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    -webkit-appearance: none;
}

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

.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { opacity: 0.6; cursor: not-allowed; }

textarea.form-control { resize: vertical; min-height: 90px; }

select.form-control {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 36px;
}

.form-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 5px;
}

/* Input con icona */
.input-icon-wrap { position: relative; }

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.input-with-icon { padding-left: 38px; }
.input-with-icon-right { padding-right: 42px; }

.input-icon-right {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

/* Form Row */
.form-row {
    display: grid;
    gap: 16px;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ============================================================
   TABELLA
   ============================================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

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

.table tbody tr:hover td { background: var(--bg-hover); }

.table-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ============================================================
   BADGE
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.badge-success  { background: var(--success-light); color: var(--success); }
.badge-warning  { background: var(--warning-light); color: var(--warning); }
.badge-danger   { background: var(--danger-light);  color: var(--danger); }
.badge-info     { background: var(--info-light);    color: var(--info); }
.badge-accent   { background: var(--accent-light);  color: var(--accent); }
.badge-secondary{ background: var(--bg-hover);      color: var(--text-muted); }

/* ============================================================
   ALERT
   ============================================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 18px;
    position: relative;
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    color: inherit;
    opacity: 0.6;
    padding: 0 4px;
}
.alert-close:hover { opacity: 1; }

.alert-success { background: var(--success-light); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.3); }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.alert-info    { background: var(--info-light);    color: var(--info);    border: 1px solid rgba(59,130,246,0.3); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

.modal-lg { max-width: 760px; }
.modal-xl { max-width: 960px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 24px 0;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.2rem;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab-btn {
    padding: 10px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: inherit;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    background: var(--gradient-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    flex-shrink: 0;
}
.avatar-sm  { width: 32px; height: 32px; font-size: 0.8rem; }
.avatar-md  { width: 40px; height: 40px; font-size: 0.9rem; }
.avatar-lg  { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar-xl  { width: 80px; height: 80px; font-size: 1.5rem; }

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-input-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 9px 13px 9px 38px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.search-input::placeholder { color: var(--text-muted); }

/* ============================================================
   PAGINAZIONE
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    transition: all var(--transition);
    text-decoration: none;
}
.page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   SPINNER
   ============================================================ */
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state p { font-size: 0.85rem; }

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

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    max-width: 400px;
    animation: toastIn 0.3s ease;
}

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

.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info    { border-left: 4px solid var(--info); }

.toast-icon { flex-shrink: 0; }
.toast-msg  { font-size: 0.875rem; font-weight: 500; color: var(--text-primary); flex: 1; }

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

.theme-toggle-float {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all var(--transition);
}
.theme-toggle-float:hover { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-bg);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.login-body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -20%;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99,102,241,0.08) 0%, transparent 70%);
    pointer-events: none;
}

.login-body::after {
    content: '';
    position: fixed;
    bottom: -30%;
    right: -10%;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139,92,246,0.06) 0%, transparent 70%);
    pointer-events: none;
}

.login-container {
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--gradient-accent);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin: 0 auto 16px;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.login-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
}

.login-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

.login-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.login-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ============================================================
   DROPDOWN
   ============================================================ */
.dropdown { position: relative; }

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
    animation: dropIn 0.15s ease;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-item.danger:hover { background: var(--danger-light); color: var(--danger); }

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar-wrap {
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-accent);
    transition: width 0.5s ease;
}

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

.cal-day-name {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 8px 4px;
}

.cal-day {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
    position: relative;
}

.cal-day:hover { background: var(--bg-hover); color: var(--text-primary); }
.cal-day.today { color: var(--accent); font-weight: 700; }
.cal-day.today::after { content: ''; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.cal-day.has-event::before { content: ''; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--success); }
.cal-day.other-month { opacity: 0.3; }
.cal-day.selected { background: var(--accent); color: white; }

/* ============================================================
   UTILITY
   ============================================================ */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-accent    { color: var(--accent); }
.text-success   { color: var(--success); }
.text-warning   { color: var(--warning); }
.text-danger    { color: var(--danger); }

.text-sm   { font-size: 0.82rem; }
.text-xs   { font-size: 0.72rem; }
.text-lg   { font-size: 1.1rem; }
.text-xl   { font-size: 1.3rem; }

.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mt-4 { margin-top: 28px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.mb-4 { margin-bottom: 28px; }
.me-1 { margin-right: 6px; }
.me-2 { margin-right: 12px; }

.d-flex { display: flex; }
.d-grid { display: grid; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 20px; }
.gap-4 { gap: 28px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); width: 260px; }
    .main-content { margin-left: 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .navbar { padding: 0 16px; }
}
