/* ==========================================================
   Area Riservata — Stile principale
   Colore primario: #0077d0
   Font: Poppins (titoli/UI), Montserrat (testo)
   ========================================================== */

:root {
  --primary: #0077d0;
  --primary-dark: #005fa8;
  --primary-darker: #004c87;
  --primary-light: #e8f3fc;
  --primary-soft: #cfe6fa;

  --ink: #16243a;
  --ink-soft: #5b6b82;
  --paper: #f4f7fb;
  --surface: #ffffff;
  --border: #e2e8f1;

  --success: #1ba35e;
  --success-light: #e3f7ec;
  --danger: #e0433f;
  --danger-light: #fdecec;
  --warning: #c8860a;
  --warning-light: #fdf3e0;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(22, 36, 58, .06);
  --shadow: 0 8px 24px rgba(22, 36, 58, .08);
  --shadow-lg: 0 20px 50px rgba(22, 36, 58, .16);

  --font-display: "Poppins", "Montserrat", sans-serif;
  --font-body: "Montserrat", "Poppins", sans-serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5,
.brand, .btn, .nav-link, .sidebar-link, label, th,
.stat-card .stat-value, .badge {
  font-family: var(--font-display);
}

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 600; color: var(--ink); }
h1 { font-size: 1.9rem; letter-spacing: -.01em; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

:focus-visible {
  outline: 2.5px solid var(--primary-dark);
  outline-offset: 2px;
}

/* ----------------------------------------------------------
   Bottoni
   ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  font-weight: 600;
  font-size: .92rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .72em 1.3em;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease, border-color .12s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: .45em .9em; font-size: .82rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ----------------------------------------------------------
   Form
   ---------------------------------------------------------- */
.field { margin-bottom: 1.1em; }
label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: .4em;
  color: var(--ink);
}
.hint { font-size: .8rem; color: var(--ink-soft); margin-top: .35em; }

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=file], select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: .95rem;
  padding: .75em .9em;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  outline: none;
}
input[type=file] { padding: .55em; cursor: pointer; }
textarea { min-height: 100px; resize: vertical; }

.checkbox-row { display: flex; align-items: center; gap: .55em; }
.checkbox-row input { width: auto; }

/* ----------------------------------------------------------
   Alert / badge
   ---------------------------------------------------------- */
.alert {
  padding: .85em 1.1em;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  margin-bottom: 1.2em;
  display: flex;
  align-items: flex-start;
  gap: .6em;
}
.alert-error { background: var(--danger-light); color: #a32420; }
.alert-success { background: var(--success-light); color: #0f7a45; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  font-size: .72rem;
  font-weight: 600;
  padding: .3em .7em;
  border-radius: 99px;
  letter-spacing: .02em;
}
.badge-admin { background: var(--primary-light); color: var(--primary-dark); }
.badge-utente { background: #eef1f6; color: var(--ink-soft); }
.badge-attivo { background: var(--success-light); color: #0f7a45; }
.badge-disattivo { background: var(--danger-light); color: #a32420; }
.badge-pdf { background: #fdecec; color: #c0392b; }
.badge-video { background: var(--primary-light); color: var(--primary-dark); }
.badge-altro { background: #f1eefc; color: #6c4fc0; }

/* ==========================================================
   LOGIN — pagina divisa in due
   ========================================================== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.login-brand {
  position: relative;
  background: linear-gradient(155deg, var(--primary-darker), var(--primary) 55%, #1aa0e8);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3.2rem;
  overflow: hidden;
}
.login-brand .pattern {
  position: absolute; inset: 0;
  opacity: .5;
  pointer-events: none;
}
.login-brand-top { position: relative; z-index: 1; }
.login-brand .logo-mark {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1.6rem;
}
.login-brand .logo-mark svg { width: 24px; height: 24px; color: #fff; }
.login-brand h1 { color: #fff; font-size: 2.1rem; max-width: 420px; }
.login-brand p.lead { color: rgba(255,255,255,.85); max-width: 380px; font-size: 1rem; }
.login-brand-bottom {
  position: relative; z-index: 1;
  font-size: .85rem;
  color: rgba(255,255,255,.75);
  border-top: 1px solid rgba(255,255,255,.2);
  padding-top: 1.2rem;
}

.login-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  background: var(--surface);
}
.login-form-box { width: 100%; max-width: 380px; }
.login-form-box .eyebrow {
  font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--primary);
  margin-bottom: .6em;
}
.login-form-box h2 { margin-bottom: .25em; }
.login-form-box .sub { color: var(--ink-soft); margin-bottom: 1.8em; }

@media (max-width: 880px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-form-wrap { padding: 1.4rem; }
}

/* ==========================================================
   NAVBAR (area utente)
   ========================================================== */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .9rem 1.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: .6em; font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.brand .logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.brand .logo-mark svg { width: 18px; height: 18px; }
.navbar-right { display: flex; align-items: center; gap: 1rem; }
.user-chip { display: flex; align-items: center; gap: .6em; font-size: .9rem; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
}

.page-wrap { max-width: 1180px; margin: 0 auto; padding: 2.2rem 1.6rem 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.8rem; flex-wrap: wrap; }
.page-head p { color: var(--ink-soft); margin: 0; }
.breadcrumb { font-size: .85rem; color: var(--ink-soft); margin-bottom: .6em; }
.breadcrumb a { color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--primary); }

/* ----------------------------------------------------------
   Griglia cartelle
   ---------------------------------------------------------- */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.1rem;
}
.folder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  text-decoration: none;
  color: var(--ink);
  display: block;
  position: relative;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
  overflow: hidden;
}
.folder-card::before {
  content: ""; position: absolute; left: 0; top: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--primary), #36a6f0);
}
.folder-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary-soft); text-decoration: none; }
.folder-card .folder-icon {
  width: 46px; height: 46px; border-radius: var(--radius-sm);
  background: var(--primary-light); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
}
.folder-card .folder-icon svg { width: 24px; height: 24px; }
.folder-card h3 { margin-bottom: .25em; font-size: 1.02rem; }
.folder-card .folder-meta { font-size: .82rem; color: var(--ink-soft); }
.folder-card .folder-desc { font-size: .85rem; color: var(--ink-soft); margin-top: .5em; }

.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  color: var(--ink-soft);
}
.empty-state svg { width: 44px; height: 44px; margin: 0 auto 1rem; color: var(--ink-soft); opacity: .6; }

/* ----------------------------------------------------------
   Lista file (file-row)
   ---------------------------------------------------------- */
.file-list { display: flex; flex-direction: column; gap: .7rem; }
.file-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .9rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.file-row .file-icon {
  width: 42px; height: 42px; min-width: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.file-row .file-icon svg { width: 21px; height: 21px; }
.file-row.tipo-pdf .file-icon { background: #fdecec; color: #c0392b; }
.file-row.tipo-video .file-icon { background: var(--primary-light); color: var(--primary-dark); }
.file-row.tipo-altro .file-icon { background: #f1eefc; color: #6c4fc0; }
.file-row .file-info { flex: 1; min-width: 0; }
.file-row .file-name { font-weight: 600; font-size: .94rem; margin-bottom: .15em; word-break: break-word; }
.file-row .file-meta { font-size: .78rem; color: var(--ink-soft); }
.file-row .file-actions { display: flex; gap: .5rem; flex-shrink: 0; }

/* ==========================================================
   AREA ADMIN — sidebar + contenuto
   ========================================================== */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 240px; flex-shrink: 0;
  background: linear-gradient(190deg, #16243a, #0f1a2c);
  color: #cfd9e8;
  padding: 1.5rem 1.1rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  z-index: 40;
}
.admin-sidebar .brand { color: #fff; margin-bottom: 2rem; padding: 0 .4rem; }
.sidebar-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #7f8da3; margin: 1.4rem .5rem .5rem; }
.sidebar-link {
  display: flex; align-items: center; gap: .7em;
  padding: .68em .8em; border-radius: var(--radius-sm);
  color: #cfd9e8; font-size: .88rem; font-weight: 500;
  margin-bottom: .15rem;
}
.sidebar-link svg { width: 18px; height: 18px; opacity: .85; }
.sidebar-link:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.sidebar-link.active { background: var(--primary); color: #fff; }
.sidebar-link.active svg { opacity: 1; }
.sidebar-divider { border-top: 1px solid rgba(255,255,255,.1); margin: 1rem 0; }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.8rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.menu-toggle {
  display: none;
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  width: 38px; height: 38px; align-items: center; justify-content: center; cursor: pointer;
}
.admin-content { padding: 2rem 1.8rem 4rem; max-width: 1180px; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(15, 26, 44, .5);
  z-index: 35;
}

@media (max-width: 900px) {
  .admin-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .admin-sidebar.is-open { transform: translateX(0); }
  .menu-toggle { display: flex; }
  .admin-content { padding: 1.4rem 1rem 3rem; }
  .admin-topbar { padding: .9rem 1rem; }
  .sidebar-overlay.is-visible { display: block; }
}

/* ----------------------------------------------------------
   Stat card (dashboard admin)
   ---------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.4rem; }
.stat-card .stat-label { font-size: .8rem; color: var(--ink-soft); margin-bottom: .5em; }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; color: var(--ink); }
.stat-card .stat-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-light); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; margin-bottom: .9em; }
.stat-card .stat-icon svg { width: 19px; height: 19px; }

/* ----------------------------------------------------------
   Card generica / pannelli form
   ---------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; }
.panel-narrow { max-width: 560px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.3rem; flex-wrap: wrap; }

/* ----------------------------------------------------------
   Tabelle
   ---------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 540px; }
th, td { padding: .85em 1.1em; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); background: #fafbfd; }
tr:last-child td { border-bottom: none; }
td.actions { display: flex; gap: .5rem; }
td.num, th.num { text-align: right; }

footer.app-footer { text-align: center; font-size: .8rem; color: var(--ink-soft); padding: 2rem 1rem; }
