@import url("../../assets/css/native-select.css?v=20261005a");

* { box-sizing: border-box; }

:root{
  --app-visual-viewport-height: 100vh;
  --app-visual-viewport-offset-top: 0px;
}

@supports (height: 100dvh){
  :root{
    --app-visual-viewport-height: 100dvh;
  }
}

html{
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  /* Il clipping orizzontale resta su html: combinare hidden/visible sui due assi rende body scroll-container in Chrome. */
  overflow: visible;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

html{
  color-scheme: light;
}

html.modal-open,
body.modal-open{
  overscroll-behavior: none;
}

:root{
  --popover-radius: 12px;
  --popover-font-size: 14px;
  --menu-dots-font-size: 22px;
  --menu-dots-hit-size: 22px;
}

html.pwa-standalone{
  --popover-font-size: 12px;
  --menu-dots-font-size: 20px;
  --menu-dots-hit-size: 20px;
}

@media (max-width: 680px){
  :root{
    --popover-font-size: 12px;
    --menu-dots-font-size: 20px;
    --menu-dots-hit-size: 20px;
  }
}

.pwa-splash {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(15, 156, 167, 0.22), transparent 42%),
    linear-gradient(180deg, #f8fbfd 0%, #eef6f8 100%);
  z-index: 2147483600;
  opacity: 1;
  transition: opacity .25s ease, visibility .25s ease;
}

.pwa-splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.pwa-splash-logo {
  width: min(168px, 42vw);
  height: auto;
  filter: drop-shadow(0 12px 24px rgba(15, 23, 42, 0.14));
}

.pwa-splash-title {
  font-family: "Nunito", "Avenir Next Rounded", "Segoe UI Rounded", "Trebuchet MS", system-ui, sans-serif;
  font-size: clamp(1.7rem, 2.8vw, 2.35rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  text-align: center;
  background: linear-gradient(90deg, #0f9ca7 0%, #1ea78f 45%, #5cbf74 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 10px 30px rgba(15, 156, 167, 0.14);
}

.pwa-splash-loader {
  width: min(240px, 60vw);
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.08);
}

.pwa-splash-loader::before {
  content: "";
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f9ca7 0%, #5cbf74 100%);
  animation: pwaSplashLoad 1.15s ease-in-out infinite;
}

@keyframes pwaSplashLoad {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(360%); }
}

html.pwa-standalone .pwa-splash {
  display: flex;
}

html.pwa-standalone #publicHeader,
html.pwa-standalone #site-drawer {
  display: none !important;
}

html.pwa-ready .pwa-splash {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.app {
  max-width: 1000px;
  margin: 32px auto;
  padding:
    max(16px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
}
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  margin-bottom: 16px;
}

.scroll-reveal-card {
  --scroll-reveal-y: -16px;
  opacity: 1;
  transform: none;
  transition: none;
  transition-delay: 0ms;
  will-change: auto;
}

.scroll-reveal-card[data-scroll-direction="up"] {
  --scroll-reveal-y: 16px;
}

.scroll-reveal-card.is-visible {
  opacity: 1;
  transform: none;
  transition-delay: 140ms;
}

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, select {
  background: var(--field-bg);
  color: var(--field-text);
  border: 1px solid var(--field-border);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 16px;
  width: 100%;
  color-scheme: light;
}


input::placeholder,
textarea::placeholder {
  color: var(--field-placeholder);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--field-focus);
}

input[type="datetime-local"]{
  display:block;
  width:100%;
  max-width:100%;
  min-width:0;
  inline-size:100%;
}
textarea { min-height: 80px; resize: vertical; }

.pull-refresh-indicator{
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: 50%;
  z-index: 11000;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% + var(--pull-distance, 0px)));
  transition: opacity .16s ease, transform .16s ease;
}

.pull-refresh-indicator.visible{
  opacity: 1;
}

.pull-refresh-indicator.ready{
  background: rgba(240, 253, 244, .98);
  border-color: rgba(34, 197, 94, .25);
}

.pull-refresh-indicator.refreshing{
  opacity: 1;
}

.pull-refresh-spinner{
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 0.14);
  border-top-color: #0f9ca7;
  animation: sisPullRefreshSpin .85s linear infinite;
}

@keyframes sisPullRefreshSpin {
  to { transform: rotate(360deg); }
}

.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; }

/* === Tema scuro: base layout + form === */
html.theme-dark body {
  background: var(--bg);
  color: var(--text);
}

html.theme-dark {
  color-scheme: dark;
}

html.theme-dark .pull-refresh-indicator{
  background: rgba(15, 23, 42, .96);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
}

html.theme-dark .pull-refresh-indicator.ready{
  background: rgba(20, 83, 45, .94);
  border-color: rgba(74, 222, 128, .26);
}

html.theme-dark .pull-refresh-spinner{
  border-color: rgba(226, 232, 240, 0.18);
  border-top-color: #5eead4;
}

@media (max-width: 900px){
  :root{
    --popover-font-size: 13px;
  }
}

html.theme-dark .pwa-splash {
  background:
    radial-gradient(circle at top, rgba(15, 156, 167, 0.18), transparent 40%),
    linear-gradient(180deg, #020617 0%, #0f172a 100%);
}

html.theme-dark .pwa-splash-loader {
  background: rgba(255,255,255,0.12);
}

html.theme-dark .pwa-splash-title {
  text-shadow: 0 12px 30px rgba(15, 156, 167, 0.2);
}

html.theme-dark .page,
html.theme-dark .tab-content,
html.theme-dark .card,
html.theme-dark .card-section {
  background: var(--card);
  border-color: var(--field-border);
}

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="date"],
html.theme-dark input[type="time"],
html.theme-dark input[type="datetime-local"],
html.theme-dark textarea,
html.theme-dark select {
  background: var(--field-bg);
  color: var(--field-text);
  border-color: var(--field-border);
  color-scheme: dark;
}



html.theme-dark input::placeholder,
html.theme-dark textarea::placeholder {
  color: var(--field-placeholder);
}

html.theme-dark p,
html.theme-dark label,
html.theme-dark legend,
html.theme-dark th,
html.theme-dark td {
  color: #e5e7eb;
}

html.theme-dark .info,
html.theme-dark .muted,
html.theme-dark .school-label {
  color: #cbd5e1;
}

html.theme-dark fieldset,
html.theme-dark hr,
html.theme-dark table,
html.theme-dark th,
html.theme-dark td {
  border-color: #475569;
}


/* Icona calendario visibile nel tema scuro */
html.theme-dark input[type="date"],
html.theme-dark input[type="time"],
html.theme-dark input[type="datetime-local"] {
  /* mantieni stile di base */
  background-color: var(--field-bg);
  color: var(--field-text);
  border-color: var(--field-border);

  /* 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="date"]::-webkit-calendar-picker-indicator,
html.theme-dark input[type="time"]::-webkit-calendar-picker-indicator,
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;
}

html.theme-dark .appointment-picker-shell{
  background:#020617;
  border-color:#4b5563;
}

html.theme-dark .appointment-time-select-shell{
  background:#020617;
  border-color:#4b5563;
}

html.theme-dark .appointment-picker-display{
  color:#e5e7eb;
}

html.theme-dark .appointment-picker-display.is-placeholder{
  color:#94a3b8;
}

html.theme-dark .appointment-picker-icon--calendar{
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23e5e7eb' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='4.5' width='17' height='16' rx='2.5'/%3E%3Cpath d='M8 2.5v4M16 2.5v4M3.5 10.5h17'/%3E%3C/svg%3E");
}

html.theme-dark .appointment-picker-icon--clock{
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23e5e7eb' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M12 7.5v4.8l3.1 1.9'/%3E%3C/svg%3E");
}

html.theme-dark .appointment-time-select{
  color:#e5e7eb;
}

html.theme-dark #addForm .appointment-field-invalid{
  border-color:#f87171 !important;
  box-shadow:0 0 0 3px rgba(248, 113, 113, .22) !important;
}

html.theme-dark #addForm .appointment-field-invalid:focus,
html.theme-dark #addForm .appointment-field-invalid:focus-within{
  border-color:#f87171 !important;
  box-shadow:0 0 0 4px rgba(248, 113, 113, .28) !important;
}

/* ===== Brand Header (full width) ===== */
.brand-header {
  position: sticky;
  top: 0;
  z-index: 20000;
  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::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: max(96px, env(safe-area-inset-top, 0px));
  background: var(--brand);
  pointer-events: none;
}


.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);
}

html.pwa-standalone .brand {
  cursor: pointer;
}

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

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

html.pwa-standalone body {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html.pwa-standalone .brand-header .brand-container {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: max(10px, env(safe-area-inset-top, 0px));
}

.pwa-refresh-indicator {
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 19990;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(203, 213, 225, 0.95);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
  transform: translate(-50%, calc(-100% - 10px));
  opacity: 0;
  pointer-events: none;
  transition: transform 180ms ease, opacity 180ms ease;
}

.pwa-refresh-indicator.is-visible {
  opacity: 1;
}

.pwa-refresh-indicator.is-loading {
  opacity: 1;
}

.pwa-refresh-spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2.5px solid rgba(15, 156, 167, 0.22);
  border-top-color: #0f9ca7;
  animation: pwaRefreshSpin .85s linear infinite;
}

.pwa-refresh-indicator.is-ready .pwa-refresh-spinner {
  border-top-color: #16a34a;
}

@keyframes pwaRefreshSpin {
  to {
    transform: rotate(360deg);
  }
}

html.theme-dark .pwa-refresh-indicator {
  background: rgba(15, 23, 42, 0.96);
  border-color: rgba(71, 85, 105, 0.95);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.5);
}

/* Accessibilità: riduci/annulla animazioni se richiesto dall’utente */
@media (prefers-reduced-motion: reduce){
  .brand-header, .brand-header .brand-container, .brand-mark, .brand-text, .scroll-reveal-card {
    opacity: 1 !important;
    transform: none !important;
    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; }
}

@media (max-width: 680px){
  input, textarea, select {
    font-size: 16px;
  }

  .app {
    margin: 18px auto;
    padding:
      max(12px, env(safe-area-inset-top, 0px))
      max(12px, env(safe-area-inset-right, 0px))
      max(16px, env(safe-area-inset-bottom, 0px))
      max(12px, env(safe-area-inset-left, 0px));
  }
}

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