
/* === TurniX Enterprise UI v3 === */
/* Local/system fonts only (no Google): Segoe UI stack */
:root{}
body{
  font-family: "Segoe UI Variable","Segoe UI","Helvetica Neue",Arial,system-ui,-apple-system,Roboto,sans-serif;
}

/* Theme palettes */
body[data-theme="dark"]{
  --bg: #0b0e14;
  --panel: #121a2a;
  --text: #0; /* placeholder */
}
/* Using explicit variables blocks for clarity */
body[data-theme="dark"]{
  --text: #eaf0f7;
  --muted: #c1c7d0;
  --primary: #3b82f6;
  --primary-strong: #2563eb;
  --danger: #dc2626;
  --warn: #f59e0b;
  --success: #16a34a;
  --border: rgba(255,255,255,.12);
  --shadow: 0 8px 30px rgba(0,0,0,.45);
}
body[data-theme="light"]{
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --danger: #b91c1c;
  --warn: #d97706;
  --success: #15803d;
  --border: rgba(15,23,42,.12);
  --shadow: 0 6px 20px rgba(2,6,23,.08);
}

html, body{
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  transition: background .25s ease, color .25s ease;
}

/* Panels / cards */
.panel, .card, .box, .content, .content-wrapper{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* Top bar */
.top-bar{
  position: sticky; top: 0; z-index: 1030;
  display:flex; align-items:center; justify-content:space-between;
  padding: 10px 14px;
  background: color-mix(in hsl, var(--panel) 92%, var(--bg));
  border-bottom: 1px solid color-mix(in hsl, var(--border) 100%, transparent);
  box-shadow: var(--shadow);
}
.top-bar > div:first-child{ font-weight: 700; font-size: 1.05rem; }

/* Buttons */
.btn-link, .btn-reset, .btn, .button{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 12px; border-radius: 12px;
  border:1px solid color-mix(in hsl, var(--border) 100%, transparent);
  background: color-mix(in hsl, var(--panel) 92%, var(--bg));
  color: var(--text) !important; text-decoration:none; font-weight:600;
  box-shadow: 0 2px 10px color-mix(in hsl, var(--shadow) 40%, transparent);
  transition: transform .07s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
  cursor: pointer;
}
.btn-link:hover, .btn-reset:hover, .btn:hover, .button:hover{
  transform: translateY(-1px);
  box-shadow: 0 8px 18px color-mix(in hsl, var(--shadow) 60%, transparent);
  text-decoration:none;
}
.btn-link:focus-visible, .btn:focus-visible, .button:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in hsl, var(--primary) 40%, transparent);
}
/* Variants */
.btn-primary{ background: linear-gradient(165deg, var(--primary), var(--primary-strong)); border-color: transparent; color:#fff !important; }
.btn-danger { background: linear-gradient(165deg, var(--danger), color-mix(in hsl, var(--danger) 85%, black)); border-color: transparent; color:#fff !important; }
.btn-warn   { background: linear-gradient(165deg, var(--warn), color-mix(in hsl, var(--warn) 85%, black)); border-color: transparent; color:#111 !important; }
.btn-success{ background: linear-gradient(165deg, var(--success), color-mix(in hsl, var(--success) 85%, black)); border-color: transparent; color:#fff !important; }

/* Links */
a{ color: var(--primary); font-weight: 600; }
a:hover{ text-decoration: underline; }

/* Tables */
table{ width:100%; border-collapse: separate !important; border-spacing:0; overflow:hidden; border-radius:12px; background: color-mix(in hsl, var(--panel) 94%, var(--bg)); }
thead th{ background: color-mix(in hsl, var(--primary) 16%, var(--panel)); color: var(--text); font-weight: 800; }
tbody tr{ border-bottom: 1px solid var(--border); }
tbody tr:hover{ background: color-mix(in hsl, var(--primary) 10%, var(--panel)); }
td, th{ padding: 12px 14px; color: var(--text); }

/* FullCalendar: readable titles & borders in both themes */
.fc .fc-toolbar-title{ color: var(--text) !important; text-transform: lowercase; letter-spacing:.2px; }
.fc .fc-button-primary{ background: linear-gradient(165deg, var(--primary), var(--primary-strong)); border:none; }
.fc .fc-button-primary:not(:disabled):hover{ filter: brightness(1.05); }
.fc-theme-standard .fc-scrollgrid, .fc-theme-standard td, .fc-theme-standard th{ border-color: var(--border); }
.fc .fc-daygrid-day-number, .fc .fc-col-header-cell-cushion{ color: var(--text) !important; }
.fc .fc-daygrid-day.fc-day-today{ background: color-mix(in hsl, var(--primary) 15%, transparent) !important; }

/* === TurniX V.78 — Calendario Assenze: celle compatte + scroll interno + zoom cella === */
/* Riduce l'altezza percepita degli eventi */
.fc .fc-daygrid-event{
  margin: 2px 4px;
  padding: 2px 6px;
  line-height: 1.15;
  font-size: 0.78rem;
}

/* Link "+ espandi" più coerente con la UI */
.fc .fc-daygrid-more-link{
  font-weight: 800;
  opacity: .92;
}

/* Popover elenco eventi (tipo Google Calendar): compatto + scroll interno */
.fc .fc-more-popover .fc-popover-body{
  max-height: 420px;
  overflow-y: auto;
}

/*
  V.80 — Celle mese dinamiche fino a 4 risorse
  - Celle con 0..4 risorse: auto-height (nessun vincolo)
  - Celle con >4 risorse: si ferma la crescita e parte lo scroll interno
*/
.fc .fc-daygrid-day{
  position: relative;
}
.fc .fc-daygrid-day-frame{
  position: relative;
}

/* Default: nessun vincolo, lascia crescere finché serve (fino a 4 risorse via JS) */
.fc .fc-daygrid-day-events{
  overflow: visible;
  padding-right: 2px;
  box-sizing: border-box;
}

/* Oltre soglia: vincolo altezza + scroll interno (V.94: ~4 righe nello stato chiuso) */
.fc .fc-daygrid-day.turnix-cell-limited .fc-daygrid-day-frame{
  overflow: hidden; /* impedisce che la cella "spinga" oltre il limite */
}
.fc .fc-daygrid-day.turnix-cell-limited .fc-daygrid-day-events{
  max-height: 110px;       /* fallback: ~4 righe (JS in V.94 imposta il valore esatto) */
  overflow-y: auto;        /* scroll interno con rotellina */
  overflow-x: hidden;
}

/* V.77 — Compattazione densità eventi in cella (4 risorse visibili senza scroll pagina) */
.fc .fc-daygrid-event-harness{ margin-top: 2px; }
.fc .fc-daygrid-event{ margin-top: 0; }
.fc .fc-event{
  padding: 1px 3px;
  border-radius: 7px;
}
.fc .fc-event .fc-event-main,
.fc .fc-event .fc-event-title,
.fc .fc-event .fc-event-title-container{
  font-size: 10px;
  line-height: 1.1;
}
.fc input.turnix-select-checkbox{
  width: 11px !important;
  height: 11px !important;
}

/* Header cella: numero giorno a sinistra + (conteggio) + controllo espandi a destra */
.fc .fc-daygrid-day-top{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 2px 4px 0 4px;
}
.fc .fc-daygrid-day-number{
  float: none;
  padding: 0;
}

.turnix-cell-meta{
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.turnix-cell-count{
  font-weight: 800;
  font-size: 11px;
  opacity: .92;
  color: color-mix(in hsl, var(--primary) 65%, #ffffff);
  line-height: 1;
}

/* V.94 — Toggle in-place (niente popover/zoom) */
.turnix-togglebar{
  display: flex;
  justify-content: center;
  padding: 4px 6px 8px 6px;
}

.turnix-cell-toggle{
  border: 1px solid color-mix(in hsl, var(--primary) 60%, #ffffff);
  background: color-mix(in hsl, var(--panel) 70%, #0b1220);
  color: color-mix(in hsl, var(--primary) 80%, #ffffff);
  font-weight: 800;
  font-size: 11px;
  border-radius: 10px;
  padding: 4px 10px;
  cursor: pointer;
  opacity: .92;
}
.turnix-cell-toggle:hover{ opacity: 1; }

/* Stato espanso: la cella resta in griglia, semplicemente più alta (max-height gestito via JS) */
.fc .fc-daygrid-day.turnix-cell-expanded{
  z-index: 20;
}
.fc .fc-daygrid-day.turnix-cell-expanded .fc-daygrid-day-frame{
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  border-radius: 14px;
}
.fc .fc-daygrid-day.turnix-cell-expanded .fc-daygrid-day-events{
  max-height: 400px; /* V.94: cap */
  overflow-y: auto;
  overflow-x: hidden;
}

/* Evita tagli ai bordi: consenti overflow visibile sui wrapper della griglia */
.fc .fc-daygrid-body,
.fc .fc-daygrid-body table,
.fc .fc-daygrid-day-frame,
.fc .fc-scrollgrid,
.fc .fc-scrollgrid-section,
.fc .fc-scrollgrid-section-body{
  overflow: visible !important;
}

/* Overlay popover custom per "+ espandi" (non sposta la pagina) */
.turnix-more-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 9999;
}
.turnix-more-popover{
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 24px));
  max-height: min(520px, calc(100vh - 24px)); /* può essere sovrascritto inline via JS */
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.turnix-more-popover.is-anchored{
  transform: none;
}
.turnix-more-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.turnix-more-title{
  font-weight: 900;
  color: var(--text);
  text-transform: capitalize;
}
.turnix-more-close{
  appearance:none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  opacity: .85;
}
.turnix-more-close:hover{ opacity: 1; }
.turnix-more-body{
  padding: 10px 10px 12px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.turnix-more-row{
  padding: 8px 10px;
  border: 1px solid color-mix(in hsl, var(--border) 70%, transparent);
  border-radius: 12px;
  margin-bottom: 8px;
  background: color-mix(in hsl, var(--panel) 92%, var(--bg));
}
.turnix-more-row-title{
  color: var(--text);
  font-weight: 700;
  font-size: .92rem;
}
.turnix-more-row-meta{
  margin-top: 2px;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.2;
  opacity: .95;
}
.turnix-more-empty{
  padding: 12px 10px;
  color: var(--muted);
}

/* SweetAlert2 */
.swal2-popup{
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
  border-radius: 16px !important;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.swal2-title{ color: var(--text) !important; font-weight: 800 !important; }
.swal2-html-container{ color: var(--muted) !important; }
.swal2-styled.swal2-confirm{ background: linear-gradient(165deg, var(--primary), var(--primary-strong)) !important; }
.swal2-styled.swal2-cancel{ background: linear-gradient(165deg, color-mix(in hsl, var(--text) 10%, #111), #111) !important; color:#fff !important; }

/* Icons */
.icon{ width: 18px; height: 18px; display:inline-block; }
.icon svg{ width: 18px; height: 18px; vertical-align: -3px; }

/* Page titles */
h2{ display:flex; align-items:center; gap:8px; font-size: 1.35rem; }
h2 .icon{ width:20px; height:20px; }

/* Inputs */
input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="email"], input[type="password"], select, textarea{
  background: color-mix(in hsl, var(--panel) 92%, var(--bg)); border:1px solid color-mix(in hsl, var(--border) 100%, transparent); color: var(--text);
  border-radius: 12px; padding: 10px 12px; outline: none; transition: border-color .2s ease, box-shadow .2s ease;
}
/* V.100 — Time inputs: sfondo chiaro coerente con i campi form */
input[type="time"]{
  background: #ffffff;
  color: #000000;
  border-color: #d1d5db;
}
input[type="time"]:focus{
  border-color: #93c5fd;
}

input:focus, select:focus, textarea:focus{ border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in hsl, var(--primary) 30%, transparent); }

/* Utility */
.hr-muted{ height:1px; border:none; background: var(--border); margin: 12px 0; }
/* === FullCalendar: evidenziazione giorno odierno (3D + pulse) === */
.fc .fc-day-today{
  position: relative;
  outline: 2px solid color-mix(in hsl, var(--primary) 70%, #ffffff 0%);
  outline-offset: -2px;
  box-shadow: 0 10px 24px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.10);
  background: linear-gradient(180deg, color-mix(in hsl, var(--primary) 18%, transparent), transparent 60%) !important;
}
.fc .fc-day-today::after{
  content:"";
  position:absolute;
  inset: 3px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  pointer-events:none;
}
.turnix-today-pulse{
  animation: turnixPulse 5s ease-out 1;
}
@keyframes turnixPulse{
  0%{ box-shadow: 0 0 0 0 rgba(59,130,246,.55), 0 10px 24px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.10); }
  70%{ box-shadow: 0 0 0 18px rgba(59,130,246,0), 0 10px 24px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.10); }
  100%{ box-shadow: 0 0 0 0 rgba(59,130,246,0), 0 10px 24px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.10); }
}

/* Reperibilità: look più coerente con Enterprise UI */
.rep-box{
  background: color-mix(in hsl, var(--panel) 92%, var(--bg));
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.rep-table th{
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
}
.rep-cell.on{
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.10), inset 0 -10px 18px rgba(0,0,0,.25);
  border-radius: 8px;
}

/* === Mobile: scroll orizzontale calendario + tap checkbox affidabile === */
.calendar-container{ max-width: 100%; }
.calendar-container #calendar{ max-width: 100%; }

/* Checkbox selezione eventi (assenze): dimensione/tap più comodi */
input.turnix-select-checkbox{
  width: 18px;
  height: 18px;
  cursor: pointer;
}

@media (max-width: 768px){
  /* FullCalendar month grid può essere più largo dello schermo: abilita pan orizzontale */
  .calendar-container #calendar{
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
  }
  .fc .fc-scrollgrid, .fc .fc-view-harness, .fc .fc-view-harness-active{
    min-width: 980px;
  }
  input.turnix-select-checkbox{
    width: 22px;
    height: 22px;
  }
}

/* =========================
   TurniX V.74 — Scrollbar Dark Mode
   ========================= */

/* Firefox */
*{
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.22) transparent;
}

/* Chrome/Edge/Safari */
::-webkit-scrollbar{ width: 8px; height: 8px; }
::-webkit-scrollbar-track{ background: transparent; }
::-webkit-scrollbar-thumb{
  background-color: rgba(255,255,255,.18);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover{ background-color: rgba(255,255,255,.28); }


/* V87 — Ricerca risorsa: nasconde elementi non matchati senza alterare altezze celle */
.turnix-filter-hidden{ display:none !important; }
