/*
 * MyDreamLife — Design System
 * Brand: verde #3db33d · arancio #f5a020
 * v2.1 – Marzo 2026
 *
 * Font CDN nel <head>:
 *   <link href="https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
 *
 * Uso Django: {% load static %} <link rel="stylesheet" href="{% static 'css/theme.css' %}">
 */

/* ═══════════════════════════════════════════
   1. CSS VARIABLES
═══════════════════════════════════════════ */
:root {
  /* ── Brand verde — SOLO su elementi interattivi, non sugli sfondi ── */
  --gr:           #3db33d;   /* CTA primari, link attivi, paginazione, KPI positivi */
  --gr-hover:     #4dcb4d;
  --gr-dk:        #2e8a2e;   /* testo verde su sfondi chiari */
  --gr-dim:       rgba(61, 179, 61, 0.10);
  --gr-border:    rgba(61, 179, 61, 0.18);
  --gr-glow:      rgba(61, 179, 61, 0.14);

  /* ── Brand arancio (accent secondario ~2%) ── */
  --or:           #f5a020;   /* btn modifica, chip Privato/Direttore */
  --or-hover:     #ffb840;
  --or-dk:        #d4870a;
  --or-dim:       rgba(245, 160, 32, 0.12);
  --or-border:    rgba(245, 160, 32, 0.22);
  --or-glow:      rgba(245, 160, 32, 0.18);

  /* ── Semantici (separati dal brand) ── */
  --success:      #4ade80;   /* stato "Aperto" — verde CHIARO, non il verde brand */
  --success-bg:   rgba(74, 222, 128, 0.10);
  --success-bd:   rgba(74, 222, 128, 0.22);
  --warning:      #fb923c;
  --warning-bg:   rgba(251, 146, 60, 0.10);
  --warning-bd:   rgba(251, 146, 60, 0.22);
  --danger:       #f87171;
  --danger-bg:    rgba(248, 113, 113, 0.10);
  --danger-bd:    rgba(248, 113, 113, 0.22);
  --info:         #5b9aff;   /* tipo BASE, informazioni */
  --info-bg:      rgba(91, 154, 255, 0.12);
  --info-bd:      rgba(91, 154, 255, 0.25);

  /* ── Sfondi dark NEUTRI (slate/ardesia, zero tinta verde) ── */
  --bg:           #0f1117;   /* pagina — grigio-ardesia neutro */
  --bg2:          #161b27;   /* sidebar */
  --bg3:          #1e2535;   /* card, topbar */
  --bg4:          #252d3d;   /* input bg, hover card */
  --bg5:          #2d3748;   /* hover riga tabella */

  /* ── Testi dark NEUTRI ── */
  --tx1:          #e2e8f0;   /* slate chiaro neutro */
  --tx2:          #94a3b8;
  --tx3:          #64748b;
  --tx4:          #334155;

  /* ── Bordi dark ── */
  --line:         rgba(255, 255, 255, 0.06);
  --line2:        rgba(255, 255, 255, 0.10);

  /* ── Layout ── */
  --sidebar-w:    230px;
  --topbar-h:     74px;
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;

  /* ── Font ── */
  --font-ui:      'Sora', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;

  /* ── Alias compatibilità con v1 ── */
  --primary:        var(--gr);
  --primary-hover:  var(--gr-hover);
  --primary-glow:   var(--gr-dim);
  --accent:         var(--or);
  --accent-glow:    var(--or-dim);
  --border:         var(--line);
  --border-focus:   var(--gr);
  --text:           var(--tx1);
  --text-dim:       var(--tx2);
  --text-muted:     var(--tx3);
  --bg-card:        var(--bg3);
  --purple:         #a78bfa;
  --purple-bg:      rgba(167, 139, 250, 0.12);
}

/* ── Light theme ── */
[data-theme="light"],
[data-bs-theme="light"] {
  --gr:           #2e8a2e;
  --gr-hover:     #3db33d;
  --gr-dk:        #1e6b1e;
  --gr-dim:       rgba(46, 138, 46, 0.09);
  --gr-border:    rgba(46, 138, 46, 0.20);
  --gr-glow:      rgba(46, 138, 46, 0.12);

  --or:           #d4870a;
  --or-hover:     #f5a020;
  --or-dk:        #b06808;
  --or-dim:       rgba(212, 135, 10, 0.09);
  --or-border:    rgba(212, 135, 10, 0.20);
  --or-glow:      rgba(212, 135, 10, 0.12);

  --success:      #16a34a;
  --success-bg:   rgba(22, 163, 74, 0.09);
  --success-bd:   rgba(22, 163, 74, 0.22);
  --warning:      #d97706;
  --warning-bg:   rgba(217, 119, 6, 0.09);
  --warning-bd:   rgba(217, 119, 6, 0.22);
  --danger:       #dc2626;
  --danger-bg:    rgba(220, 38, 38, 0.09);
  --danger-bd:    rgba(220, 38, 38, 0.22);
  --info:         #003fa7;
  --info-bg:      rgba(0, 63, 167, 0.09);
  --info-bd:      rgba(0, 63, 167, 0.22);

  --bg:           #f1f5f9;   /* slate chiaro, nessuna tinta verde */
  --bg2:          #ffffff;
  --bg3:          #f8fafc;
  --bg4:          #f1f5f9;
  --bg5:          #e2e8f0;

  --tx1:          #0f172a;
  --tx2:          #475569;
  --tx3:          #94a3b8;
  --tx4:          #cbd5e1;

  --line:         rgba(0, 0, 0, 0.07);
  --line2:        rgba(0, 0, 0, 0.12);

  --primary:        var(--gr);
  --primary-hover:  var(--gr-hover);
  --primary-glow:   var(--gr-dim);
  --accent:         var(--or);
  --accent-glow:    var(--or-dim);
  --border:         var(--line);
  --border-focus:   var(--gr);
  --text:           var(--tx1);
  --text-dim:       var(--tx2);
  --text-muted:     var(--tx3);
  --bg-card:        var(--bg3);
}

/* ═══════════════════════════════════════════
   2. BASE RESET & BODY
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--tx1);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════
   3. LAYOUT – SIDEBAR + TOPBAR
═══════════════════════════════════════════ */
.mdh-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.mdh-sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--line2);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 200;
}

.mdh-sidebar-logo {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line2);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Immagine logo reale */
.mdh-logo-img {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 9px;
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mdh-logo-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Fallback mark senza immagine */
.mdh-logo-mark {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--gr), var(--or));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 10px var(--gr-glow);
}

/* My=arancio · Dream=bianco · Life=verde */
.mdh-logo-text { font-size: 14px; font-weight: 800; line-height: 1.2; letter-spacing: -0.2px; }
.mdh-logo-my     { color: var(--or); }
.mdh-logo-dream  { color: var(--tx1); }
.mdh-logo-life   { color: var(--gr); }

.mdh-logo-sub {
  font-size: 9px;
  color: var(--tx3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  display: block;
  margin-top: 2px;
}

.mdh-sidebar-section {
  padding: 14px 14px 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--tx4);
}

.mdh-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  margin: 1px 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--tx2);
  cursor: pointer;
  text-decoration: none;
  border-left: 2px solid transparent;
}

.mdh-nav-item:hover {
  background: var(--bg4);
  color: var(--tx1);
  text-decoration: none;
}

.mdh-nav-item.active {
  background: var(--gr-dim);
  color: var(--gr);
  font-weight: 700;
  border: 1px solid var(--gr-border);
  border-left: 2px solid var(--gr);
}

.mdh-nav-item i {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  color: var(--tx3);
}
.mdh-nav-item.active i { color: var(--gr); }

.mdh-nav-badge {
  margin-left: auto;
  font-size: 10px;
  background: var(--danger);
  color: #fff;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
  line-height: 1.4;
}

/* ── Topbar ── */
.mdh-topbar {
  height: var(--topbar-h);
  background: var(--bg3);
  border-bottom: 1px solid var(--line2);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  /* Accent line verde→arancio→trasparente */

}

.mdh-topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gr) 0%, var(--or) 50%, transparent 100%);
}

.mdh-topbar-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--tx1);
}

.mdh-topbar-meta { font-size: 11px; color: var(--tx3); }

.mdh-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Main content */
.mdh-content {
  flex: 1;
  padding: 10px 10px;
  background: var(--bg);
}

/* ═══════════════════════════════════════════
   4. PAGE HEADER
═══════════════════════════════════════════ */
.mdh-breadcrumb {
  font-size: 11px;
  color: var(--tx3);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.mdh-breadcrumb i { font-size: 9px; }

.mdh-page-title {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 2px;
  color: var(--tx1);
}

.mdh-page-sub { font-size: 13px; color: var(--tx3); margin: 0; }

/* ═══════════════════════════════════════════
   5. CARDS
═══════════════════════════════════════════ */
.mdh-card {
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-radius: var(--radius-lg);
}
.mdh-card:hover { border-color: var(--gr-border); }

.mdh-card-header {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mdh-card-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--tx1);
}

.mdh-card-body { padding: 16px; }

.mdh-card-footer {
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg4);
  border-radius: 0 0 var(--radius) var(--radius);
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Stat strip KPI ── */
.mdh-stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg3);
  margin-bottom: 20px;
}

.mdh-stat-cell {
  padding: 18px 20px;
  border-right: 1px solid var(--line2);
}
.mdh-stat-cell:last-child { border-right: none; }

.mdh-stat-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--tx3);
  margin-bottom: 8px;
}

.mdh-stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
  color: var(--tx1);
}
.mdh-stat-value.brand   { color: var(--gr); }
.mdh-stat-value.accent  { color: var(--or); }
.mdh-stat-value.danger  { color: var(--danger); }
.mdh-stat-value.success { color: var(--success); }

.mdh-stat-sub { font-size: 10px; color: var(--tx3); margin-top: 4px; }

/* Stat card singola */
.mdh-stat-card {
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.mdh-stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 12px;
}

/* ═══════════════════════════════════════════
   6. BUTTONS
═══════════════════════════════════════════ */
.mdh-btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

/* Verde — azione primaria */
.mdh-btn-primary {
  background: var(--gr);
  color: #fff;
  box-shadow: 0 2px 8px var(--gr-glow);
}
.mdh-btn-primary:hover {
  background: var(--gr-hover);
  color: #fff;
  box-shadow: 0 3px 14px var(--gr-glow);
}

/* Arancio — modifica, azione secondaria */
.mdh-btn-accent {
  background: var(--or-dim);
  color: var(--or);
  border: 1px solid var(--or-border);
}
.mdh-btn-accent:hover { background: rgba(245, 160, 32, 0.20); color: var(--or-hover); }

/* Ghost – outline arancione */
.mdh-btn-outline {
  background: transparent;
  color: var(--or);
  border: 1px solid rgba(232, 150, 10, 0.4);
}
.mdh-btn-outline:hover { background: var(--or-dim); color: var(--or); }

/* Outline verde */
.mdh-btn-outline-primary {
  background: transparent;
  color: var(--gr);
  border: 1px solid var(--gr-border);
}
.mdh-btn-outline-primary:hover { background: var(--gr-dim); color: var(--gr); }

/* Danger */
.mdh-btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-bd);
}
.mdh-btn-danger:hover { background: rgba(248, 113, 113, 0.20); }

/* Outline danger */
.mdh-btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.mdh-btn-outline-danger:hover { background: var(--or-dim); }

/* Outline success */
.mdh-btn-outline-success {
  background: transparent;
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.mdh-btn-outline-success:hover { background: var(--success-bg); }

/* Success */
.mdh-btn-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-bd);
}
.mdh-btn-success:hover { background: rgba(74, 222, 128, 0.20); }

.mdh-btn:disabled, .mdh-btn[disabled] {
  opacity: 0.45; pointer-events: none; cursor: default;
}

.mdh-btn-sm { font-size: 11px; padding: 4px 10px; }
.mdh-btn-lg { font-size: 15px; padding: 10px 22px; }

/* ═══════════════════════════════════════════
   7. FORM CONTROLS
═══════════════════════════════════════════ */
.mdh-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--tx3);
  margin-bottom: 5px;
  display: block;
}

.mdh-input,
.mdh-select,
.mdh-textarea {
  font-family: var(--font-ui);
  background: var(--bg4);
  border: 1px solid var(--line2);
  color: var(--tx1);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}
.mdh-input,
.mdh-select { height: 36px; }

/* Focus: verde brand */
.mdh-input:focus,
.mdh-select:focus,
.mdh-textarea:focus {
  outline: none;
  border-color: var(--gr);
  box-shadow: 0 0 0 3px var(--gr-dim);
}

.mdh-input::placeholder { color: var(--tx3); }

/* File input — ensure proper sizing */
input[type="file"].mdh-input {
  height: auto;
  min-height: 40px;
  padding: 6px 10px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.d-flex > input[type="file"].mdh-input {
  flex: 1;
  min-width: 0;
}
/* File input button — outline green */
input[type="file"]::file-selector-button {
  background: transparent;
  color: var(--gr);
  border: 1px solid rgba(76,175,80,0.4);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-right: 10px;
  transition: background .15s;
}
input[type="file"]::file-selector-button:hover {
  background: var(--gr-dim);
}

/* Auto-style Django widgets */
.mdh-content input[type="text"],
.mdh-content input[type="email"],
.mdh-content input[type="password"],
.mdh-content input[type="number"],
.mdh-content input[type="tel"],
.mdh-content input[type="url"],
.mdh-content input[type="date"],
.mdh-content input[type="time"],
.mdh-content input[type="datetime-local"],
.mdh-content input[type="search"],
.mdh-content select,
.mdh-content textarea {
  font-family: var(--font-ui);
  background: var(--bg4);
  border: 1px solid var(--line2);
  color: var(--tx1);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  width: 100%;
}
.mdh-content input:focus,
.mdh-content select:focus,
.mdh-content textarea:focus {
  outline: none;
  border-color: var(--gr);
  box-shadow: 0 0 0 3px var(--gr-dim);
  background: var(--bg3);
  color: var(--text);
}
.mdh-content input::placeholder,
.mdh-content textarea::placeholder { color: var(--tx3); }

/* Override Bootstrap form-control / form-select in dark */
.mdh-content .form-control,
.mdh-content .form-select {
  background-color: var(--bg4) !important;
  border-color: var(--line2) !important;
  color: var(--tx1) !important;
}
.mdh-content .form-control:focus,
.mdh-content .form-select:focus {
  background-color: var(--bg3) !important;
  border-color: var(--gr) !important;
  box-shadow: 0 0 0 3px var(--gr-dim) !important;
  color: var(--text) !important;
}
.form-check-label { color: var(--text) !important; }

/* Date input — dark icon & picker */
:root {
  color-scheme: dark;
}
[data-theme="light"],
[data-bs-theme="light"] {
  color-scheme: light;
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
}

.mdh-textarea { resize: vertical; min-height: 80px; }

.mdh-input-group { position: relative; }
.mdh-input-group .mdh-input { padding-left: 36px; }
.mdh-input-group .mdh-input-icon {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--tx3); font-size: 14px; pointer-events: none;
}

/* ═══════════════════════════════════════════
   8. TABLES
═══════════════════════════════════════════ */
.mdh-table-wrapper {
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.mdh-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.mdh-table thead { background: var(--bg4); }

.mdh-table th {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--tx3); padding: 10px 14px;
  border-bottom: 1px solid var(--line2);
  text-align: left; white-space: nowrap;
}

.mdh-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.mdh-table tr:last-child td { border-bottom: none; }
.mdh-table tbody tr:hover td { background: var(--bg5); }

/* Link nome: verde brand */
.mdh-table td a:not(.mdh-btn) {
  color: var(--text); font-weight: 700; text-decoration: none;
}
.mdh-table td a:not(.mdh-btn):hover { color: rgba(255, 245, 227, 0.842); text-decoration: underline; }
.bi-eye,
.bi-eye-fill { color: var(--accent) !important; }
.mdh-table .bi-pencil,
.mdh-table .bi-pencil-fill,
.mdh-table .bi-pencil-square { color: var(--text) !important; }

/* Riga highlight (corso attivo) */
.mdh-table tr.row-highlight td { background: var(--gr-dim); }
.mdh-table tr.row-highlight:hover td { background: rgba(61, 179, 61, 0.16); }

/* Stato corso */
.mdh-table tr.edizione-aperto td      { background: rgba(74, 222, 128, 0.14); }
.mdh-table tr.edizione-sospeso td     { background: rgba(251, 146, 60, 0.14); }
.mdh-table tr.edizione-completato td  { background: rgba(96, 165, 250, 0.14); }
.mdh-table tr.edizione-annullato td   { background: rgba(248, 113, 113, 0.14); }
.mdh-table tr.edizione-aperto:hover td     { background: rgba(74, 222, 128, 0.22); }
.mdh-table tr.edizione-sospeso:hover td    { background: rgba(251, 146, 60, 0.22); }
.mdh-table tr.edizione-completato:hover td { background: rgba(96, 165, 250, 0.22); }
.mdh-table tr.edizione-annullato:hover td  { background: rgba(248, 113, 113, 0.22); }

.mdh-table .td-mono {
  font-family: var(--font-mono); font-size: 11px; color: var(--tx2);
}

.mdh-table-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--line2);
  background: var(--bg4);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--tx3); gap: 10px; flex-wrap: wrap;
}

/* ═══════════════════════════════════════════
   9. BADGES / STATUS CHIPS
═══════════════════════════════════════════ */
.mdh-badge {
  font-size: 10px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px;
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap; line-height: 1.4;
}

/* Brand */
.mdh-badge-brand   { background: var(--gr-dim); color: var(--gr); border: 1px solid var(--gr-border); }
.mdh-badge-accent  { background: var(--or-dim); color: var(--or); border: 1px solid var(--or-border); }

/* Semantici */
.mdh-badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bd); }
.mdh-badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-bd); }
.mdh-badge-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-bd); }
.mdh-badge-info    { background: var(--info-bg);     color: var(--info);    border: 1px solid var(--info-bd); }
.mdh-badge-muted   { background: var(--bg5); color: var(--tx2); border: 1px solid var(--line2); }

/* Alias stati corso (pronti per template Django) */
.mdh-badge-aperto      { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bd); }
.mdh-badge-chiuso      { background: var(--bg5); color: var(--tx2); border: 1px solid var(--line2); }
.mdh-badge-sospeso     { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-bd); }
.mdh-badge-annullato   { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-bd); }
.mdh-badge-base        { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-bd); }
.mdh-badge-retraining  { background: var(--or-dim); color: var(--or); border: 1px solid var(--or-border); }
.mdh-badge-privato     { background: var(--or-dim); color: var(--or); border: 1px solid var(--or-border); }
.mdh-badge-direttore   { background: var(--or-dim); color: var(--or); border: 1px solid var(--or-border); }
.mdh-badge-sanitario   { background: var(--gr-dim); color: var(--gr); border: 1px solid var(--gr-border); }

/* Alias compatibilità v1 */
.mdh-badge-primary     { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-bd); }
.mdh-badge-purple      { background: var(--purple-bg); color: var(--purple); border: 1px solid rgba(167,139,250,0.25); }
.mdh-badge-danger-solid { background: var(--danger); color: #fff; }




/* ═══════════════════════════════════════════
   10. TOGGLE SWITCH
═══════════════════════════════════════════ */

/* --- Custom mdh-switch (non-Bootstrap) --- */
.mdh-switch {
  position: relative; display: inline-block;
  width: 38px; height: 22px; flex-shrink: 0;
}
.mdh-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.mdh-switch-track {
  position: absolute; inset: 0;
  background: transparent; border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 11px; cursor: pointer;
}
.mdh-switch-track::after {
  content: ''; position: absolute;
  width: 16px; height: 16px;
  background: var(--danger); border-radius: 50%;
  top: 2px; left: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: left 0.15s ease;
}
.mdh-switch input:checked + .mdh-switch-track {
  background: transparent; border-color: rgba(76, 175, 80, 0.4);
}
.mdh-switch input:checked + .mdh-switch-track::after {
  background: var(--gr); left: 18px;
}

/* --- Bootstrap form-switch: COMPLETO OVERRIDE --- */
/* Disabilitiamo TUTTE le transizioni di Bootstrap sugli switch.
   Bootstrap anima background-image durante il cambio stato, causando
   il doppio pallino. Usiamo solo transizione su background-position. */

/* Reset: rimuovi qualsiasi background/transizione Bootstrap */
.form-switch .form-check-input {
  all: unset !important;
  display: inline-block !important;
  width: 2em !important;
  height: 1em !important;
  vertical-align: middle !important;
  border-radius: 2em !important;
  cursor: pointer !important;
  pointer-events: auto !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  /* Stato OFF: pallino rosso a sinistra */
  background-color: transparent !important;
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23ef4444'/%3e%3c/svg%3e") !important;
  background-position: left center !important;
  transition: background-position 0.15s ease !important;
}

.form-switch .form-check-input:active,
.form-switch .form-check-input:focus {
  cursor: pointer !important;
}
.form-switch,
.form-switch label,
.form-switch .form-check-input + * {
  cursor: pointer !important;
}

/* Stato ON: pallino verde a destra */
.form-switch .form-check-input:checked {
  background-color: transparent !important;
  border-color: rgba(76, 175, 80, 0.4) !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%234CAF50'/%3e%3c/svg%3e") !important;
  background-position: right center !important;
}

/* Disabled */
.form-switch .form-check-input:disabled {
  cursor: default !important;
  pointer-events: none !important;
  opacity: 0.5 !important;
  border-color: rgba(255,255,255,0.12) !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23888'/%3e%3c/svg%3e") !important;
}
.form-switch .form-check-input:disabled:checked {
  background-position: right center !important;
}

/* Checkbox normali (non switch) */
.form-check-input[type="checkbox"] {
  background-color: var(--bg4); border-color: var(--line2);
}
.form-check-input[type="checkbox"]:checked {
  background-color: var(--gr); border-color: var(--gr);
}

/* ═══════════════════════════════════════════
   11. USER CHIP (topbar)
═══════════════════════════════════════════ */
.mdh-user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  background: var(--bg4); border-radius: var(--radius-sm);
  border: 1px solid var(--line2); cursor: default;
}

.mdh-user-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--gr), var(--or));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff; flex-shrink: 0;
  box-shadow: 0 2px 8px var(--gr-glow);
}

.mdh-user-info { text-align: right; line-height: 1.3; }
.mdh-user-org  { font-size: 11px; font-weight: 800; color: var(--gr); letter-spacing: 0.2px; }
.mdh-user-name { font-size: 11px; font-weight: 600; color: var(--tx1); }
.mdh-user-role { font-size: 10px; color: var(--tx3); }

/* ═══════════════════════════════════════════
   12. STICKY NOTES (dashboard)
═══════════════════════════════════════════ */
.mdh-note {
  border-radius: var(--radius); padding: 12px;
  font-size: 12px; border-left-width: 3px;
  border-left-style: solid; margin-bottom: 8px;
}
.mdh-note-header {
  display: flex; justify-content: space-between;
  margin-bottom: 5px; font-size: 10px; font-weight: 700; opacity: 0.8;
}
.mdh-note-brand  { background: var(--gr-dim);  border-color: var(--gr); }
.mdh-note-accent { background: var(--or-dim);  border-color: var(--or); }
.mdh-note-yellow { background: rgba(245,158,11,0.10); border-color: #f59e0b; }
.mdh-note-green  { background: rgba(74,222,128,0.10); border-color: var(--success); }
.mdh-note-blue   { background: rgba(96,165,250,0.10); border-color: var(--info); }
.mdh-note-red    { background: var(--danger-bg); border-color: var(--danger); }
.mdh-note-orange { background: rgba(249,115,22,0.10); border-color: #f97316; }
/* Alias v1 */
.mdh-note-purple { background: var(--purple-bg); border-color: var(--purple); }
.mdh-note-pink   { background: rgba(236,72,153,0.10); border-color: #ec4899; }

/* ═══════════════════════════════════════════
   13. PROGRESS BAR
═══════════════════════════════════════════ */
.mdh-progress {
  height: 4px; background: var(--bg5);
  border-radius: 2px; overflow: hidden; margin-top: 4px;
}
.mdh-progress-bar { height: 100%; border-radius: 2px; }
.mdh-progress-bar-primary { background: var(--gr); }
.mdh-progress-bar-accent  { background: var(--or); }
.mdh-progress-bar-success { background: var(--success); }
.mdh-progress-bar-warning { background: var(--warning); }
.mdh-progress-bar-danger  { background: var(--danger); }

/* ═══════════════════════════════════════════
   14. FILTER BAR
═══════════════════════════════════════════ */
.mdh-filter-bar {
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  padding: 13px 16px;
  display: flex; gap: 10px;
  align-items: flex-end; flex-wrap: wrap;
  margin-bottom: 16px;
}

.mdh-filter-group { display: flex; flex-direction: column; gap: 4px; }

.mdh-filter-label {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px; color: var(--tx3);
}

/* ═══════════════════════════════════════════
   15. PAGINATION
═══════════════════════════════════════════ */
.mdh-pagination {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.mdh-pagination-info { font-size: 12px; color: var(--tx3); }
.mdh-pagination-controls { display: flex; gap: 3px; }

.mdh-page-btn {
  font-family: var(--font-ui); font-size: 12px; font-weight: 600;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--gr-border);
  background: transparent; color: var(--gr);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.mdh-page-btn:hover { background: var(--gr-dim); }
.mdh-page-btn.active {
  background: var(--gr-dim); color: var(--gr);
  border-color: var(--gr); font-weight: 700;
}

/* ═══════════════════════════════════════════
   16. MODAL
═══════════════════════════════════════════ */
.mdh-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1050;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.mdh-modal {
  background: var(--bg3); border: 1px solid var(--line2);
  border-radius: var(--radius-lg); padding: 28px;
  width: 100%; max-width: 480px; position: relative;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}
.mdh-modal-title { font-size: 17px; font-weight: 800; margin-bottom: 4px; color: var(--tx1); }
.mdh-modal-sub   { font-size: 12px; color: var(--tx3); margin-bottom: 20px; }

/* ═══════════════════════════════════════════
   17. TOAST / ALERT
═══════════════════════════════════════════ */
.mdh-toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 13px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  z-index: 2000; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.mdh-toast-success { background: var(--success); color: #fff; }
.mdh-toast-danger  { background: var(--danger);  color: #fff; }
.mdh-toast-warning { background: var(--warning); color: #fff; }
.mdh-toast-brand   { background: var(--gr); color: #fff; box-shadow: 0 8px 24px var(--gr-glow); }

/* ═══════════════════════════════════════════
   18. OTP INPUT
═══════════════════════════════════════════ */
.mdh-otp-group {
  display: flex; gap: 8px; justify-content: center; margin: 20px 0;
}
.mdh-otp-digit {
  width: 50px; height: 58px;
  background: var(--bg4); border: 2px solid var(--line2);
  border-radius: var(--radius); text-align: center;
  font-size: 24px; font-weight: 800;
  font-family: var(--font-mono); color: var(--gr);
}
.mdh-otp-digit:focus {
  outline: none; border-color: var(--gr); background: var(--gr-dim);
}

/* ═══════════════════════════════════════════
   19. CALENDAR
═══════════════════════════════════════════ */
.mdh-cal-header {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; margin-bottom: 4px;
}
.mdh-cal-day-name {
  text-align: center; font-size: 10px; font-weight: 700;
  color: var(--tx3); padding: 5px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.mdh-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.mdh-cal-day {
  min-height: 74px; background: var(--bg4);
  border-radius: var(--radius-sm); padding: 7px;
  border: 1px solid var(--line);
}
.mdh-cal-day:hover  { border-color: var(--gr-border); }
.mdh-cal-day.today  { border-color: var(--gr); background: var(--gr-dim); }
.mdh-cal-day.other-month { opacity: 0.3; }
.mdh-cal-day-num    { font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.mdh-cal-event {
  font-size: 9px; font-weight: 600; padding: 2px 6px;
  border-radius: 3px; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}

/* ═══════════════════════════════════════════
   20. UTILITY CLASSES
═══════════════════════════════════════════ */
.text-brand    { color: var(--gr) !important; }
.text-accent   { color: var(--or) !important; }
.text-success  { color: var(--success) !important; }
.text-warning  { color: var(--warning) !important; }
.text-danger   { color: var(--danger) !important; }
.text-info     { color: var(--info) !important; }
.text-muted    { color: var(--tx3) !important; }
.text-dim      { color: var(--tx2) !important; }
.text-mono     { font-family: var(--font-mono); }
.text-primary  { color: var(--gr) !important; }  /* alias v1 */

.bg-brand-soft   { background: var(--gr-dim); }
.bg-accent-soft  { background: var(--or-dim); }
.bg-success-soft { background: var(--success-bg); }
.bg-warning-soft { background: var(--warning-bg); }
.bg-danger-soft  { background: var(--danger-bg); }
.bg-info-soft    { background: var(--info-bg); }
.bg-primary-soft { background: var(--gr-dim); }  /* alias v1 */
.bg-purple-soft  { background: var(--purple-bg); }

.icon-brand   { color: var(--gr); }
.icon-accent  { color: var(--or); }
.icon-success { color: var(--success); }
.icon-warning { color: var(--warning); }
.icon-danger  { color: var(--danger); }
.icon-info    { color: var(--info); }
.icon-muted   { color: var(--tx3); }
.icon-primary { color: var(--gr); }  /* alias v1 */
.icon-purple  { color: var(--purple); }

.mdh-divider { border: none; border-top: 1px solid var(--line2); margin: 16px 0; }

/* ═══════════════════════════════════════════
   21. SCROLLBAR
═══════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg5); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--tx3); }

/* ═══════════════════════════════════════════
   22. RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 768px) {
  .mdh-sidebar { display: none; }
  .mdh-sidebar.open {
    display: flex; position: fixed;
    inset: 0 auto 0 0; z-index: 300;
  }
  .mdh-content { padding: 16px; }
  .mdh-filter-bar { flex-direction: column; align-items: stretch; }
  .mdh-stat-strip { grid-template-columns: repeat(2, 1fr); }
}