* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: #111827;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1000px; margin: 32px auto; padding: 16px; }
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  margin-bottom: 16px;
}
h1, h2, h3 { margin: 0 0 12px 0; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

input, textarea {
  border: 1px solid #e6e9ee;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 14px;
  width: 100%;
}
textarea { min-height: 80px; resize: vertical; }

.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

.error { color: var(--danger); margin-top: 8px; }
.info  { color: var(--muted);  margin-top: 8px; }

#addForm { margin-bottom: 30px; }
#studenteNome { margin-top: 12px; }

/* === Tema scuro: base layout + form === */
html.theme-dark body {
  background: #020617;
  color: #e5e7eb;
}

html.theme-dark .page,
html.theme-dark .tab-content,
html.theme-dark .card,
html.theme-dark .card-section {
  background: #111827;
  border-color: #4b5563;
}

html.theme-dark h1,
html.theme-dark h2,
html.theme-dark h3,
html.theme-dark h4,
html.theme-dark h5 {
  color: #f9fafb;
}

/* input, textarea, select */
html.theme-dark input[type="text"],
html.theme-dark input[type="email"],
html.theme-dark input[type="password"],
html.theme-dark input[type="search"],
html.theme-dark input[type="datetime-local"],
html.theme-dark textarea,
html.theme-dark select {
  background: #020617;
  color: #e5e7eb;
  border-color: #4b5563;
}

html.theme-dark input::placeholder,
html.theme-dark textarea::placeholder {
  color: #9ca3af;
}

html.theme-dark input::placeholder,
html.theme-dark textarea::placeholder {
  color: #9ca3af;
}

/* Icona calendario visibile nel tema scuro */
html.theme-dark input[type="datetime-local"] {
  /* mantieni stile di base */
  background-color: #020617;
  color: #e5e7eb;
  border-color: #4b5563;

  /* suggerisce al browser di usare popup scuro dove possibile */
  color-scheme: dark;
}

/* Usiamo il pulsante nativo per aprire il calendario,
   ma con un'icona chiara sopra */
html.theme-dark input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23e5e7eb' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='4.5' width='17' height='16' rx='2.5'/%3E%3Cpath d='M9 2.5v4M15 2.5v4M3.5 10.5h17'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;

  /* nascondo eventuali dettagli grafici originali, ma NON il pulsante */
  color: transparent;
  opacity: 1;
}

/* ===== Brand Header (full width) ===== */
.brand-header {
  position: sticky;
  top: 0;
  z-index: 1200;
  background: var(--brand);
  color: var(--brand-ink);
  width: 100%;
  box-shadow: 0 1px 0 rgba(0,0,0,.06);
  transition: box-shadow .18s ease;
}

/* ===== Brand Header (full width) ===== */
.brand-header {
  position: sticky;
  top: 0;
  z-index: 1200;
  background: var(--brand);
  color: var(--brand-ink);
  width: 100%;
  box-shadow: 0 1px 0 rgba(0,0,0,.06);
  transition: box-shadow .18s ease;
}

.brand-header .brand-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: padding .18s ease;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  height: 56px;
  width: auto;
  flex: 0 0 auto;
  /* ombra leggera sotto il logo */
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.10));
  transition: height .18s ease;
}

.brand-text {
  font-weight: 800;
  font-size: clamp(20px, 3.2vw, 30px);
  line-height: 1;
  letter-spacing: .2px;
  color: var(--brand-ink);
  transition: font-size .18s ease;
}

/* Pulsante cambio tema (chiaro/scuro) */
.theme-toggle {
  border: 0;
  margin-left: 12px;
  background: rgba(15, 23, 42, 0.08);
  color: #111827;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: background .18s ease, transform .12s ease;
}

.theme-toggle:hover {
  background: rgba(15, 23, 42, 0.14);
}

.theme-toggle:active {
  transform: translateY(1px);
}

/* Variante in tema scuro */
html.theme-dark .theme-toggle {
  background: rgba(15, 23, 42, 0.7);
  color: #facc15;
}

html.theme-dark .brand-header {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.9);
}

/* Stato compattato quando si scorre */
.brand-header.shrink {
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.brand-header.shrink .brand-container { padding: 6px 16px; }
.brand-header.shrink .brand-mark { height: 44px; }
.brand-header.shrink .brand-text { font-size: clamp(18px, 2.6vw, 24px); }

/* Quando l'header è shrink, rimpicciolisci anche il toggle del tema */
.brand-header.shrink .theme-toggle {
  width: 26px;
  height: 26px;
  font-size: 14px;
}

/* Accessibilità: riduci/annulla animazioni se richiesto dall’utente */
@media (prefers-reduced-motion: reduce){
  .brand-header, .brand-header .brand-container, .brand-mark, .brand-text {
    transition: none !important;
  }
}

/* Responsivo header */
@media (max-width: 520px){
  .brand-header .brand-container { padding: 10px 14px; }
  .brand-mark  { height: 44px; }
  .brand-text  { font-size: 20px; }
}

/* Utilità */
.hidden { display: none !important; }
.school-label { font-size: 13px; color: var(--muted); padding: 6px 10px; display: inline-block; }
.school-selector {
  padding: 2px 4px; font-size: 10px; border-radius: 6px; background: #fff;
  border: 1px solid #e6e9ee; max-width: 100%; cursor: pointer;
}
