/* ============================================================
   Portale Dipendenti — Smaltimento Assistito
   Design tokens presi dal sito pubblico (colori, font, raggi)
   ============================================================ */

:root {
  /* Colori brand (da smaltimentoassistito.it) */
  --navy: #001D66;
  --navy-soft: #24408f;
  --purple: #9450FF;
  --purple-light: #AC9EFF;
  --green: #5CE5A3;
  --green-light: #8CFFCD;
  --darkgrey: #2D3D55;
  --grey: #697484;
  --lightgrey: #C3CBD7;
  --bg: #F0F0F5;
  --white: #FFFFFF;

  --success: #589C00;
  --warning: #D2980E;
  --info: #1478B2;
  --alarm: #B44108;

  /* Tipografia */
  --font-body: "Poppins", "Helvetica Neue", Arial, sans-serif;

  /* Raggi (coerenti col sito: pill sui bottoni, morbidi sulle card) */
  --radius-pill: 32px;
  --radius-card: 24px;
  --radius-image: 8px;
  --radius-sm: 12px;

  /* Ombre */
  --shadow-card: 0 4px 18px rgba(0, 29, 102, 0.07);
  --shadow-card-hover: 0 10px 28px rgba(0, 29, 102, 0.12);
  --shadow-sharp: 6px 6px 0px rgba(0, 29, 102, 0.08);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--navy);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-body);
  color: var(--navy);
  margin: 0 0 8px;
  font-weight: 700;
  line-height: 1.15;
}

p { line-height: 1.55; color: var(--darkgrey); margin: 0 0 12px; }

a { color: inherit; text-decoration: none; }

button { font-family: var(--font-body); cursor: pointer; }

img { max-width: 100%; display: block; }

svg { stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }

.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-soft); box-shadow: var(--shadow-card-hover); }

.btn-ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--lightgrey); }
.btn-ghost:hover { border-color: var(--navy); }

.btn-accent { background: var(--purple); color: var(--white); }
.btn-accent:hover { box-shadow: var(--shadow-card-hover); }

.btn-sm { padding: 9px 18px; font-size: 0.85rem; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-topic { background: rgba(20, 120, 178, 0.12); color: var(--info); }
.badge-campaign { background: rgba(148, 80, 255, 0.14); color: var(--purple); }
.badge-doc { background: rgba(88, 156, 0, 0.12); color: var(--success); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.login-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  z-index: 0;
}
.login-blob.one { width: 420px; height: 420px; background: var(--purple-light); top: -120px; left: -120px; }
.login-blob.two { width: 380px; height: 380px; background: var(--green-light); bottom: -140px; right: -100px; }

.login-card {
  position: relative;
  z-index: 1;
  background: var(--white);
  width: 100%;
  max-width: 420px;
  padding: 44px 40px 36px;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card-hover);
  text-align: center;
}

.login-card .logo { width: 52px; margin: 0 auto 20px; }

.login-card h1 { font-size: 1.6rem; margin-bottom: 6px; }
.login-card .subtitle { color: var(--grey); font-size: 0.92rem; margin-bottom: 28px; }

.field { text-align: left; margin-bottom: 16px; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--darkgrey); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--lightgrey);
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--navy);
}
.field input:focus { outline: none; border-color: var(--purple); background: var(--white); }

.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 24px;
}
.login-row a { color: var(--info); font-weight: 600; }
.remember { display: flex; align-items: center; gap: 6px; color: var(--grey); }

.login-card .btn { width: 100%; justify-content: center; margin-bottom: 18px; }

.pw-error { color: var(--alarm); font-size: 0.8rem; font-weight: 600; margin: -6px 0 14px; }

.demo-note {
  font-size: 0.75rem;
  color: var(--grey);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: left;
}
.demo-note strong { color: var(--navy); }

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--navy);
  color: var(--white);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 0 6px; }
.sidebar .brand .brand-logo { width: 150px; height: auto; }
.sidebar .brand small { font-family: var(--font-body); font-weight: 500; font-size: 0.66rem; color: var(--purple-light); letter-spacing: 0.06em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  transition: background 0.15s ease, color 0.15s ease;
}
.nav a .ico { width: 18px; height: 18px; flex-shrink: 0; }
.nav a:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav a.active { background: var(--purple); color: var(--white); }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 16px;
}
.lock-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.6);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.lock-btn:hover { background: rgba(255,255,255,0.08); color: var(--white); }

/* ---- Main ---- */
.main { padding: 32px 40px 60px; width: 100%; min-width: 0; }

/* ---- Banner avviso in evidenza (sostituisce il topbar) ---- */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(120deg, var(--navy) 0%, var(--purple) 130%);
  color: var(--white);
  border-radius: var(--radius-pill);
  padding: 10px 12px 10px 18px;
  margin-bottom: 30px;
  box-shadow: var(--shadow-card-hover);
}
.alert-banner .alert-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.alert-banner .alert-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.alert-banner .alert-body strong { font-size: 0.9rem; }
.alert-banner .alert-body span { font-size: 0.8rem; opacity: 0.85; }
.alert-banner .btn { background: var(--white); color: var(--navy); flex-shrink: 0; }
.alert-banner .btn:hover { background: var(--bg); }

/* ---- Sezione generica ---- */
.section { margin-bottom: 36px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.section-head h2 { font-size: 1.3rem; }

.section-major { margin-top: 20px; }
.section-major .section-head h2 { font-size: 1.7rem; }
.section-head .hint { color: var(--grey); font-size: 0.82rem; }
.section-head a.see-all { font-size: 0.82rem; font-weight: 600; color: var(--info); flex-shrink: 0; }

.card {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

/* ---- Griglia dashboard: calendario + carosello ---- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 22px;
  align-items: start;
}

/* ---- Mini calendario ---- */
.calendar-card {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 24px;
  order: 2;
}
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.calendar-head .month { font-weight: 700; font-size: 1.05rem; }
.calendar-nav { display: flex; gap: 6px; }
.calendar-nav button {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--lightgrey);
  background: var(--white); color: var(--navy); font-size: 0.8rem; display: flex; align-items: center; justify-content: center;
}
.calendar-nav button:hover { background: var(--bg); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-dow { font-size: 0.65rem; color: var(--grey); font-weight: 600; padding-bottom: 4px; text-transform: uppercase; }
.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 0.8rem;
  border-radius: 50%;
  color: var(--darkgrey);
}
.cal-day.muted { color: var(--lightgrey); }
.cal-day.today { background: var(--navy); color: var(--white); font-weight: 700; }
.cal-day.past:not(.today) { color: var(--grey); }
.cal-day.has-event { cursor: pointer; }

.cal-day-dots {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
}
.cal-day-dot { width: 4px; height: 4px; border-radius: 50%; }
.cal-day.past .cal-day-dot { opacity: 0.4; }
.cal-day.today .cal-day-dot { outline: 1px solid var(--navy); }

.dot-event { background: var(--purple); }

/* ---- Tooltip eventi calendario ---- */
.cal-tooltip {
  position: fixed;
  transform: translate(-50%, calc(-100% - 10px));
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.72rem;
  box-shadow: var(--shadow-card-hover);
  z-index: 60;
  pointer-events: none;
  max-width: 220px;
}
.cal-tooltip[hidden] { display: none; }
.cal-tooltip-item { display: flex; align-items: center; gap: 6px; padding: 2px 0; white-space: nowrap; }
.cal-tooltip-item .cal-day-dot { flex-shrink: 0; }

.see-all-events-btn { width: 100%; justify-content: center; margin-top: 14px; }

/* ---- Popup elenco completo eventi ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 29, 102, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card-hover);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--bg); }
.modal-head h3 { font-size: 1.1rem; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: var(--bg); color: var(--navy); font-size: 1.1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.modal-close:hover { background: var(--lightgrey); }
.modal-body { padding: 18px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-event-row { display: flex; gap: 12px; align-items: flex-start; }
.modal-event-row.is-past { opacity: 0.5; }
.modal-event-row .upcoming-info { display: flex; flex-direction: column; gap: 2px; }
.modal-event-row .type-line { display: flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--grey); }
.modal-event-note { font-size: 0.76rem; color: var(--grey); font-style: italic; margin-top: 2px; }

.upcoming { margin-top: 18px; border-top: 1px solid var(--bg); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.upcoming-item { display: flex; gap: 12px; align-items: flex-start; }
.upcoming-date {
  background: var(--bg);
  border-radius: var(--radius-sm);
  min-width: 44px;
  text-align: center;
  padding: 6px 4px;
  flex-shrink: 0;
}
.upcoming-date .d { font-weight: 700; font-size: 0.95rem; display: block; line-height: 1; }
.upcoming-date .m { font-size: 0.6rem; text-transform: uppercase; color: var(--grey); }
.upcoming-info strong { display: block; font-size: 0.85rem; margin-bottom: 2px; }
.upcoming-info span { font-size: 0.76rem; color: var(--grey); }

/* ---- Colonna calendario+carosello: novità/campagne sopra, presentazione sotto ---- */
.col-stack { display: flex; flex-direction: column; gap: 32px; min-width: 0; order: 1; }

/* ---- Novità & Campagne: carosello testuale sottile ---- */
.carousel-card { display: flex; flex-direction: column; min-width: 0; }
.carousel-viewport { overflow: hidden; border-radius: var(--radius-sm); min-width: 0; }
.carousel-track { display: flex; transition: transform 0.4s ease; }
.slide {
  min-width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 96px;
  padding: 2px 4px;
}
.slide-text { min-width: 0; flex: 1; }
.slide-text .badge { margin-bottom: 8px; }
.slide-text h3 { font-size: 1rem; margin-bottom: 4px; }
.slide-text p { font-size: 0.82rem; margin-bottom: 0; }
.slide .btn { flex-shrink: 0; white-space: nowrap; }

.carousel-controls { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.carousel-dots { display: flex; gap: 6px; }
.carousel-dots button { width: 7px; height: 7px; border-radius: 50%; border: none; background: var(--lightgrey); padding: 0; }
.carousel-dots button.active { background: var(--purple); width: 20px; border-radius: var(--radius-pill); }
.carousel-arrows { display: flex; gap: 8px; }
.carousel-arrows button {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--lightgrey);
  background: var(--white); display: flex; align-items: center; justify-content: center;
}
.carousel-arrows button:hover { background: var(--bg); }

/* ---- Ultima Presentazione (embed Google Slides) ---- */
.slides-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.slides-embed iframe { width: 100%; height: calc(100% + 36px); border: none; display: block; }

/* ---- Esplora risorse ---- */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn {
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--lightgrey);
  background: var(--white);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--darkgrey);
}
.tab-btn.active { background: var(--navy); border-color: var(--navy); color: var(--white); }

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.resource-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.resource-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.resource-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(148, 80, 255, 0.12);
  color: var(--purple);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}
.resource-body { flex: 1; min-width: 0; }
.resource-body strong { display: block; font-size: 0.85rem; margin-bottom: 2px; }
.resource-body span { font-size: 0.72rem; color: var(--grey); }
.resource-download {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--navy);
}
.resource-card:hover .resource-download { background: var(--navy); color: var(--white); }
.resource-card.placeholder { opacity: 0.5; }
.resource-card.placeholder:hover { box-shadow: var(--shadow-card); transform: none; }
.resource-card.placeholder:hover .resource-download { background: var(--bg); color: var(--navy); }
.resource-group-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--grey); margin: 0 0 12px; }
[data-resource-group].is-detached {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--bg);
}

/* ---- Link utili ---- */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.link-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.link-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.link-card .link-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--navy);
  font-size: 0.95rem;
}
.link-card strong { font-size: 0.88rem; }
.link-card span { font-size: 0.74rem; color: var(--grey); }
.link-card.placeholder { opacity: 0.55; }
.link-card.placeholder:hover { transform: none; box-shadow: var(--shadow-card); }

.link-group + .link-group {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--bg);
}

.footer-note { text-align: center; font-size: 0.75rem; color: var(--lightgrey); margin-top: 30px; }

/* ---- Responsive ----
   Tre livelli:
   1) fino a 1180px (tablet / finestra media): il menu resta aperto come
      da desktop, ma calendario e contenuti si impilano come da smartphone
      — altrimenti tra i due layout la colonna centrale (Novità & Campagne)
      diventa troppo stretta per essere leggibile.
   2) da 480px a 1180px: se c'è abbastanza larghezza, dentro il box del
      calendario la griglia e gli eventi stanno affiancati invece che impilati.
   3) fino a 1000px (smartphone): il menu diventa una barra orizzontale. */

@media (max-width: 1180px) {
  .grid-2 { grid-template-columns: 1fr; }
  .calendar-card { position: static; order: -1; }
  .main { padding: 24px; }
}

@media (min-width: 480px) and (max-width: 1180px) {
  .calendar-card { flex-direction: row; align-items: flex-start; gap: 24px; }
  .calendar-main { flex: 1; min-width: 0; }
  .upcoming {
    flex: 1;
    min-width: 0;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    border-left: 1px solid var(--bg);
    padding-left: 20px;
  }
}

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; align-items: center; padding: 16px 20px; }
  .sidebar .nav { display: none; }
  .sidebar-footer { border: none; padding: 0; margin-left: auto; }
  .alert-banner { flex-wrap: wrap; }
  .alert-banner .btn { width: 100%; justify-content: center; }
  .slide { flex-direction: column; align-items: flex-start; }
}
