/* ==========================================================================
   Calendario Corsi AI7 - design system del pannello admin
   Prefisso .ad-  |  Nessuna dipendenza da framework CSS
   ========================================================================== */

@font-face {
  font-family: 'DM Sans';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('../../public/webfonts/dm-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('../../public/webfonts/dm-sans-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('../../public/webfonts/dm-sans-latin-600-normal.woff2') format('woff2');
}

:root {
  --rosso:      #c8102e;
  --rosso-scuro:#a50d26;
  --scuro:      #16161f;
  --scuro-2:    #1f1f2b;
  --scuro-3:    #2b2b3a;
  --testo:      #23232f;
  --testo-soft: #6b6b80;
  --bordo:      #e4e4ec;
  --sfondo:     #f5f5f8;
  --bianco:     #ffffff;
  --verde:      #17996b;
  --verde-soft: #e6f6ef;
  --ambra:      #b57400;
  --ambra-soft: #fdf3e0;
  --rosso-soft: #fdeaee;
  --blu:        #2563c9;
  --blu-soft:   #e8f0fd;
  --sidebar-w:  256px;
  --raggio:     12px;
  --ombra:      0 8px 24px rgba(20,20,35,.06);
  --ombra-hover:0 12px 32px rgba(20,20,35,.1);
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--testo);
  background: var(--sfondo);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--rosso); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.ad-layout { display: flex; min-height: 100vh; }

.ad-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.ad-content { padding: 24px 28px 56px; flex: 1; }

@media (max-width: 991px) {
  .ad-main { margin-left: 0; }
  .ad-content { padding: 16px 14px 48px; }
}

/* ---------- Sidebar ---------- */
.ad-sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--scuro);
  color: #c7c7d6;
  display: flex; flex-direction: column;
  z-index: 60;
  overflow-y: auto;
}

.ad-sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 18px;
  color: #fff; text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.ad-sidebar-brand:hover { text-decoration: none; }
.ad-sidebar-brand-icon {
  width: 38px; height: 38px; flex: none;
  border-radius: 9px;
  background: var(--rosso);
  display: grid; place-items: center;
  font-size: 17px;
}
.ad-sidebar-brand-name { display: block; font-weight: 600; font-size: 15px; line-height: 1.2; }
.ad-sidebar-brand-sub  { display: block; font-size: 12px; color: #8a8a9c; }

.ad-sidebar-nav { padding: 14px 10px 28px; flex: 1; }

.ad-sidebar-section {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: #6a6a80; font-weight: 600;
  padding: 16px 9px 7px;
}

.ad-nav-list { list-style: none; margin: 0; padding: 0; }

.ad-nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: 8px;
  color: #c7c7d6; font-size: 14.5px;
  text-decoration: none;
  transition: background .13s, color .13s;
}
.ad-nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.ad-nav-link.is-active { background: var(--rosso); color: #fff; font-weight: 500; }
.ad-nav-link i { width: 19px; text-align: center; font-size: 14px; }
.ad-nav-badge {
  margin-left: auto; background: var(--rosso); color: #fff;
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 20px;
}
.ad-nav-link.is-active .ad-nav-badge { background: rgba(255,255,255,.25); }

/* ---------- Topbar ---------- */
.ad-topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px; height: 60px;
  background: var(--bianco);
  border-bottom: 1px solid var(--bordo);
}
.ad-topbar-title { font-weight: 600; font-size: 17px; }
.ad-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.ad-topbar-user { font-size: 14px; color: var(--testo-soft); display: flex; align-items: center; gap: 7px; }
.ad-topbar-logout { color: var(--testo-soft); font-size: 17px; }
.ad-topbar-logout:hover { color: var(--rosso); }
.ad-sidebar-toggle {
  border: 0; background: transparent; font-size: 19px; color: var(--testo);
  cursor: pointer; padding: 6px 4px; display: none;
}

@media (max-width: 991px) {
  .ad-topbar { padding: 0 14px; }
  .ad-sidebar-toggle { display: block; }
  .ad-sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .ad-sidebar.is-open { transform: translateX(0); }
  .ad-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55;
  }
}

/* ---------- Intestazione di pagina ---------- */
.ad-page-head {
  display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.ad-page-head h1 { margin: 0; font-size: 22px; font-weight: 600; }
.ad-page-head p { margin: 4px 0 0; color: var(--testo-soft); font-size: 14px; }
.ad-page-actions { margin-left: auto; display: flex; gap: 9px; flex-wrap: wrap; }

/* ---------- Card ---------- */
.ad-card {
  background: var(--bianco);
  border: 1px solid transparent;
  border-radius: var(--raggio);
  box-shadow: var(--ombra);
  margin-bottom: 20px;
  transition: box-shadow 0.25s ease;
}
.ad-card:hover {
  box-shadow: var(--ombra-hover);
}
.ad-card-head {
  padding: 15px 18px; border-bottom: 1px solid var(--bordo);
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
}
.ad-card-head h2 { margin: 0; font-size: 15.5px; font-weight: 600; }
.ad-card-head .ad-page-actions { margin-left: auto; }
.ad-card-body { padding: 18px; }
.ad-card-body.is-flush { padding: 0; }

/* ---------- Griglie ---------- */
.ad-grid { display: grid; gap: 16px; margin-bottom: 20px; }
/* Le griglie usate per impaginare un form dentro una card non spaziano oltre. */
.ad-card-body .ad-grid { margin-bottom: 0; }
.ad-card-body .ad-grid + .ad-grid { margin-top: 16px; }
.ad-grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.ad-grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.ad-grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 991px) { .ad-grid-3, .ad-grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px)  { .ad-grid-2, .ad-grid-3, .ad-grid-4 { grid-template-columns: 1fr; } }

/* ---------- Statistiche ---------- */
.ad-stat {
  background: var(--bianco); border: 1px solid var(--bordo);
  border-radius: var(--raggio); padding: 17px 18px; box-shadow: var(--ombra);
}
.ad-stat-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--testo-soft); font-weight: 600;
  display: flex; align-items: center; gap: 7px;
}
.ad-stat-value { font-size: 27px; font-weight: 600; margin-top: 7px; line-height: 1.1; }
.ad-stat-sub { font-size: 13px; color: var(--testo-soft); margin-top: 3px; }

/* ---------- Tabelle ---------- */
.ad-table-wrap { overflow-x: auto; }
.ad-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.ad-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--testo-soft); font-weight: 600;
  padding: 11px 14px; border-bottom: 1px solid var(--bordo); white-space: nowrap;
}
.ad-table td { padding: 12px 14px; border-bottom: 1px solid var(--bordo); vertical-align: middle; }
.ad-table tr:last-child td { border-bottom: 0; }
.ad-table tbody tr:hover { background: #fafafc; }
.ad-table .ad-num { text-align: right; font-variant-numeric: tabular-nums; }

.ad-table tfoot td {
  border-top: 2px solid var(--bordo);
  border-bottom: 0;
  background: #fafafc;
  font-size: 14.5px;
}

/* Tabella riepilogo mensile: prima colonna bloccata quando si scorre */
.ad-table-mensile th:first-child,
.ad-table-mensile td:first-child {
  position: sticky; left: 0;
  background: var(--bianco);
  z-index: 1;
}
.ad-table-mensile tfoot td:first-child { background: #fafafc; }
.ad-table-mensile tbody tr:hover td:first-child { background: #fafafc; }
.ad-mese-corrente { background: #fff8f9; }

@media print {
  .ad-sidebar, .ad-topbar, .ad-page-actions, .ad-filtri { display: none !important; }
  .ad-main { margin-left: 0; }
  .ad-content { padding: 0; }
  .ad-card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

/* ---------- Badge e pallini ---------- */
.ad-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
  background: #eeeef3; color: var(--testo-soft); white-space: nowrap;
}
.ad-badge-verde { background: var(--verde-soft); color: var(--verde); }
.ad-badge-rosso { background: var(--rosso-soft); color: var(--rosso); }
.ad-badge-ambra { background: var(--ambra-soft); color: var(--ambra); }
.ad-badge-blu   { background: var(--blu-soft);   color: var(--blu); }

.ad-dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  display: inline-block; vertical-align: middle;
}

/* ---------- Bottoni ---------- */
.ad-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 8px; border: 1px solid transparent;
  font-family: inherit; font-size: 14px; font-weight: 500; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform 0.15s, background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.ad-btn:active { transform: scale(0.97); }
.ad-btn:hover { text-decoration: none; }
.ad-btn-primario { background: linear-gradient(135deg, var(--rosso) 0%, var(--rosso-scuro) 100%); color: #fff; box-shadow: 0 4px 12px rgba(200,16,46,.2); border: 0; }
.ad-btn-primario:hover { box-shadow: 0 6px 16px rgba(200,16,46,.3); filter: brightness(1.1); }
.ad-btn-neutro { background: var(--bianco); color: var(--testo); border-color: var(--bordo); }
.ad-btn-neutro:hover { background: #f2f2f6; color: var(--testo); }
.ad-btn-scuro { background: var(--scuro-2); color: #fff; }
.ad-btn-scuro:hover { background: var(--scuro-3); color: #fff; }
.ad-btn-pericolo { background: var(--bianco); color: var(--rosso); border-color: #f3c7cf; }
.ad-btn-pericolo:hover { background: var(--rosso-soft); color: var(--rosso); }
.ad-btn-piccolo { padding: 6px 11px; font-size: 13px; }
.ad-btn-blocco { width: 100%; }
.ad-btn[disabled] { opacity: .55; pointer-events: none; }

.ad-btn-icona {
  width: 32px; height: 32px; padding: 0; border-radius: 7px;
  background: transparent; border: 1px solid var(--bordo); color: var(--testo-soft);
}
.ad-btn-icona:hover { background: #f2f2f6; color: var(--testo); }

/* ---------- Form ---------- */
.ad-form-riga { margin-bottom: 16px; }
.ad-label {
  display: block; font-size: 13px; font-weight: 600; color: #4a4a5c; margin-bottom: 6px;
}
.ad-aiuto { font-size: 12.5px; color: var(--testo-soft); margin-top: 5px; }

.ad-input, .ad-select, .ad-textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--bordo); border-radius: 8px;
  font-family: inherit; font-size: 14.5px; color: var(--testo); background: var(--bianco);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.ad-input:focus, .ad-select:focus, .ad-textarea:focus {
  outline: none; border-color: var(--rosso); box-shadow: 0 0 0 4px rgba(200,16,46,.15);
}
.ad-textarea { min-height: 92px; resize: vertical; }
.ad-input[type=color] { padding: 3px; height: 40px; cursor: pointer; }

.ad-check { display: flex; align-items: flex-start; gap: 9px; font-size: 14.5px; cursor: pointer; }
.ad-check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--rosso); flex: none; }

.ad-form-azioni {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding-top: 17px; margin-top: 5px; border-top: 1px solid var(--bordo);
}

/* ---------- Avvisi ---------- */
.ad-avviso {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 16px; border-radius: var(--raggio);
  margin-bottom: 18px; font-size: 14.5px;
  border-left: 3px solid;
}
.ad-avviso i { margin-top: 2px; }
.ad-avviso-success { background: var(--verde-soft); border-color: var(--verde); color: #0f6d4c; }
.ad-avviso-error   { background: var(--rosso-soft); border-color: var(--rosso); color: #91142c; }
.ad-avviso-warning { background: var(--ambra-soft); border-color: var(--ambra); color: #7d5100; }
.ad-avviso-info    { background: var(--blu-soft);   border-color: var(--blu);   color: #1b4a99; }

/* ---------- Stato vuoto ---------- */
.ad-vuoto { text-align: center; padding: 44px 20px; color: var(--testo-soft); }
.ad-vuoto i { font-size: 34px; opacity: .35; display: block; margin-bottom: 12px; }
.ad-vuoto p { margin: 0 0 16px; }

/* ---------- Calendario mensile ---------- */
.ad-cal-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ad-cal-mese { font-size: 17px; font-weight: 600; min-width: 190px; }

.ad-cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ad-cal th {
  padding: 9px 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--testo-soft); font-weight: 600; border-bottom: 1px solid var(--bordo);
}
.ad-cal td {
  border: 1px solid var(--bordo); vertical-align: top;
  height: 112px; padding: 5px; position: relative;
}
.ad-cal-giorno { font-size: 12.5px; color: var(--testo-soft); font-weight: 600; padding: 1px 3px; }
.ad-cal td.is-fuori { background: #fafafc; }
.ad-cal td.is-fuori .ad-cal-giorno { opacity: .4; }
.ad-cal td.is-oggi { background: #fff8f9; }
.ad-cal td.is-oggi .ad-cal-giorno { color: var(--rosso); }
.ad-cal td.is-sospeso { background: repeating-linear-gradient(45deg, #fafafc, #fafafc 7px, #f2f2f6 7px, #f2f2f6 14px); }
.ad-cal-sospeso {
  font-size: 11px; color: var(--testo-soft); font-style: italic;
  padding: 2px 4px; display: block;
}

.ad-cal-ev {
  display: block; margin-top: 3px; padding: 3px 6px;
  border-radius: 5px; font-size: 12px; line-height: 1.35;
  color: #fff; text-decoration: none;
  border-left: 3px solid rgba(0,0,0,.22);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ad-cal-ev:hover { text-decoration: none; filter: brightness(1.08); }
.ad-cal-ev.is-annullata { text-decoration: line-through; opacity: .55; }
.ad-cal-ev-ora { font-weight: 600; opacity: .9; }

@media (max-width: 767px) {
  .ad-cal td { height: 76px; font-size: 11px; }
  .ad-cal-ev { font-size: 10.5px; padding: 2px 4px; }
}

/* ---------- Elenco lezioni (vista agenda) ---------- */
.ad-agenda { list-style: none; margin: 0; padding: 0; }
.ad-agenda li {
  display: flex; gap: 13px; align-items: center;
  padding: 12px 18px; border-bottom: 1px solid var(--bordo);
}
.ad-agenda li:last-child { border-bottom: 0; }
.ad-agenda-data {
  flex: none; width: 52px; text-align: center; line-height: 1.15;
}
.ad-agenda-data b { display: block; font-size: 19px; font-weight: 600; }
.ad-agenda-data span { font-size: 11.5px; color: var(--testo-soft); text-transform: uppercase; }
.ad-agenda-corpo { min-width: 0; flex: 1; }
.ad-agenda-titolo { font-weight: 500; }
.ad-agenda-meta { font-size: 13px; color: var(--testo-soft); margin-top: 2px; }
.ad-agenda-azioni { margin-left: auto; display: flex; gap: 7px; flex: none; }

@media (max-width: 640px) {
  .ad-agenda li { flex-wrap: wrap; padding: 12px 14px; }
  .ad-agenda-azioni { margin-left: 65px; width: 100%; }
}

/* ---------- Barra dei filtri ---------- */
.ad-filtri {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
}
.ad-filtri .ad-form-riga { margin-bottom: 0; min-width: 160px; }

/* ---------- Barra di avanzamento ore ---------- */
.ad-barra { height: 7px; border-radius: 4px; background: #eeeef3; overflow: hidden; }
.ad-barra > span { display: block; height: 100%; border-radius: 4px; background: var(--rosso); }

/* ---------- Utility ---------- */
.ad-flex { display: flex; align-items: center; gap: 9px; }
.ad-flex-wrap { flex-wrap: wrap; }
.ad-mt-0 { margin-top: 0; }
.ad-mb-0 { margin-bottom: 0; }
.ad-soft { color: var(--testo-soft); }
.ad-piccolo { font-size: 13px; }
.ad-nowrap { white-space: nowrap; }
.ad-destra { text-align: right; }
