/* =============================================================
   Documenti Riservati — Stylesheet
   ============================================================= */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --primary:        #1e3a5f;
  --primary-light:  #2c4f7c;
  --accent:         #3498db;
  --accent-dark:    #2980b9;
  --danger:         #e74c3c;
  --danger-dark:    #c0392b;
  --success:        #27ae60;
  --warning:        #f39c12;
  --info:           #2980b9;
  --sidebar-bg:     #1a2742;
  --sidebar-width:  240px;
  --white:          #ffffff;
  --bg:             #f0f2f5;
  --card-bg:        #ffffff;
  --text:           #2c3e50;
  --text-light:     #6c757d;
  --border:         #dde3ed;
  --radius:         6px;
  --shadow:         0 2px 8px rgba(0,0,0,.08);
  --shadow-md:      0 4px 16px rgba(0,0,0,.12);
  --font:           system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }
img { max-width: 100%; }
ul { list-style: none; }

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

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  color: #fff;
  font-weight: 700;
  font-size: .875rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  line-height: 1.3;
}
.sidebar-brand svg { flex-shrink: 0; opacity: .9; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav ul { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.75);
  font-size: .875rem;
  transition: background .15s, color .15s;
}
.nav-link svg { flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  margin-top: auto;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: .875rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-meta { flex: 1; overflow: hidden; }
.user-name { font-size: .8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; color: rgba(255,255,255,.55); }
.btn-logout { color: rgba(255,255,255,.5); display: flex; align-items: center; flex-shrink: 0; }
.btn-logout:hover { color: var(--danger); text-decoration: none; }

/* ── Main content ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 28px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.page-title { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.sidebar-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.sidebar-toggle span {
  display: block;
  width: 22px; height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

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

/* ── Flash messages ──────────────────────────────────────────── */
.flash-container { padding: 12px 28px 0; }

.alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 12px;
}
.alert-close {
  background: none; border: none; cursor: pointer; font-size: 1.2rem;
  line-height: 1; opacity: .6; padding: 0 4px;
}
.alert-close:hover { opacity: 1; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning  { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
.alert-info     { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Cards ────────────────────────────────────────────────────── */
/* Il padding vive sulla card stessa: qualunque contenuto (form, alert,
   testo) messo direttamente dentro una .card ha respiro dai bordi per
   default, senza dover ricordare di aggiungere padding pagina per pagina.
   Header, tabelle e barre filtro gestiscono già il proprio padding/bordo e
   devono restare a tutta larghezza (comprese le celle fino al bordo): si
   "riportano a filo" con un margine negativo pari al padding della card. */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  margin: -20px -20px 0;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--primary); }

.card > .table-responsive,
.card > table,
.card > .filter-form,
.card > .doc-grid,
.card > .simple-list {
  margin-left: -20px;
  margin-right: -20px;
}
.card > .table-responsive:last-child,
.card > table:last-child,
.card > .doc-grid:last-child,
.card > .simple-list:last-child {
  margin-bottom: -20px;
}

/* ── Grid / Row ──────────────────────────────────────────────── */
.row { display: flex; gap: 20px; flex-wrap: wrap; }
.col-3 { flex: 0 0 calc(25% - 15px); }
.col-4 { flex: 0 0 calc(33.333% - 14px); }
.col-5 { flex: 0 0 calc(41.667% - 12px); }
.col-7 { flex: 0 0 calc(58.333% - 12px); }
.col-8 { flex: 0 0 calc(66.667% - 7px); }
.col-9 { flex: 0 0 calc(75% - 5px); }

/* ── Stats grid ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--text-light); margin-top: 4px; }
.stat-card-warning .stat-value { color: var(--warning); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  padding: 10px 16px;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-light);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  background: #f8f9fa;
}
.table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-hover tr:hover td { background: #f8f9fb; }
.table-sm th, .table-sm td { padding: 7px 12px; }
.row-disabled td { opacity: .55; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group > label, label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=url],
input[type=color], select, textarea {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52,152,219,.15);
}
select { cursor: pointer; }
textarea { resize: vertical; }
.form-hint { font-size: .75rem; color: var(--text-light); margin-top: 4px; display: block; }
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.form-check input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.form-check label { margin: 0; font-weight: normal; cursor: pointer; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
fieldset.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
fieldset.fieldset legend {
  padding: 0 8px;
  font-weight: 700;
  font-size: .875rem;
  color: var(--primary);
}

/* Eye toggle for password */
.input-eye { position: relative; }
.input-eye input { padding-right: 40px; }
.eye-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-light);
}

/* File drop zone */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s;
  position: relative;
}
.file-drop:hover { border-color: var(--accent); }
.file-drop input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}
.file-drop-label { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text-light); pointer-events: none; }
.file-drop-label svg { color: var(--accent); }
.file-name { color: var(--success); font-weight: 600; font-size: .875rem; margin-top: 8px; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-block { width: 100%; justify-content: center; }
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-light); color: #fff; }
.btn-secondary { background: #e9ecef; color: var(--text); }
.btn-secondary:hover { background: #dee2e6; color: var(--text); }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover   { background: var(--danger-dark); color: #fff; }
.btn-warning   { background: var(--warning);  color: #fff; }
.btn-info      { background: var(--info);     color: #fff; }
.btn-google    { background: #fff; color: #444; border: 1px solid #ddd; }
.btn-google:hover { background: #f8f9fa; color: #333; }
.btn-sm  { padding: 5px 12px; font-size: .8rem; }
.btn-xs  { padding: 3px 8px; font-size: .75rem; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.badge-admin      { background: #1e3a5f; }
.badge-assistente { background: #8e44ad; }
.badge-referente  { background: #16a085; }
.badge-docente    { background: #2980b9; }
.badge-success    { background: var(--success); }
.badge-danger     { background: var(--danger); }
.badge-warning    { background: var(--warning); }
.badge-info       { background: var(--info); }
.badge-secondary  { background: #6c757d; }

/* ── Filter form ─────────────────────────────────────────────── */
.filter-form { padding: 16px 20px; border-bottom: 1px solid var(--border); background: #f8f9fa; }
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filter-row .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

/* ── Checklist scrollabile (es. abbinamento docenti) ──────────── */
.checklist-box {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 12px;
  background: var(--white);
}
.checklist-box .form-check { padding: 6px 0; margin-bottom: 0; border-bottom: 1px solid #f0f2f5; }
.checklist-box .form-check:last-child { border-bottom: none; }
.checklist-box .form-check.is-hidden { display: none; }
.checklist-empty { padding: 12px 0; color: var(--text-light); font-size: .875rem; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; padding: 16px; justify-content: center; flex-wrap: wrap; }
.page-btn {
  min-width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text);
  text-decoration: none;
}
.page-btn:hover  { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Quick actions ───────────────────────────────────────────── */
.quick-actions { display: flex; gap: 16px; flex-wrap: wrap; }
.action-card {
  flex: 0 0 180px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: .875rem;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .15s;
}
.action-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; color: var(--accent); }
.action-card svg { color: var(--accent); }

/* ── Doc grid (fascicolo) ────────────────────────────────────── */
.doc-grid { display: flex; flex-direction: column; }
.doc-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.doc-card:last-child { border-bottom: none; }
.doc-card:hover { background: #f8f9fb; }
.doc-icon { color: var(--text-light); flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-title { font-weight: 600; font-size: .9rem; color: var(--text); }
.doc-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 4px; font-size: .78rem; }
.doc-actions { flex-shrink: 0; }

/* ── Student info card ───────────────────────────────────────── */
.student-info-card { padding: 24px 20px; text-align: center; }
.student-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.student-name { font-weight: 700; font-size: 1rem; }
.student-class { margin-top: 6px; }
.student-notes { font-size: .85rem; text-align: left; color: var(--text-light); }
.alert-info-card { padding: 16px; font-size: .8rem; color: #0c5460; background: #d1ecf1; border-color: #bee5eb; }

/* ── Simple list ─────────────────────────────────────────────── */
.simple-list { padding: 0; }
.simple-list li { padding: 10px 20px; border-bottom: 1px solid var(--border); font-size: .875rem; }
.simple-list li:last-child { border-bottom: none; }

/* ── Student badge (upload) ──────────────────────────────────── */
.student-badge {
  padding: 10px 20px;
  background: #f0f7ff;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}

/* ── Misc ─────────────────────────────────────────────────────── */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-light); }
.text-right   { text-align: right; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 20px; }
.mb-3 { margin-bottom: 12px; }
.p-3  { padding: 12px; }
.p-4  { padding: 20px; }
code  { background: #f0f2f5; padding: 2px 6px; border-radius: 3px; font-size: .85em; }

.breadcrumb { font-size: .875rem; color: var(--text-light); margin-bottom: 16px; }
.breadcrumb a { color: var(--accent); }

/* ── Modal ────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.5);
}
.modal-dialog {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 1.5rem;
  cursor: pointer; line-height: 1; color: var(--text-light);
}

/* ── Login page ────────────────────────────────────────────────── */
.login-body {
  background: linear-gradient(135deg, #1e3a5f 0%, #2c4f7c 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
}
.login-wrapper {
  width: 100%;
  max-width: 420px;
}
.login-card {
  background: var(--white);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 8px 40px rgba(0,0,0,.3);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand svg { color: var(--primary); }
.login-brand h1 { font-size: 1.1rem; margin: 10px 0 4px; color: var(--primary); }
.login-subtitle { font-size: .85rem; color: var(--text-light); }
.login-footer { text-align: center; margin-top: 16px; color: rgba(255,255,255,.6); }
.oauth-section { text-align: center; }
.oauth-info { color: var(--text-light); font-size: .875rem; margin-bottom: 16px; }
.btn-google svg { margin-right: 4px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    z-index: 200;
    transition: left .25s;
  }
  .sidebar.open { left: 0; }
  .sidebar-toggle { display: flex; }
  .main-content { margin-left: 0; }
  .row { flex-direction: column; }
  .col-3, .col-4, .col-5, .col-7, .col-8, .col-9 { flex: 1 1 100%; }
  .content-area { padding: 16px; }
  .filter-row { flex-direction: column; }
}
