/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 18px;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: #3563e9; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
.site-header {
  background: #1a1a2e;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .03em;
}
.site-title:hover { text-decoration: none; color: #93c5fd; }
.header-nav { display: flex; align-items: center; gap: .75rem; }
.nav-user { font-size: .92rem; color: #fff; }

/* Header admin a 3 colonne */
.header-inner-admin {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
}
.header-nav-admin {
  display: flex;
  align-items: center;
  gap: .75rem;
  justify-content: center;
}

/* Dropdown nav */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-toggle {
  background: #3563e9;
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.nav-dropdown-toggle:hover { background: #5b21b6; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding-top: 6px;
  min-width: 170px;
  z-index: 200;
}
.nav-dropdown-menu-inner {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  overflow: hidden;
}
.nav-dropdown-menu a {
  display: block;
  padding: .65rem 1.1rem;
  color: #1a1a2e;
  font-size: .92rem;
  font-weight: 500;
  white-space: nowrap;
}
.nav-dropdown-menu a:hover {
  background: #f0f4ff;
  text-decoration: none;
  color: #3563e9;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  display: block;
}

/* Header studente a 3 colonne */
.header-inner-studente {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.header-inner-studente .header-nav { justify-self: end; }
.header-studente-info {
  text-align: center;
  line-height: 1.25;
}
.header-studente-nome {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .02em;
}
.header-studente-matricola {
  font-size: .82rem;
  color: rgba(255,255,255,.65);
}

/* ===== Main ===== */
.main-content {
  max-width: 1600px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  flex: 1;
  width: 100%;
}

/* ===== Footer ===== */
.site-footer {
  background: #1a1a2e;
  color: rgba(255,255,255,.5);
  text-align: center;
  padding: .75rem;
  margin-top: auto;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: .45rem .95rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: #7c3aed;
  color: #fff;
  transition: background .15s;
  text-decoration: none;
}
.btn:hover { background: #5b21b6; text-decoration: none; color: #fff; }
.btn-sm { padding: .45rem .95rem; font-size: .9rem; }
.btn-outline { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; }
.btn-outline:hover { background: rgba(255,255,255,.1); }
.btn-danger { background: #f43f5e; }
.btn-danger:hover { background: #e11d48; }
.btn-secondary { background: #0891b2; }
.btn-secondary:hover { background: #0e7490; }
.btn-success { background: #10b981; }
.btn-success:hover { background: #059669; }
.btn-warning { background: #f59e0b; }
.btn-warning:hover { background: #d97706; }

/* ===== Alerts ===== */
.alert {
  padding: .85rem 1.1rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  font-size: .92rem;
}
.alert-success { background: #dcfce7; color: #166534; border-left: 4px solid #16a34a; }
.alert-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; }

/* ===== Cards ===== */
.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid #e5e7eb;
}
.card-title { font-size: 1.15rem; font-weight: 700; }

/* ===== Page header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { padding: .85rem 1rem; text-align: left; }
th { background: #f8fafc; font-weight: 700; border-bottom: 2px solid #e5e7eb; font-size: 1rem; }
tr:not(:last-child) td { border-bottom: 1px solid #f1f5f9; }
tr:hover td { background: #f8fafc; }
.actions { white-space: nowrap; display: flex; gap: .4rem; flex-wrap: wrap; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: #374151;
}
.form-control {
  width: 100%;
  padding: .55rem .8rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: #3563e9;
  box-shadow: 0 0 0 3px rgba(53,99,233,.15);
}
textarea.form-control { resize: vertical; min-height: 120px; }
.form-hint { font-size: .78rem; color: #6b7280; margin-top: .3rem; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

/* ===== Login ===== */
.login-wrap {
  max-width: 400px;
  margin: 4rem auto;
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo h1 { font-size: 1.6rem; }

/* ===== Domanda box ===== */
.domanda-box {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-left: 4px solid #3563e9;
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}
.domanda-box .domanda-num {
  font-size: .78rem;
  color: #3563e9;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .35rem;
}
.domanda-box .domanda-testo {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: .75rem;
  line-height: 1.5;
  color: #111827;
}
/* Testo introduttivo dentro il domanda-box (anteprima import) */
.domanda-box .import-testo-intro {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  padding: .65rem .9rem;
  margin-bottom: .85rem;
  font-size: .88rem;
  color: #78350f;
  line-height: 1.55;
}
.domanda-box .import-testo-intro-body {
  white-space: pre-wrap;
}
.domanda-box .import-testo-intro-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #d97706;
  margin-bottom: .3rem;
}
/* Risposte */
.risposta-item {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .3rem .5rem;
  border-radius: 5px;
  font-size: .9rem;
  margin-bottom: .2rem;
}
.risposta-item .risposta-lettera {
  font-weight: 700;
  font-size: .82rem;
  min-width: 1.4rem;
  text-align: center;
  background: #f1f5f9;
  color: #475569;
  border-radius: 4px;
  padding: .05rem .3rem;
  flex-shrink: 0;
}
.risposta-item.corretta {
  background: #f0fdf4;
  color: #166534;
  font-weight: 600;
}
.risposta-item.corretta .risposta-lettera {
  background: #dcfce7;
  color: #166534;
}
.risposta-item .badge-corretta {
  font-size: .68rem;
  background: #dcfce7;
  color: #166534;
  border-radius: 4px;
  padding: .1rem .4rem;
  font-weight: 700;
  flex-shrink: 0;
}
.domanda-actions {
  margin-top: .75rem;
  padding-top: .6rem;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: .4rem;
}

/* ===== Import textarea ===== */
.haic-preview { font-family: monospace; font-size: .85rem; }

/* ===== Badge ===== */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
}
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* ===== Breadcrumb ===== */
.breadcrumb {
  font-size: .9rem;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 1.25rem;
  padding: .6rem 1rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: .1rem;
}
.breadcrumb a { color: #3563e9; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 .3rem; color: #d1d5db; font-size: 1rem; }

/* ===== Print styles ===== */
@media print {
  body { background: #fff; font-family: 'Times New Roman', serif; }
  .no-print { display: none !important; }
  .site-header, .site-footer { display: none; }
  .main-content { margin: 0; padding: 0; max-width: 100%; }
  .card { box-shadow: none; border: none; padding: 0; }
  .domanda-box { border: none; padding: .3rem 0; page-break-inside: avoid; }
  .btn { display: none; }
}
