/* =============================================================================
   Design system "Prenota" — Unità Pastorale Piove di Sacco
   Fonte: design-guide.md (token, componenti, regole di contrasto, microcopy).
   ========================================================================== */

:root {
  /* --- Brand (dal logo UP) --- */
  --azzurro: #48b8e8; /* identità: logo, stato attivo, focus, dettagli — MAI testo bianco sopra */
  --azzurro-tint: #eaf6fc;
  --azzurro-tint-2: #d3ecf9;

  /* --- Azzurro azione (superfici con testo bianco) --- */
  --azione: #0e76b0;
  --azione-hover: #0a5e8e;
  --azione-press: #084a70;

  /* --- Sidebar / superfici scure --- */
  --nav-bg: #0e3b57;
  --nav-bg-2: #0a2e45;

  /* --- Neutri --- */
  --ink: #1f2d3a;
  --ink-muted: #5b6b78;
  --border: #e4eaf0;
  --surface: #ffffff;
  --app-bg: #f4f8fb;

  /* --- Stati --- */
  --ok-bg: #e7f6ef;
  --ok-fg: #14794f;
  --warn-bg: #fcf0da;
  --warn-fg: #9a5b00;
  --danger-bg: #fbe7e7;
  --danger-fg: #b02328;

  /* --- Tipografia --- */
  --font-display: "Schibsted Grotesk", system-ui, -apple-system, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, -apple-system, sans-serif;

  /* --- Spaziatura / forma --- */
  --space: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(16, 59, 87, 0.06), 0 6px 20px rgba(16, 59, 87, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--app-bg);
  color: var(--ink);
  font: 15px/1.55 var(--font-body);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0 0 4px;
}
h1 {
  font-weight: 600;
  font-size: 24px;
}
h2 {
  font-weight: 600;
  font-size: 18px;
}
p.muted,
.muted {
  color: var(--ink-muted);
}

a {
  color: var(--azione);
}

/* Anello di focus da tastiera, sempre visibile */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--azzurro);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* =============================================================================
   Layout generico (pagine pubbliche: modulo, conferma, risultati)
   ========================================================================== */

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}
.page--wide {
  max-width: 1000px;
}

.public-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  margin-bottom: 28px;
}
.public-header img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
}
.public-header h1 {
  font-size: 22px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

/* =============================================================================
   Shell admin: sidebar + area di lavoro
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--nav-bg);
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  padding: 0 6px;
}
.sidebar__brand img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sidebar__brand span {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.25;
  color: #fff;
}
.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.sidebar__nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.sidebar__nav a.active {
  background: #fff;
  color: var(--azione);
}
.sidebar__cta {
  margin-top: 18px;
}
.sidebar__cta .btn {
  width: 100%;
  justify-content: center;
}
.sidebar__foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar__foot button {
  align-self: flex-start;
}

.sidebar-toggle {
  display: none;
}

.topbar-home {
  display: none;
}

.app-main {
  flex: 1;
  min-width: 0;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-topbar h1 {
  margin: 0;
  flex: 1;
}

.app-content {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 32px 80px;
}

@media (max-width: 860px) {
  .sidebar-toggle {
    display: inline-flex;
  }
  .topbar-home {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--azione);
    text-decoration: none;
    background: var(--azzurro-tint);
    padding: 8px 12px;
    border-radius: 999px;
    white-space: nowrap;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow-card);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(10, 30, 45, 0.4);
    z-index: 30;
  }
  .app-topbar,
  .app-content {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* =============================================================================
   Tab secondaria (Dettagli e campi · Risposte · Impostazioni)
   ========================================================================== */

.form-tabs {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.form-tabs a {
  padding: 0 0 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.form-tabs a:hover {
  color: var(--ink);
}
.form-tabs a.active {
  color: var(--azione);
  border-bottom-color: var(--azione);
}

/* =============================================================================
   Card KPI
   ========================================================================== */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(16, 59, 87, 0.05);
}
.kpi-card__value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  line-height: 1.1;
  color: var(--ink);
}
.kpi-card__label {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
}

/* =============================================================================
   Indicatore di capienza slot — componente firma
   ========================================================================== */

.capacity {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.capacity__bar {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.capacity__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--azzurro);
  transition: width 0.2s ease;
}
.capacity__fill.is-warn {
  background: #e3a63c;
}
.capacity__fill.is-danger {
  background: var(--danger-fg);
}
.capacity__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}
.capacity__chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}
.capacity__chip.is-ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
}
.capacity__chip.is-warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}
.capacity__chip.is-danger {
  background: var(--danger-bg);
  color: var(--danger-fg);
}

/* Selettore slot nel modulo pubblico */
.slot-option {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.slot-option--selected {
  border-color: var(--azzurro);
  background: var(--azzurro-tint);
}
.slot-option--disabled {
  opacity: 0.55;
}
.slot-option input {
  flex-shrink: 0;
  accent-color: var(--azzurro);
}
.slot-option__body {
  flex: 1;
  min-width: 0;
}
.slot-option__label {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

/* =============================================================================
   Form
   ========================================================================== */

label {
  display: block;
  font-weight: 500;
  color: var(--ink-muted);
  margin-bottom: 5px;
  font-size: 13px;
}

.field {
  margin-bottom: 18px;
}
.field .hint {
  color: var(--ink-muted);
  font-size: 12px;
  margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--ink);
  background: var(--surface);
}
textarea {
  resize: vertical;
  min-height: 80px;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--azzurro);
  box-shadow: 0 0 0 3px var(--azzurro-tint-2);
}

.checkbox-row,
.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  margin-bottom: 6px;
}
.checkbox-row label,
.radio-row label {
  margin: 0;
  font-weight: 400;
  color: var(--ink);
}
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--azzurro);
}

/* =============================================================================
   Pulsanti
   ========================================================================== */

button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  background: var(--azione);
  color: #fff;
}
button:hover,
.btn:hover {
  background: var(--azione-hover);
}
button:active,
.btn:active {
  background: var(--azione-press);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--app-bg);
}

.btn-danger {
  background: transparent;
  color: var(--danger-fg);
  border-color: var(--danger-fg);
}
.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-link {
  background: none;
  border: none;
  color: var(--azione);
  padding: 0;
  font-weight: 600;
}
.btn-link:hover {
  background: none;
  text-decoration: underline;
}

/* =============================================================================
   Messaggi di stato
   ========================================================================== */

.error {
  background: var(--danger-bg);
  border: 1px solid #f0c6c6;
  color: var(--danger-fg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}
.success {
  background: var(--ok-bg);
  border: 1px solid #bfe6d1;
  color: var(--ok-fg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-muted);
}
.empty-state .btn,
.empty-state button {
  margin-top: 14px;
}

/* =============================================================================
   Tabella semplice / elenchi
   ========================================================================== */

table.simple {
  width: 100%;
  border-collapse: collapse;
}
table.simple th,
table.simple td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
table.simple th {
  color: var(--ink-muted);
  font-weight: 500;
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.tag--draft {
  color: var(--ink-muted);
  background: var(--border);
}
.tag--published {
  color: var(--ok-fg);
  background: var(--ok-bg);
}
.tag--closed {
  color: #3a4652;
  background: #e7ecf1;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child {
  border-bottom: none;
}

.field-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  background: var(--app-bg);
}
.field-row__body {
  flex: 1;
}
.field-row__actions {
  display: flex;
  gap: 6px;
}
.field-row__actions button {
  padding: 6px 10px;
  font-size: 12px;
}

/* =============================================================================
   Tabulator (griglia risposte)
   ========================================================================== */

.tabulator {
  border: none;
  background: transparent;
  font-family: var(--font-body);
}
.tabulator .tabulator-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tabulator .tabulator-header .tabulator-col {
  background: var(--surface);
  border-right: none;
}
.tabulator .tabulator-col-title {
  font-weight: 500;
  font-size: 13px;
  color: var(--ink-muted);
}
.tabulator .tabulator-row {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tabulator .tabulator-row.tabulator-row-even {
  background: var(--surface);
}
.tabulator .tabulator-row:hover {
  background: var(--azzurro-tint);
}
.tabulator .tabulator-cell {
  font-size: 14px;
  color: var(--ink);
  border-right: none;
}
.tabulator .tabulator-headers .tabulator-header-filter input {
  padding: 5px 8px;
  font-size: 12px;
}
.tabulator-group {
  background: var(--azzurro-tint);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  border-bottom: 1px solid var(--azzurro-tint-2);
}
.tabulator .tabulator-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--ink-muted);
}
