/* ═══════════════════════════════════════════════════════════
   FormaPro — Stylesheet principale
   Identità visiva POLI.design / lessonsonair.polidesign.net
   ═══════════════════════════════════════════════════════════ */

/* ── Google Fonts ───────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=Work+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

/* ── Variabili globali ──────────────────────────────────── */
:root {
  /* Brand POLI.design */
  --primary:      #0038AD;   /* blu istituzionale */
  --primary-hov:  #002d8a;   /* hover */
  --primary-dk:   #1a2a5e;   /* sidebar */
  --primary-lt:   #e8edf8;   /* azzurro chiarissimo */

  /* Superfici */
  --surface:      #f0f2f8;
  --border:       #cdd5e8;
  --border-focus: #0038AD;

  /* Testo */
  --text:         #1a2a5e;
  --muted:        #6b7a9e;

  /* Semantici */
  --ok:           #059669;
  --warn:         #d97706;
  --danger:       #dc2626;

  /* Input */
  --input-bg:     #fff3f3;

  /* Layout */
  --sidebar-w:    252px;
  --topbar-h:     64px;

  /* Font */
  --font-head:    'Syne', sans-serif;
  --font-body:    'Work Sans', sans-serif;
}

/* ── Reset base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); background: var(--surface); color: var(--text); min-height: 100vh; }

/* ══════════════════════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════════════════════ */
#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Gradiente identico a lessonsonair.polidesign.net */
  background: linear-gradient(135deg,
    #c9cfe8 0%,
    #b8c8e8 15%,
    #d0d8f0 30%,
    #c5cce5 45%,
    #bcc5e0 55%,
    #c8c0d8 70%,
    #b8b0d0 85%,
    #a8b8d5 100%
  );
}

.lc {
  background: rgba(240, 244, 252, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 52px 44px 44px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 40px rgba(0, 56, 173, 0.10);
}

.lc-logo-wrap { text-align: center; margin-bottom: 36px; }
.lc-logo-wrap img { max-width: 220px; height: auto; }

/* Fallback testo se immagine non carica */
.lc-logo-text {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-dk);
  letter-spacing: -0.5px;
  text-align: center;
  margin-bottom: 4px;
}
.lc-logo-sub {
  font-family: var(--font-head);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin-bottom: 36px;
}

.lc label {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.lc .form-control {
  background: var(--input-bg);
  border: 1.5px solid transparent;
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 14px;
  font-family: var(--font-body);
  width: 100%;
  transition: border-color .2s;
  color: var(--text);
}
.lc .form-control:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 56, 173, .1);
  background: #fff;
}
.lc .form-control::placeholder { color: #aab3c8; }

.lc-note { font-size: 12px; color: var(--muted); margin-top: 16px; text-align: center; }

#loginErr {
  font-size: 13px;
  color: var(--danger);
  margin-top: 10px;
  display: none;
  padding: 10px 14px;
  background: #fee2e2;
  border-radius: 6px;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════ */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--primary-dk);
  display: flex;
  flex-direction: column;
  z-index: 200;
}

.sb-brand { padding: 28px 24px 22px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sb-brand-logo { max-width: 150px; height: auto; filter: brightness(0) invert(1); opacity: .92; }
.sb-brand-fallback {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  letter-spacing: .5px;
  display: none;
}
.sb-brand-sub {
  font-family: var(--font-head);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.38);
  margin-top: 4px;
}
.sb-module {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: rgba(255,255,255,.5);
  margin-top: 10px;
}

.sb-nav    { flex: 1; padding: 14px 0; overflow-y: auto; }
.sb-sec    { font-family: var(--font-head); font-size: 9px; letter-spacing: 2.5px; text-transform: uppercase; color: rgba(255,255,255,.25); padding: 14px 24px 6px; font-weight: 600; }

.sb-a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 24px;
  color: rgba(255,255,255,.55);
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 400;
  text-decoration: none;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.sb-a:hover  { color: #fff; background: rgba(255,255,255,.06); }
.sb-a.active { color: #fff; background: rgba(0, 56, 173, .35); border-left-color: #fff; }
.sb-a i      { width: 17px; text-align: center; font-size: 14px; }

.sb-badge {
  margin-left: auto;
  background: #e63946;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
  display: none;
}

.sb-foot    { padding: 18px 24px; border-top: 1px solid rgba(255,255,255,.08); }
.sb-user    { display: flex; align-items: center; gap: 10px; }
.sb-av      { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-weight: 700; font-size: 13px; flex-shrink: 0; }
.sb-uname   { font-family: var(--font-body); font-size: 13px; font-weight: 500; color: #fff; }
.sb-urole   { font-family: var(--font-head); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: rgba(255,255,255,.35); }

/* ══════════════════════════════════════════════════════════
   LAYOUT PRINCIPALE
   ══════════════════════════════════════════════════════════ */
#app   { margin-left: var(--sidebar-w); display: none; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 30px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.tb-t  { font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--primary-dk); letter-spacing: .3px; }
.tb-d  { font-family: var(--font-body); font-size: 12px; color: var(--muted); }

.page         { padding: 28px 30px; display: none; }
.page.active  { display: block; }

/* ══════════════════════════════════════════════════════════
   STAT CARDS (dashboard)
   ══════════════════════════════════════════════════════════ */
.scards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.sc {
  background: #fff;
  border-radius: 12px;
  padding: 22px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
}
.sc-ico  { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 19px; margin-bottom: 14px; background: var(--primary-lt); }
.sc-v    { font-family: var(--font-head); font-size: 32px; font-weight: 700; line-height: 1; margin-bottom: 4px; color: var(--primary-dk); }
.sc-l    { font-family: var(--font-body); font-size: 12px; color: var(--muted); font-weight: 400; }

/* ══════════════════════════════════════════════════════════
   TABLE CARD
   ══════════════════════════════════════════════════════════ */
.tc   { background: #fff; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.tc-h { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.tc-t { font-family: var(--font-head); font-size: 15px; font-weight: 600; color: var(--primary-dk); }

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

.t th {
  background: var(--surface);
  font-family: var(--font-head);
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.t td             { font-family: var(--font-body); padding: 13px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.t tr:last-child td { border-bottom: none; }
.t tbody tr:hover td { background: #f5f7fc; }
.t-empty          { text-align: center; color: var(--muted); padding: 36px !important; font-family: var(--font-body); }

/* ══════════════════════════════════════════════════════════
   AVATAR
   ══════════════════════════════════════════════════════════ */
.av    { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-weight: 700; font-size: 11px; flex-shrink: 0; }
.av-lg { width: 40px; height: 40px; font-size: 13px; }

/* ══════════════════════════════════════════════════════════
   PILLS / BADGE DI STATO
   ══════════════════════════════════════════════════════════ */
.pill    { display: inline-block; padding: 3px 10px; border-radius: 4px; font-size: 11px; font-family: var(--font-head); font-weight: 600; white-space: nowrap; letter-spacing: .4px; text-transform: uppercase; }
.p-ok    { background: #d1fae5; color: #065f46; }
.p-soon  { background: #fef3c7; color: #92400e; }
.p-late  { background: #fee2e2; color: #991b1b; }
.p-info  { background: #e8edf8; color: #0038AD; }
.p-gray  { background: #f1f5f9; color: #475569; }
.p-never { background: #f8fafc; color: #94a3b8; border: 1px solid var(--border); }

/* ══════════════════════════════════════════════════════════
   BOTTONI
   ══════════════════════════════════════════════════════════ */
.btn-p {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 10px 20px;
  font-size: 12px;
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .15s;
}
.btn-p:hover    { background: var(--primary-hov); }
.btn-p:disabled { opacity: .6; cursor: not-allowed; }

.btn-g {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  padding: 9px 16px;
  font-size: 12px;
  font-family: var(--font-head);
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-g:hover { border-color: var(--primary); color: var(--primary); }

.btn-ic {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 5px;
  color: var(--muted);
  transition: all .15s;
  font-family: inherit;
  font-size: 13px;
}
.btn-ic:hover     { background: var(--surface); color: var(--text); }
.btn-ic.del:hover { background: #fee2e2; color: var(--danger); }

.btn-sign {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 14px;
  font-size: 13px;
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-sign:hover    { background: var(--primary-hov); }
.btn-sign:disabled { opacity: .6; cursor: not-allowed; }

.btn-lo {
  background: none;
  border: none;
  color: rgba(255,255,255,.35);
  font-size: 12px;
  font-family: var(--font-head);
  letter-spacing: .5px;
  cursor: pointer;
  margin-top: 10px;
  padding: 0;
  transition: color .2s;
  text-transform: uppercase;
}
.btn-lo:hover { color: rgba(255,255,255,.8); }

/* ══════════════════════════════════════════════════════════
   FORM CONTROLS
   ══════════════════════════════════════════════════════════ */
.form-control,
.form-select {
  background: var(--input-bg);
  border: 1.5px solid transparent;
  border-radius: 6px;
  padding: 10px 13px;
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color .2s, background .2s;
  color: var(--text);
  width: 100%;
}
.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 56, 173, .08);
  outline: none;
}
.form-control::placeholder { color: #aab3c8; }
.form-label { font-family: var(--font-body); font-size: 13px; font-weight: 500; display: block; margin-bottom: 6px; color: var(--text); }

/* ── Barra di ricerca ───────────────────────────────────── */
.sw-wrap            { position: relative; }
.sw-wrap i          { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; pointer-events: none; }
.sw-wrap input      { padding-left: 33px; }

/* ══════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════ */
.modal-content  { border-radius: 12px; border: none; box-shadow: 0 20px 60px rgba(0, 38, 120, .15); font-family: var(--font-body); }
.modal-header   { padding: 24px 26px 0; border-bottom: none; }
.modal-body     { padding: 20px 26px; }
.modal-footer   { padding: 0 26px 24px; border-top: none; gap: 8px; }
.modal-title    { font-family: var(--font-head); font-size: 17px; font-weight: 700; color: var(--primary-dk); }

/* ══════════════════════════════════════════════════════════
   PROGRESS BAR
   ══════════════════════════════════════════════════════════ */
.prog   { height: 5px; background: var(--border); border-radius: 4px; overflow: hidden; }
.prog-b { height: 100%; border-radius: 4px; background: var(--primary); transition: width .5s; }

/* ══════════════════════════════════════════════════════════
   SPINNER DI CARICAMENTO
   ══════════════════════════════════════════════════════════ */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-loading { display: flex; align-items: center; justify-content: center; padding: 60px; color: var(--muted); gap: 12px; font-family: var(--font-body); }

/* ══════════════════════════════════════════════════════════
   TOAST NOTIFICHE
   ══════════════════════════════════════════════════════════ */
#toasts {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fp-toast {
  background: var(--primary-dk);
  color: #fff;
  padding: 13px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 8px 28px rgba(0, 38, 120, .2);
  animation: tIn .3s ease;
}
.fp-toast.ok  { background: var(--ok); }
.fp-toast.err { background: var(--danger); }

@keyframes tIn { from { opacity: 0; transform: translateX(50px); } }

/* ══════════════════════════════════════════════════════════
   SCADENZA PREVIEW (modal frequenza)
   ══════════════════════════════════════════════════════════ */
#scadPrev {
  background: #e8edf8;
  border-radius: 6px;
  padding: 11px 14px;
  font-size: 13px;
  font-family: var(--font-body);
  display: none;
  margin-top: 12px;
  color: var(--primary-dk);
}

/* ══════════════════════════════════════════════════════════
   MATRICE CORSI
   ══════════════════════════════════════════════════════════ */
#matTable th,
#matTable td { white-space: nowrap; }
