/* ── AIManage — Design System ───────────────────────────────────────────── */
:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #818cf8;
  --secondary: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #6366f1;

  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #273349;
  --bg-input: #1e293b;
  --sidebar-bg: #0d1526;
  --sidebar-w: 240px;

  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-heading: #f1f5f9;
  --border: #2d3f5c;
  --border-light: #334155;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
  --row-hover: rgba(255, 255, 255, .02);
  --track-bg: rgba(255, 255, 255, .08);

  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* ── TEMA CHIARO ────────────────────────────────────────────────────────── */
html[data-theme="light"] {
  --primary-light: #4f46e5;

  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --sidebar-bg: #ffffff;

  --text: #334155;
  --text-muted: #64748b;
  --text-heading: #0f172a;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --shadow: 0 4px 24px rgba(15, 23, 42, .08);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, .06);
  --row-hover: rgba(15, 23, 42, .035);
  --track-bg: rgba(15, 23, 42, .08);
}

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

html {
  font-size: 15px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── SCROLLBAR ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── APP SHELL ──────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  font-size: 26px;
}

.logo-text {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-heading);
  line-height: 1.2;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  padding: 12px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text);
}

.nav-item.active {
  background: rgba(79, 70, 229, .2);
  color: var(--primary-light);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-logout {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: color .15s, background .15s;
}

.btn-logout:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, .1);
}

.btn-theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: color .15s, background .15s;
}

.btn-theme-toggle:hover {
  color: var(--primary-light);
  background: rgba(79, 70, 229, .1);
}

/* ── MAIN CONTENT ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 61px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-heading);
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* ── CARDS ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

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

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-heading);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── STAT CARDS ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .2s;
}

.stat-card:hover {
  border-color: var(--primary);
}

.stat-icon {
  font-size: 22px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-heading);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.stato-moduli-recap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stato-moduli-recap div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.stato-moduli-recap b {
  color: var(--text-heading);
  font-weight: 800;
}

/* ── GRID ───────────────────────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.grid-6 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

@media(max-width:1200px) {
  .grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media(max-width:800px) {
  .grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}

.btn:hover {
  opacity: .88;
  transform: translateY(-1px);
}

.btn:active {
  transform: none;
}

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

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

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

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

.btn-warning {
  background: var(--warning);
  color: #000;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

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

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}

.btn-lg {
  padding: 11px 22px;
  font-size: 15px;
}

.w-full {
  width: 100%;
}

/* ── FORMS ──────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .25);
}

.form-control::placeholder {
  color: var(--text-muted);
}

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

select.form-control {
  cursor: pointer;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* ── TABLES ─────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--sidebar-bg);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(45, 63, 92, .5);
  vertical-align: middle;
  color: var(--text);
}

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

tbody tr:hover td {
  background: var(--row-hover);
}

/* ── BADGES ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success {
  background: rgba(16, 185, 129, .2);
  color: #34d399;
}

.badge-danger {
  background: rgba(239, 68, 68, .2);
  color: #f87171;
}

.badge-warning {
  background: rgba(245, 158, 11, .2);
  color: #fbbf24;
}

.badge-info {
  background: rgba(99, 102, 241, .2);
  color: #a5b4fc;
}

.badge-muted {
  background: rgba(148, 163, 184, .15);
  color: var(--text-muted);
}

.badge-primary {
  background: rgba(79, 70, 229, .2);
  color: var(--primary-light);
}

/* ── ALERTS ─────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-success {
  background: rgba(16, 185, 129, .1);
  border-color: rgba(16, 185, 129, .3);
  color: #34d399;
}

.alert-danger {
  background: rgba(239, 68, 68, .1);
  border-color: rgba(239, 68, 68, .3);
  color: #f87171;
}

.alert-warning {
  background: rgba(245, 158, 11, .1);
  border-color: rgba(245, 158, 11, .3);
  color: #fbbf24;
}

.alert-info {
  background: rgba(99, 102, 241, .1);
  border-color: rgba(99, 102, 241, .3);
  color: #a5b4fc;
}

/* ── TOASTS ─────────────────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 320px;
  max-width: calc(100vw - 40px);
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--toast-accent, var(--success));
  border-radius: 8px;
  padding: 11px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .25s, transform .25s;
}

.toast.show { opacity: 1; transform: translateY(0); }

.toast-success { --toast-accent: var(--success); }
.toast-error   { --toast-accent: var(--danger); }
.toast-warning { --toast-accent: var(--warning); }

.toast-body { display: flex; align-items: flex-start; gap: 9px; }
.toast-icon { font-size: 16px; margin-top: 1px; color: var(--toast-accent, var(--success)); }
.toast-title { color: var(--text-heading); font-size: 12.5px; font-weight: 700; }
.toast-message { color: var(--text-muted); font-size: 11.5px; margin-top: 2px; }

.toast-bar-track {
  height: 2.5px;
  background: var(--track-bg);
  border-radius: 2px;
  margin-top: 9px;
  overflow: hidden;
}

.toast-bar {
  height: 100%;
  width: 100%;
  background: var(--toast-accent, var(--success));
  transform-origin: left;
  transition: transform linear;
}

/* ── CONFIRM MODAL ──────────────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  opacity: 0;
  transition: opacity .15s;
}

.confirm-overlay.show { opacity: 1; }

.confirm-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 320px;
  max-width: calc(100vw - 40px);
  text-align: center;
  transform: scale(.96);
  transition: transform .15s;
}

.confirm-overlay.show .confirm-modal { transform: scale(1); }

.confirm-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-size: 20px;
  background: rgba(239, 68, 68, .12);
  color: var(--danger);
}

.confirm-icon.info { background: rgba(79, 70, 229, .12); color: var(--primary-light); }

.confirm-title { color: var(--text-heading); font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.confirm-message { color: var(--text-muted); font-size: 12.5px; line-height: 1.5; margin-bottom: 18px; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions .btn { flex: 1; }

/* ── CALENDAR ───────────────────────────────────────────────────────────── */
.fc {
  --fc-border-color: var(--border);
  --fc-today-bg-color: rgba(79, 70, 229, .08);
  /* Separatore tra eventi contemporanei affiancati: di default è bianco puro
     (pensato per temi chiari) e risulta troppo invasivo sul tema scuro. */
  --fc-page-bg-color: var(--bg);
}

.fc .fc-toolbar-title {
  font-size: 15px !important;
  font-weight: 700;
  color: var(--text-heading);
}

.fc .fc-button {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-size: 12px !important;
  padding: 4px 10px !important;
  border-radius: 6px !important;
  box-shadow: none !important;
}

.fc .fc-button:hover {
  background: var(--bg-card-hover) !important;
}

.fc .fc-button-active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}

.fc .fc-col-header-cell {
  background: var(--sidebar-bg);
  padding: 6px 0;
}

.fc .fc-col-header-cell-cushion {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  text-decoration: none;
}

.fc-event {
  border-radius: 6px !important;
  border: none !important;
  font-size: 11px !important;
  padding: 3px 5px !important;
  cursor: pointer;
}

.fc-event .fc-event-main-frame {
  flex-direction: column !important;
  gap: 2px;
  white-space: normal;
  align-items: flex-start;
}

.fc-event .fc-event-time {
  display: inline-block !important;
  background: rgba(0,0,0,0.22);
  border-radius: 3px;
  font-size: 9.5px !important;
  font-weight: 600;
  padding: 0 4px;
  line-height: 1.6;
  white-space: nowrap;
  flex-shrink: 0;
}

.fc-event .fc-event-title-container {
  width: 100%;
}

.fc-event .fc-event-title,
.fc-event .fc-event-title.fc-sticky {
  white-space: normal !important;
  overflow: visible !important;
  word-break: break-word;
  line-height: 1.3;
  position: static !important;
  font-weight: 700 !important;
  font-size: 11.5px !important;
  text-align: center;
  display: block;
  width: 100%;
}

.fc-event:hover {
  filter: brightness(1.1);
}

.fc .fc-daygrid-day-number {
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: none;
}

.fc .fc-day-today .fc-daygrid-day-number {
  color: var(--primary-light);
  font-weight: 700;
}

.fc .fc-timegrid-slot {
  height: 40px !important;
}

/* ── LIST VIEW CONTRAST OVERRIDES ───────────────────────────────────────── */
.fc-list-day-cushion,
.fc-list-day-side-text {
  background-color: var(--sidebar-bg) !important;
  color: var(--text-heading) !important;
}

.fc-list-event {
  background-color: transparent !important;
}

.fc-list-event:hover td {
  background-color: var(--bg-card-hover) !important;
}

.fc-list-event td {
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.fc-list-event-title a {
  color: var(--text-heading) !important;
}

.fc-list-event-time {
  color: var(--text-muted) !important;
}

.fc-list-empty {
  background-color: var(--bg-card) !important;
  color: var(--text-muted) !important;
}

/* ── MINI CALENDAR CLASSE ───────────────────────────────────────────────── */
.classe-cal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.classe-cal-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.classe-cal-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-heading);
}

.classe-cal-corso {
  font-size: 11px;
  color: var(--text-muted);
}

.classe-cal-body {
  height: 320px;
  padding: 8px;
}

/* ── MODAL ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from {
    transform: scale(.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-heading);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
}

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

.modal-body {
  padding: 20px;
}

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

/* ── PAGINATION ─────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 20px;
}

.pagination .page-item .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pagination .page-item .page-link:hover:not(.active) {
  background: var(--bg-card-hover);
  color: var(--text);
}

.pagination .page-item.disabled .page-link {
  opacity: .4;
  pointer-events: none;
}

/* ── UTILITY ────────────────────────────────────────────────────────────── */
.text-sm {
  font-size: 12px;
}

.text-muted {
  color: var(--text-muted);
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.mt-1 {
  margin-top: 6px;
}

.mt-2 {
  margin-top: 12px;
}

.mt-3 {
  margin-top: 20px;
}

.mt-4 {
  margin-top: 28px;
}

.mb-1 {
  margin-bottom: 6px;
}

.mb-2 {
  margin-bottom: 12px;
}

.mb-3 {
  margin-bottom: 20px;
}

.flex {
  display: flex;
}

.flex-1 {
  flex: 1;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.font-bold {
  font-weight: 700;
}

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

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

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

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

/* ── AUTH LAYOUT ────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse 80% 70% at 50% -20%, rgba(79, 70, 229, .2), transparent),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
}

.auth-logo .logo-text {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-heading);
}

.auth-logo .logo-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.auth-card h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 4px;
}

.auth-card .sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ── DISPONIBILITA CALENDAR ──────────────────────────────────────────────── */
.disp-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 12px;
}

.disp-day {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  transition: all .15s;
  user-select: none;
}

.disp-day.empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
}

.disp-day.weekend {
  color: var(--text-muted);
}

.disp-day.available {
  background: rgba(16, 185, 129, .2);
  border-color: #10b981;
  color: #34d399;
}

.disp-day.unavailable {
  background: rgba(239, 68, 68, .15);
  border-color: #ef4444;
  color: #f87171;
}

.disp-day:not(.empty):hover {
  border-color: var(--primary-light);
  transform: scale(1.08);
}

.disp-legend {
  display: flex;
  gap: 16px;
  margin-top: 10px;
}

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

.disp-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* ── FEEDBACK ────────────────────────────────────────────────────────────── */
.feedback-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feedback-msg {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.6;
}

.feedback-msg.from-docente {
  background: var(--bg);
  border: 1px solid var(--border);
}

.feedback-msg.from-tutor {
  background: rgba(79, 70, 229, .1);
  border: 1px solid rgba(79, 70, 229, .3);
}

.feedback-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* ── EVENT POPUP ─────────────────────────────────────────────────────────── */
.event-popup {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 240px;
  max-width: 320px;
  box-shadow: var(--shadow);
  z-index: 300;
  font-size: 13px;
}

.event-popup-title {
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 8px;
  font-size: 14px;
}

.event-popup-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.event-popup-row span:first-child {
  min-width: 16px;
}

.event-popup-actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

/* ── SEARCH BAR ──────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.search-bar .form-control {
  max-width: 280px;
}

/* ── EMPTY STATE ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

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

/* ── MOBILE (≤640px) ────────────────────────────────────────────────────── */
.mobile-topbar, .mobile-bottombar, .mobile-drawer-scrim, .mobile-drawer, .mobile-avatar-menu, .fab-nuova-lezione {
  display: none;
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .topbar { display: none; }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; padding-top: 72px; overflow-x: hidden; }
  .page-content.has-mobile-bottombar { padding-bottom: 84px; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 12px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 200;
  }

  .mobile-topbar-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--text);
    padding: 6px;
    flex-shrink: 0;
  }

  .mobile-topbar-logo {
    flex: 1;
    display: flex;
    justify-content: center;
    background: #fff;
    border-radius: 6px;
    padding: 4px 10px;
    align-self: stretch;
    align-items: center;
  }

  .mobile-topbar-logo img {
    height: 26px;
    width: auto;
    display: block;
  }

  .mobile-avatar-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
  }

  .mobile-avatar-wrap { position: relative; }

  .mobile-avatar-menu.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 42px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 6px;
    min-width: 170px;
    z-index: 250;
  }

  .mobile-avatar-menu button {
    display: flex;
    align-items: center;
    gap: 9px;
    background: none;
    border: none;
    text-align: left;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
  }

  .mobile-avatar-menu button:hover {
    background: var(--bg);
  }

  .mobile-drawer-scrim.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 290;
  }

  .mobile-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -260px;
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    z-index: 300;
    display: flex;
    flex-direction: column;
    transition: left .2s ease;
  }

  .mobile-drawer.open {
    left: 0;
  }

  .mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }

  .mobile-drawer-nav {
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .mobile-bottombar {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: 68px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
  }

  .mobile-bottombar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 500;
  }

  .mobile-bottombar-item i {
    font-size: 19px;
  }

  .mobile-bottombar-item.active {
    color: var(--primary-light);
  }

  .fab-nuova-lezione {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 18px;
    bottom: 84px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 22px;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(79, 70, 229, .4);
    z-index: 150;
  }

  .mobile-scroll-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .mobile-scroll-row::-webkit-scrollbar { display: none; }

  .mobile-scroll-row > * { flex-shrink: 0; }

  .mobile-accordion-toggle {
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .mobile-accordion-toggle .mobile-accordion-chevron {
    transition: transform .2s ease;
  }

  .mobile-accordion-toggle.collapsed .mobile-accordion-chevron {
    transform: rotate(-90deg);
  }

  .mobile-accordion-body.collapsed {
    display: none;
  }

  #moduli-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .desktop-cal-control {
    display: none !important;
  }

  #cal-body-wrap, #cal-docente-wrap {
    height: 440px !important;
    padding: 6px !important;
  }

  .card {
    padding: 14px;
  }

  .disp-month-grid {
    gap: 3px;
  }

  .disp-day {
    font-size: 11px;
  }

  .pannello-mobile-block {
    display: flex;
  }

  .pannello-desktop-only {
    display: none !important;
  }

  .moduli-layout-grid {
    grid-template-columns: 1fr !important;
  }

  #corso-form-card, #form-card {
    display: none;
  }

  #corso-form-card.mobile-form-open, #form-card.mobile-form-open {
    display: block;
  }

  .corso-card-row {
    flex-wrap: wrap;
  }

  .corso-card-info {
    flex-basis: 100%;
  }

  .corso-card-actions {
    flex-basis: 100%;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  .corso-meta-dot {
    display: none;
  }

  .corso-meta-desc {
    display: block;
    margin-top: 2px;
  }

  /* Tabelle -> lista di card verticali, stesso markup, nessuna duplicazione */
  table.data-table thead {
    display: none;
  }

  table.data-table, table.data-table tbody, table.data-table tr, table.data-table td {
    display: block;
    width: 100%;
  }

  table.data-table tr {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 10px 12px;
  }

  table.data-table td {
    border: none !important;
    padding: 6px 0 !important;
    text-align: left !important;
  }

  table.data-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    margin-bottom: 2px;
  }
}

.pannello-mobile-block {
  display: none;
}