
/* ========================================
   CSS VARIABLES
   ======================================== */
:root {
    /* Core Colors */
    --background: 0 0% 4.3%;
    --foreground: 0 0% 100%;
    
    /* Surface Colors */
    --card: 0 0% 7%;
    --card-foreground: 0 0% 100%;
    --popover: 0 0% 9%;
    --popover-foreground: 0 0% 100%;
    
    /* Primary - Red */
    --primary: 1 100% 44%;
    --primary-foreground: 0 0% 100%;
    
    /* Secondary - Dark Gray */
    --secondary: 0 0% 12%;
    --secondary-foreground: 0 0% 100%;
    
    /* Muted */
    --muted: 0 0% 15%;
    --muted-foreground: 0 0% 65%;
    
    /* Accent */
    --accent: 1 100% 44%;
    --accent-foreground: 0 0% 100%;
    
    /* Destructive */
    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 100%;
    
    /* Borders & Inputs */
    --border: 0 0% 18%;
    --input: 0 0% 15%;
    --ring: 1 100% 44%;
    --radius: 0.75rem;
    
    /* Sidebar */
    --sidebar-background: 0 0% 6%;
    --sidebar-foreground: 0 0% 85%;
    --sidebar-primary: 1 100% 44%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 0 0% 12%;
    --sidebar-accent-foreground: 0 0% 100%;
    --sidebar-border: 0 0% 15%;
    --sidebar-ring: 1 100% 44%;
    
    /* Status Colors */
    --status-active: 142 76% 36%;
    --status-expired: 0 84% 50%;
    --status-suspended: 43 96% 56%;
    --status-archived: 0 0% 45%;
    
    /* Urgency Colors */
    --urgency-critical: 0 84% 50%;
    --urgency-warning: 25 95% 53%;
    --urgency-caution: 43 96% 56%;
    --urgency-safe: 142 76% 36%;
    --urgency-info: 221 83% 53%; 
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.6), 0 4px 6px -4px rgb(0 0 0 / 0.5);
    --shadow-glow: 0 0 20px hsl(1 100% 44% / 0.3);
}

/* ========================================
   BASE STYLES
   ======================================== */
* {
    border-color: hsl(var(--border));
}

body {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: hsl(var(--background));
}

::-webkit-scrollbar-thumb {
    background: hsl(var(--muted));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--muted-foreground));
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 5px hsl(1 100% 44% / 0.3); }
    50% { box-shadow: 0 0 20px hsl(1 100% 44% / 0.5); }
}

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

.animate-fade-in { animation: fadeIn 0.3s ease-out; }
.animate-slide-up { animation: slideUp 0.4s ease-out; }
.animate-pulse-glow { animation: pulseGlow 2s ease-in-out infinite; }
.animate-spin { animation: spin 1s linear infinite; }

.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }

/* ========================================
   TEXT UTILITIES
   ======================================== */
.text-gradient {
    background: linear-gradient(135deg, hsl(0 0% 100%), hsl(1 100% 60%));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========================================
   CARD COMPONENTS
   ======================================== */
.card-elevated {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
}

.card-glow {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--primary) / 0.3);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-glow);
}

/* KPI Card */
.kpi-card {
    position: relative;
    overflow: hidden;
    border-radius: 0.75rem;
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    padding: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.kpi-card:hover {
    border-color: hsl(var(--primary) / 0.5);
    box-shadow: var(--shadow-glow);
}

.kpi-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: linear-gradient(135deg, hsl(0 0% 6%) 0%, hsl(1 100% 15% / 0.3) 100%);
}

.kpi-card:hover::before {
    opacity: 1;
}

/* KPI Card Variants */
.kpi-card-primary {
    border-color: hsl(var(--primary) / 0.3);
}

.kpi-card-primary:hover {
    border-color: hsl(var(--primary) / 0.6);
}

.kpi-card-warning {
    border-color: hsl(var(--status-suspended) / 0.3);
}

.kpi-card-warning:hover {
    border-color: hsl(var(--status-suspended) / 0.6);
}

.kpi-card-warning::before {
    background: linear-gradient(135deg, hsl(0 0% 6%) 0%, hsl(43 96% 25% / 0.3) 100%);
}

.kpi-card-danger {
    border-color: hsl(var(--status-expired) / 0.3);
}

.kpi-card-danger:hover {
    border-color: hsl(var(--status-expired) / 0.6);
}

.kpi-card-danger::before {
    background: linear-gradient(135deg, hsl(0 0% 6%) 0%, hsl(0 84% 25% / 0.3) 100%);
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 0.5rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    color: hsl(var(--sidebar-foreground));
}

.sidebar-link:hover {
    background-color: hsl(var(--sidebar-accent));
    color: hsl(var(--sidebar-accent-foreground));
}

.sidebar-link.active {
    background-color: hsl(var(--sidebar-primary));
    color: hsl(var(--sidebar-primary-foreground));
}

/* ========================================
   STATUS BADGES
   ======================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-active {
    background-color: hsl(var(--status-active) / 0.15);
    color: hsl(var(--status-active));
}

.status-expired {
    background-color: hsl(var(--status-expired) / 0.15);
    color: hsl(var(--status-expired));
}

.status-suspended {
    background-color: hsl(var(--urgency-info) / 0.15);
    color: hsl(var(--urgency-info));
}

.status-archived {
    background-color: hsl(var(--status-archived) / 0.15);
    color: hsl(var(--status-archived));
}

/* ========================================
   URGENCY BADGES
   ======================================== */
.urgency-critical {
    background-color: hsl(var(--urgency-critical) / 0.2);
    color: hsl(var(--urgency-critical));
    border: 1px solid hsl(var(--urgency-critical) / 0.3);
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.urgency-warning {
    background-color: hsl(var(--urgency-warning) / 0.15);
    color: hsl(var(--urgency-warning));
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.urgency-caution {
    background-color: hsl(var(--urgency-caution) / 0.15);
    color: hsl(var(--urgency-caution));
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.urgency-safe {
    background-color: hsl(var(--urgency-safe) / 0.15);
    color: hsl(var(--urgency-safe));
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.urgency-info {
    background-color: hsl(var(--urgency-info) / 0.15);
    color: hsl(var(--urgency-info));
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ========================================
   BUTTON COMPONENTS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px hsl(var(--ring));
}

.btn:disabled {
    pointer-events: none;
    opacity: 0.5;
}

.btn-primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    padding: 0.5rem 1rem;
    height: 2.5rem;
}

.btn-primary:hover:not(:disabled) {
    background-color: hsl(var(--primary) / 0.9);
}

.btn-outline {
    border: 1px solid hsl(var(--border));
    background-color: transparent;
    padding: 0.5rem 1rem;
    height: 2.5rem;
}

.btn-outline:hover:not(:disabled) {
    background-color: hsl(var(--muted));
}

.btn-ghost {
    background-color: transparent;
    padding: 0.5rem;
}

.btn-ghost:hover:not(:disabled) {
    background-color: hsl(var(--muted) / 0.5);
}

.btn-icon {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0.5rem;
}

/* ========================================
   SELECT DROPDOWN COMPONENTS
   ======================================== */

/* Custom Select Dropdown */
.custom-select {
    position: relative;
    display: inline-block;
}

.custom-select-trigger {
    display: flex;
    height: 2.5rem;
    width: 100%;
    align-items: center;
    border-radius: calc(var(--radius) - 2px);
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--background));
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 0.5rem;
}

.custom-select-trigger:hover {
    background-color: hsl(var(--muted) / 0.5);
}

.custom-select.open .custom-select-trigger {
    border-color: hsl(var(--ring));
}

.custom-select-content {
    position: absolute;
    z-index: 50;
    display: none;
    max-height: 24rem;
    min-width: 100%;
    overflow: auto;
    border-radius: calc(var(--radius) - 2px);
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--popover));
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.6), 0 4px 6px -4px rgb(0 0 0 / 0.5);
    margin-top: 0.25rem;
    padding: 0.25rem;
}

.custom-select-item {
    position: relative;
    display: flex;
    width: 100%;
    cursor: pointer;
    user-select: none;
    align-items: center;
    border-radius: calc(var(--radius) - 2px);
    padding: 0.625rem 0.75rem 0.625rem 2.5rem;
    font-size: 0.875rem;
    outline: none;
    transition: all 0.15s ease;
    color: hsl(var(--foreground));
}

.custom-select-item:hover {
    background-color: hsl(var(--muted) / 0.5);
}

.custom-select-item.selected {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    font-weight: 500;
}

.custom-select-item::before {
    content: '✓';
    position: absolute;
    left: 0.75rem;
    width: 1rem;
    height: 1rem;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.custom-select-item.selected::before {
    display: flex;
}

/* Native select styling (fallback) */
select.select-native {
    appearance: none;
    display: flex;
    height: 2.5rem;
    width: 100%;
    align-items: center;
    border-radius: 0.375rem;
    border: 1px solid hsl(var(--input));
    background-color: hsl(var(--background));
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

select.select-native:focus {
    outline: none;
    ring: 2px solid hsl(var(--ring));
    ring-offset: 2px;
}

select.select-native option {
    background-color: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    padding: 0.375rem 2rem 0.375rem 2rem;
}

select.select-native option:checked {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

/* ========================================
   FORM COMPONENTS
   ======================================== */
.input-field {
    display: flex;
    width: 100%;
    border-radius: 0.375rem;
    border: 1px solid hsl(var(--input));
    background-color: hsl(var(--muted) / 0.5);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    color: hsl(var(--foreground));
    height: 3rem;
}

.input-field::placeholder {
    color: hsl(var(--muted-foreground));
}

.input-field:focus {
    outline: none;
    background-color: hsl(var(--muted));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.label {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    margin-bottom: 0.5rem;
    display: block;
}

.select-field {
    border-radius: 0.375rem;
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--muted) / 0.5);
    padding: 0.5rem 0.75rem;
    color: hsl(var(--foreground));
    font-size: 0.875rem;
    height: 2.5rem;
}

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

/* ========================================
   TABLE COMPONENTS
   ======================================== */
.table-row-hover {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.table-row-hover:hover {
    background-color: hsl(var(--muted) / 0.3);
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    position: fixed;
    inset-y: 0;
    left: 0;
    z-index: 50;
    width: 16rem;
    display: flex;
    flex-direction: column;
    border-right: 1px solid hsl(var(--sidebar-border));
    background-color: hsl(var(--sidebar-background));
    transition: transform 0.3s ease;
}

@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        animation: slideInLeft 0.3s ease;
    }
}

@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
    }
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    color: hsl(var(--sidebar-foreground));
}

.nav-link:hover {
    background-color: hsl(var(--sidebar-accent));
    color: hsl(var(--foreground));
    transform: translateX(4px);
}

.nav-link.active {
    background-color: hsl(var(--sidebar-primary));
    color: hsl(var(--primary-foreground));
}

/* ========================================
   MOBILE NAV
   ======================================== */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    height: 4rem;
    background-color: hsl(var(--sidebar-background));
    border-top: 1px solid hsl(var(--sidebar-border));
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 1rem;
}

@media (min-width: 1024px) {
    .mobile-nav {
        display: none;
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    color: hsl(var(--sidebar-foreground));
    font-size: 0.75rem;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
    background-color: hsl(var(--sidebar-accent));
    color: hsl(var(--foreground));
}

.mobile-nav-item.active {
    color: hsl(var(--primary));
}

/* ========================================
   OVERLAY
   ======================================== */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ========================================
   MODAL
   ======================================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: hsl(var(--card));
    border-radius: 0.75rem;
    padding: 1.5rem;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

/* ========================================
   SWITCH
   ======================================== */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: hsl(var(--muted));
    border-radius: 34px;
    transition: 0.3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

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

input:checked + .slider:before {
    transform: translateX(20px);
}

/* X ROSSA nella searchbar */
input[type="search"]::-webkit-search-cancel-button {
    filter: brightness(0) saturate(100%) invert(11%) sepia(97%) saturate(7426%) hue-rotate(3deg) brightness(98%) contrast(118%);
    cursor: pointer;
}

/* ==============================================
   TOGGLE SWITCH (per Discipline)
   ============================================== */
   .toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background-color: hsl(var(--muted));
    border-radius: 34px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.toggle-switch.active {
    background-color: hsl(var(--primary));
}

.toggle-slider {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;  /* ← PALLINO DISATTIVO - CAMBIA QUI */
    border-radius: 50%;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.toggle-switch.active .toggle-slider {
    transform: translateX(20px);
    background-color: black;  /* ← PALLINO ATTIVO - CAMBIA QUI */
}

.toggle-switch:hover {
    opacity: 0.9;
}

/* ==============================================
   CUSTOM RADIO BUTTONS (per Discipline Form)
   ============================================== */
   .discipline-radio {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 2px solid hsl(var(--primary));
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.discipline-radio:hover {
    background-color: hsl(var(--primary) / 0.1);
}

.discipline-radio-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: transparent;
    transition: background-color 0.2s ease;
}

.discipline-radio.checked .discipline-radio-dot {
    background-color: hsl(var(--primary));
}

/* =========================
   LOGIN CHECKBOX (ROSSA) + NO BLU DEFAULT
   ========================= */

/* togli highlight blu/outline di default */
input[type="checkbox"]{
    outline: none !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* stile checkbox custom */
  input[type="checkbox"].checkbox-red {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid rgba(255,255,255,0.25);
    background: transparent;
    display: inline-grid;
    place-content: center;
    cursor: pointer;
    transition: all .15s ease;
  }
  
  /* checked = rosso pieno */
  input[type="checkbox"].checkbox-red:checked {
    background: #e00400;          /* rosso */
    border-color: #e00400;
  }
  
  /* spunta bianca */
  input[type="checkbox"].checkbox-red:checked::after {
    content: "✓";
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    line-height: 1;
  }
  
  /* focus: niente ring blu */
  input[type="checkbox"].checkbox-red:focus,
  input[type="checkbox"].checkbox-red:focus-visible {
    outline: none !important;
    box-shadow: none !important;
  }
  
  /* hover leggero */
  input[type="checkbox"].checkbox-red:hover {
    border-color: rgba(255,255,255,0.4);
  }
  