/* Publiflow — custom styles layered on Tailwind CDN */

:root {
  --teal:        #006D8C;
  --teal-dark:   #004F66;
  --teal-light:  #E6F3F6;
  --teal-mid:    #0891B2;   /* cyan-600 approx */
  --coral:       #E5523F;
  --ink:         #0B1014;
  --paper:       #FAF7F2;
  --paper-2:     #F0EBE2;
  --muted:       #6B7480;
  --sun:         #F2C84B;
}

[x-cloak] { display: none !important; }

/* ── Body ──────────────────────────────────────────────────────────────── */
/* iOS: blocca l'auto-inflazione del testo al cambio orientamento (landscape→portrait). */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100svh;
}

/* ── Brand button ──────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--teal);
  color: #fff;
  border-radius: 0.75rem;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn-primary:hover  { background: var(--teal-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
  background: white;
  color: var(--teal);
  border: 1.5px solid var(--teal);
  border-radius: 0.75rem;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  transition: background 0.15s;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--teal-light); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  transition: background 0.15s;
}
.btn-ghost:hover { background: var(--paper-2); }

/* ── Form inputs ────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid #D1D5DB;
  border-radius: 0.75rem;
  background: white;
  font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,109,140,0.12);
}
.input.error { border-color: var(--coral); }
.input.input-sm {
  padding: 0.45rem 0.625rem;
  font-size: 0.8125rem;
  min-width: 0;
  box-sizing: border-box;
}
input[type="date"] {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  padding: 1.25rem;
}

/* ── Nav (bottom — mobile-first) ────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #E5E7EB;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 40;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.25rem;
  cursor: pointer;
  gap: 0.25rem;
  font-size: 0.65rem;
  color: var(--muted);
  transition: color 0.15s;
  border: none;
  background: transparent;
}
.bottom-nav-item.active { color: var(--teal); }
.bottom-nav-item svg { width: 1.4rem; height: 1.4rem; }

/* ── Pending banner ─────────────────────────────────────────────────────── */
.pending-banner {
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
  border: 1.5px solid #FCD34D;
  border-radius: 0.875rem;
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: opacity 0.15s;
}
.pending-banner:hover { opacity: 0.9; }
.pending-banner .icon { font-size: 1.4rem; }

/* ── Calendar grid ──────────────────────────────────────────────────────── */
/* Le celle sono quadrate e larghe 1/7 del contenitore: senza un tetto, in orizzontale
   diventano enormi (7 × ~95px). Il cap è puramente estetico e vincola solo il landscape
   (in verticale la griglia è già più stretta di 420px).
   NB: non c'entra col bug "il calendario resta ingrandito dopo la rotazione", che è il
   mancato ricalcolo di `aspect-ratio` da parte di WebKit — vedi lo script in <head>. */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  max-width: 420px;
  margin-inline: auto;
}
.cal-day-header {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.25rem 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.1s, transform 0.1s;
  line-height: 1.2;
}
.cal-day:hover:not(.weekend):not(.festivo) { transform: scale(1.08); }
.cal-day.empty { visibility: hidden; }
/* Festivo: riempimento a linee oblique (come DipendentInCloud) — nessuna richiesta ferie.
   La tinta (--festivo-line) cambia per tipo; il pattern è condiviso. */
.cal-day.festivo {
  --festivo-line: rgba(100, 116, 139, 0.45);   /* nazionale: grigio-ardesia */
  --festivo-bg:   #F3F4F6;
  cursor: default;
  background-color: var(--festivo-bg);
  background-image: repeating-linear-gradient(
    -45deg,
    var(--festivo-line) 0, var(--festivo-line) 1.5px,
    transparent 1.5px, transparent 6px
  );
}
.cal-day.festivo.festivo-patrono  { --festivo-line: rgba(37, 99, 235, 0.50);  --festivo-bg: #EFF6FF; } /* patrono: blu */
.cal-day.festivo.festivo-chiusura { --festivo-line: rgba(217, 119, 6, 0.50);  --festivo-bg: #FFFBEB; } /* chiusura/ponte: ambra */
.cal-day.festivo > span:first-of-type { text-decoration: line-through; opacity: 0.8; }

/* Swatch di legenda: stesso pattern, tinta per tipo */
.cal-legend-festivo {
  --festivo-line: rgba(100, 116, 139, 0.60);
  --festivo-bg:   #F3F4F6;
  background-color: var(--festivo-bg);
  background-image: repeating-linear-gradient(
    -45deg,
    var(--festivo-line) 0, var(--festivo-line) 1px,
    transparent 1px, transparent 3px
  );
}
.cal-legend-festivo.festivo-patrono  { --festivo-line: rgba(37, 99, 235, 0.65); --festivo-bg: #EFF6FF; }
.cal-legend-festivo.festivo-chiusura { --festivo-line: rgba(217, 119, 6, 0.65); --festivo-bg: #FFFBEB; }

/* ── Blocking modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 1rem; }
}
.modal-box {
  background: white;
  border-radius: 1.25rem 1.25rem 0 0;
  padding: 1.5rem;
  width: 100%;
  max-height: 90svh;
  overflow-y: auto;
}
@media (min-width: 640px) {
  .modal-box {
    border-radius: 1.25rem;
    max-width: 36rem;
    max-height: 85svh;
  }
}

/* ── KPI cards (admin) ──────────────────────────────────────────────────── */
.kpi-card {
  background: white;
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.kpi-card .kpi-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--teal);
}
.kpi-card .kpi-label {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 5rem);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.25rem;
  border-radius: 2rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: white;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  white-space: nowrap;
}
.toast.ok    { background: #10B981; }
.toast.error { background: #EF4444; }
.toast.info  { background: var(--teal); }

/* ── Offline banner ─────────────────────────────────────────────────────── */
.offline-bar {
  background: #374151;
  color: white;
  text-align: center;
  font-size: 0.8rem;
  padding: 0.4rem;
  position: sticky;
  top: 0;
  z-index: 60;
}

/* ── Spinner ────────────────────────────────────────────────────────────── */
.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner.dark {
  border-color: rgba(0,109,140,0.2);
  border-top-color: var(--teal);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Custom color utilities (not in Tailwind CDN default palette) ───────── */
.bg-teal     { background-color: var(--teal) !important; }
.text-teal   { color: var(--teal) !important; }
.border-teal { border-color: var(--teal) !important; }

/* ── Segmented control ──────────────────────────────────────────────────── */
.seg-wrap {
  background: white;
  border-bottom: 1px solid #F3F4F6;
  padding: 0.6rem 1rem;
}
.seg-control {
  display: flex;
  background: var(--paper-2);
  border-radius: 0.875rem;
  padding: 0.25rem;
  gap: 0;
  position: relative;
  max-width: 20rem;
  margin: 0 auto;
}
.seg-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  border-radius: 0.625rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
  position: relative;
  z-index: 1;
}
.seg-btn.active { color: var(--teal); }
.seg-btn svg { width: 1rem; height: 1rem; transition: transform 0.2s; }
.seg-btn.active svg { transform: scale(1.1); }
.seg-pill {
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
  height: calc(100% - 0.5rem);
  width: calc(50% - 0.25rem);
  background: white;
  border-radius: 0.625rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none;
}
.seg-pill.right { transform: translateX(100%); }

/* ── Timbra ─────────────────────────────────────────────────────────────── */
.timbra-hero {
  border-radius: 1.5rem;
  padding: 1.1rem 1.5rem;
  text-align: center;
  transition: background 0.4s, box-shadow 0.4s;
}
.timbra-hero.dentro {
  background: linear-gradient(145deg, var(--teal-dark) 0%, var(--teal) 60%, #0891B2 100%);
  box-shadow: 0 8px 32px rgba(0,109,140,0.35);
  color: white;
}
.timbra-hero.fuori {
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  color: var(--ink);
}
.timbra-clock {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.timbra-status-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  display: inline-block;
}
.timbra-status-dot.active {
  background: #4ADE80;
  box-shadow: 0 0 0 0 rgba(74,222,128,0.6);
  animation: pulse-dot 2s ease-in-out infinite;
}
.timbra-status-dot.inactive { background: #9CA3AF; }

@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0   rgba(74,222,128,0.6); }
  50%  { box-shadow: 0 0 0 8px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0   rgba(74,222,128,0); }
}

.btn-entra {
  width: 100%;
  padding: 1.1rem;
  border-radius: 1.25rem;
  border: none;
  cursor: pointer;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
  background: linear-gradient(135deg, #059669, #10B981);
  color: white;
  box-shadow: 0 4px 16px rgba(16,185,129,0.35);
}
.btn-entra:hover  { background: linear-gradient(135deg, #047857, #059669); }
.btn-entra:active { transform: scale(0.97); box-shadow: 0 2px 8px rgba(16,185,129,0.25); }

.btn-esci {
  width: 100%;
  padding: 1.1rem;
  border-radius: 1.25rem;
  border: none;
  cursor: pointer;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
  background: linear-gradient(135deg, #DC2626, var(--coral));
  color: white;
  box-shadow: 0 4px 16px rgba(229,82,63,0.35);
}
.btn-esci:hover  { background: linear-gradient(135deg, #B91C1C, #DC2626); }
.btn-esci:active { transform: scale(0.97); box-shadow: 0 2px 8px rgba(229,82,63,0.25); }

.btn-entra:disabled, .btn-esci:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ── Status badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-pending  { background: #FEF3C7; color: #92400E; }
.badge-ok       { background: #D1FAE5; color: #064E3B; }
.badge-submitted{ background: #DBEAFE; color: #1E3A8A; }
.badge-approved { background: #D1FAE5; color: #064E3B; }
.badge-rejected { background: #FEE2E2; color: #7F1D1D; }

/* ── Admin desktop shell (sidebar + master-detail, lg: 1024px+ only) ────── */
.admin-sidebar {
  width: 15rem;
  background: white;
  border-right: 1px solid #E5E7EB;
  padding: 1rem 0.75rem;
  gap: 0.25rem;
}
.admin-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.admin-sidebar-link:hover { background: var(--paper-2); }
.admin-sidebar-link.active { background: var(--teal-light); color: var(--teal); font-weight: 600; }
.admin-sidebar-link svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }

.list-row-selected { background: var(--teal-light) !important; border-left: 3px solid var(--teal); }

.detail-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 16rem;
  color: var(--muted);
  text-align: center;
  gap: 0.5rem;
}

/* Leaflet: neutralizza il reset img{max-width:100%} di Tailwind Preflight (rompe
   marker/tile se non isolato) e isola lo stacking context dai modali/toast dell'app. */
.leaflet-container img, .leaflet-container svg { max-width: none !important; }
.timbra-map-wrap {
  position: relative;
  z-index: 0;
  height: 18rem;
  border-radius: 1rem;
  overflow: hidden;
}

/* ── Prevent iOS Safari zoom on input focus (font-size must be ≥ 16px) ── */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  font-size: max(16px, 1em);
}
