/* ============================================================
   Solo ciò che Tailwind non copre: theming FullCalendar,
   gestione display dei modali, spinner, piccoli dettagli.
   ============================================================ */

/* I colori vivono nella palette centralizzata in theme.css (:root channel vars).
   Qui li deriviamo per gli override di FullCalendar e i piccoli componenti. */
:root {
  --brand: rgb(var(--brand-500));
  --brand2: rgb(var(--accent-500));
  --border: rgba(255, 255, 255, 0.10);
}

/* ============================================================
   Componenti riutilizzabili (condivisi da tutte le pagine)
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border-radius: .75rem; padding: .625rem 1rem; font-size: .875rem; font-weight: 600;
  border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05);
  color: #f1f5f9; cursor: pointer; transition: all .15s ease;
}
.btn:hover { background: rgba(255,255,255,.09); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  border: 0; color: #fff;
  background: linear-gradient(135deg, rgb(var(--brand-500)), rgb(var(--accent-500)));
  box-shadow: 0 8px 20px -6px rgb(var(--brand-500) / .4);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-tiny { padding: .375rem .625rem; font-size: .75rem; border-radius: .5rem; }
.btn.loading { opacity: .7; pointer-events: none; }
.card {
  border-radius: 1rem; border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.035); backdrop-filter: blur(12px);
  padding: 1.25rem; box-shadow: 0 10px 30px -10px rgba(0,0,0,.3);
}
.field-input {
  width: 100%; border-radius: .75rem; border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.05); padding: .625rem .875rem; font-size: .875rem; color: #f1f5f9;
}
.field-input::placeholder { color: #64748b; }
.field-input:focus { outline: none; border-color: transparent; box-shadow: 0 0 0 2px rgb(var(--brand-500) / .5); }
.chip {
  display: inline-flex; align-items: center; gap: .5rem; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05);
  padding: .375rem .75rem; font-size: 12.5px; font-weight: 600; color: #94a3b8;
  cursor: pointer; transition: all .15s; user-select: none;
}
.chip:hover { transform: translateY(-1px); }
.chip-on { color: #fff; border-color: rgb(var(--brand-500) / .9); background: rgb(var(--brand-500) / .28); box-shadow: 0 0 0 1px rgb(var(--brand-500) / .5) inset; }
.h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; color: #f1f5f9; }
.muted { color: #94a3b8; }
.metric { border-radius: .5rem; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05); padding: .375rem .625rem; font-size: .75rem; }

/* ---------- Modali: display controllato via id (batte le utility) ---------- */
#eventModal, #authModal, #accountModal {
  display: none;
  align-items: center;
  justify-content: center;
}
#eventModal:not(.hidden),
#authModal:not(.hidden),
#accountModal:not(.hidden) { display: flex; }

#addSourceForm { display: none; }
#addSourceForm:not(.hidden) { display: flex; }

/* ---------- Auth tabs (stato attivo gestito via JS) ---------- */
.auth-tab.active {
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  border-color: transparent;
  color: #fff;
}

/* ---------- Confidence bar (iniettata da JS) ---------- */
#mConfidence i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #34d399);
}

/* ---------- Scrape button loading spinner ---------- */
.btn.loading { opacity: 0.7; pointer-events: none; }
.btn.loading .btn-label::after {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast error ---------- */
#toast.err { border-color: #f87171; }

/* ---------- Status pills ---------- */
.pill { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.ok { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.pill.off { background: rgba(248, 113, 113, 0.15); color: #f87171; }

/* ---------- Custom scrollbar ---------- */
#sourceList::-webkit-scrollbar, .card::-webkit-scrollbar { width: 8px; }
#sourceList::-webkit-scrollbar-thumb, .card::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12); border-radius: 8px;
}

/* ============================================================
   FullCalendar — tema dark premium
   ============================================================ */
#calendar {
  --fc-border-color: var(--border);
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: rgba(255, 255, 255, 0.03);
  --fc-today-bg-color: rgba(99, 102, 241, 0.10);
}
.fc { color: #e2e8f0; }
.fc .fc-toolbar-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number { color: #94a3b8; text-decoration: none; }
/* Toolbar: pulsanti minimali (prev/next/today + Month/Week/List). */
.fc .fc-toolbar.fc-header-toolbar { margin-bottom: 1rem; }
.fc .fc-button-primary {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  text-transform: capitalize;
  font-weight: 500;
  font-size: 12.5px;
  line-height: 1;
  border-radius: 7px;
  padding: 5px 10px;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.fc .fc-button-primary:not(:disabled):hover { background: rgba(255, 255, 255, 0.06); color: #f1f5f9; }
.fc .fc-button .fc-icon { font-size: 1.15em; vertical-align: -1px; }
.fc .fc-button-primary:disabled { opacity: .4; }
/* Vista attiva: tinta brand discreta (niente gradiente pieno). */
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: rgb(var(--brand-500) / .16);
  border-color: rgb(var(--brand-500) / .5);
  color: #fff;
}
.fc .fc-button-primary:focus,
.fc .fc-button-primary:focus-visible { outline: none; box-shadow: 0 0 0 2px rgb(var(--brand-500) / .35); }
/* Gruppo Month/Week/List: angoli uniti, spaziatura pulita. */
.fc .fc-button-group > .fc-button:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.fc .fc-button-group > .fc-button:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.fc .fc-today-button { text-transform: none; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--border); }
.fc-theme-standard .fc-scrollgrid { border-color: var(--border); }
.fc .fc-daygrid-day.fc-day-today { background: var(--fc-today-bg-color); }
/* Eventi: minimali e squadrati (niente arrotondamento né ombra), in linea col resto. */
.fc-daygrid-event, .fc-timegrid-event {
  border: none;
  border-radius: 0;
  padding: 1px 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}
.fc-daygrid-event:hover, .fc-timegrid-event:hover { filter: brightness(1.1); }
/* FullCalendar inietta il suo CSS a runtime (dopo style.css): serve !important
   per battere il suo hover chiaro di default, illeggibile sul tema scuro. */
.fc-list-event:hover td { background: rgba(255, 255, 255, 0.08) !important; }
.fc .fc-list-day-cushion { background: rgba(255, 255, 255, 0.04); }
.fc-list-event-dot { border-color: currentColor; }

/* Eventi molto corroborati: bordo in rilievo (>5 fonti) e massimo rilievo (>=20). */
.fc .fc-event.ev-hot {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6), 0 3px 10px rgba(0, 0, 0, 0.45);
  font-weight: 700;
}
.fc .fc-event.ev-super {
  box-shadow: 0 0 0 2px #fbbf24, 0 0 14px rgba(251, 191, 36, 0.7), 0 4px 12px rgba(0, 0, 0, 0.5);
  font-weight: 800;
}
/* Vista lista: accento a sinistra (il box-shadow su <tr> non rende). */
.fc .fc-list-event.ev-hot td:first-child { box-shadow: inset 4px 0 0 rgba(255, 255, 255, 0.7); }
.fc .fc-list-event.ev-super td:first-child { box-shadow: inset 4px 0 0 #fbbf24; }
.fc .fc-list-event.ev-super td { font-weight: 700; }

/* --- Pagine informative (privacy / cookies) --- */
.policy h2 { margin-top: 1.6rem; margin-bottom: .5rem; font-size: 1.05rem; font-weight: 600; color: #e2e8f0; }
.policy p, .policy li { color: #94a3b8; font-size: 14px; line-height: 1.65; }
.policy p { margin-bottom: .75rem; }
.policy ul { list-style: disc; padding-left: 1.25rem; margin-bottom: .75rem; }
.policy li { margin-bottom: .3rem; }
.policy b, .policy strong { color: #e2e8f0; }
.policy a { color: rgb(96 165 250); text-decoration: underline; }
.policy code { background: rgba(255,255,255,.06); padding: .1rem .35rem; border-radius: .3rem; font-size: 12.5px; color: #cbd5e1; }
.policy .note { border: 1px solid rgba(245,158,11,.35); background: rgba(245,158,11,.08); border-radius: .6rem; padding: .8rem 1rem; font-size: 12.5px; color: #fcd34d; }
.policy table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: 13px; }
.policy th, .policy td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid rgba(255,255,255,.08); vertical-align: top; }
.policy th { color: #cbd5e1; font-weight: 600; }
.policy td { color: #94a3b8; }

/* --- Mappa Leaflet (tema scuro) --- */
.leaflet-top, .leaflet-bottom { z-index: 10 !important; } /* sotto header (z-20) e modali (z-50) */
.leaflet-container { background: #0b1020; font: inherit; }
.leaflet-control-attribution { background: rgba(11,16,32,.75) !important; color: #64748b !important; }
.leaflet-control-attribution a { color: #94a3b8 !important; }
.leaflet-bar a { background: #1e293b !important; color: #e2e8f0 !important; border-color: rgba(255,255,255,.12) !important; }
.leaflet-bar a:hover { background: #334155 !important; }

/* --- Barra scorrevole (ticker) eventi della settimana --- */
.ticker-bar { position: relative; background: #090c15; } /* sfondo opaco: il contenuto sotto non traspare */
.ticker-noise { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; pointer-events: none; }
.ticker { animation: ticker-scroll 120s linear infinite; } /* scorrimento lento */
.ticker-bar:hover .ticker { animation-play-state: paused; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Hint giallo pulsante sotto la select paese (onboarding) */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.55); }
  50%      { box-shadow: 0 0 0 7px rgba(251, 191, 36, 0); }
}
.pulse-hint { animation: pulse-glow 1.8s ease-out infinite; }

/* Evento disdetto (cancelled): resta nel calendario ma spento e barrato */
.fc .fc-event.ev-cancelled { opacity: .45; text-decoration: line-through; }
.fc .fc-list-event.ev-cancelled td { opacity: .55; }
.fc .fc-list-event.ev-cancelled .fc-list-event-title { text-decoration: line-through; }
