/* ---------------------------------------
   BASE
---------------------------------------- */

body {
  background: #f8fafc; /* sfondo elegante chiaro */
  color: #0f172a;
  font-family: 'Inter', system-ui, sans-serif;
}

/* ---------------------------------------
   CARD
---------------------------------------- */

.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.06);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 1rem;
}

/* ---------------------------------------
   STATISTICHE / KPI
---------------------------------------- */
.kpi-box {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  text-align: left;
  border-left: 6px solid transparent;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
}

.kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.7;
}

/* COLORI */
.kpi-warehouse {
  border-left-color: #f59e0b; 
  color: #b45309;
  background: #fef9c3;
}

.kpi-photo {
  border-left-color: #3b82f6;
  color: #1e3a8a;
  background: #eff6ff;
}

.kpi-post {
  border-left-color: #a855f7;
  color: #6b21a8;
  background: #f5e8ff;
}

.kpi-done {
  border-left-color: #059669;
  color: #064e3b;
  background: #ecfdf5;
}

.kpi-total {
  border-left-color: #475569;
  color: #1e293b;
  background: #f1f5f9;
}

/* Forza il riconoscimento della classe */
.kpi-box.kpi-still {
  border-left-color: #06b6d4 !important;
  color: #0891b2 !important;
  background-color: #ecfeff !important;
}

/* Serve anche a colorare il numero e la scritta all'interno */
.kpi-box.kpi-still .kpi-value,
.kpi-box.kpi-still .kpi-label {
  color: #0891b2 !important;
}
/* ---------------------------------------
   STILE SPECIFICO WORKER LOAD COUNT
---------------------------------------- */
.worker-load-count {
    color: #dc2626 !important; /* Rosso scuro di Tailwind (Red 700), forziamo con !important */
    font-weight: 700; /* Per renderlo in grassetto */
    white-space: nowrap; 
}


/* Sblocca il touch sui bottoni della tabella */
.sortable-col, 
.excel-filter-trigger, 
#toggle-actions-col,
.admin-filter-input {
    touch-action: manipulation; /* Velocizza il click eliminando il ritardo del doppio tap */
    cursor: pointer;
    position: relative;
    z-index: 120; /* Li tiene sopra ogni possibile wrapper invisibile */
}

/* Evita che il testo venga selezionato mentre provi a cliccare velocemente */
th.sortable-col span {
    user-select: none;
    -webkit-user-select: none;
}

/* ---------------------------------------
   BOTTONI
---------------------------------------- */

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  font-weight: 600;
  border-radius: 10px;
  padding: 0.55rem 1.2rem;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
  transition: 0.2s;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #4338ca, #4f46e5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #eef2ff;
  color: #4338ca;
  font-weight: 600;
  border-radius: 10px;
  padding: 0.55rem 1.2rem;
  border: 1px solid #c7d2fe;
  transition: 0.2s;
}
.btn-secondary:hover {
  background: #e0e7ff;
  transform: translateY(-1px);
}

.btn-danger {
  background: #ef4444;
  color: white;
  font-weight: 600;
  border-radius: 10px;
  padding: 0.55rem 1.2rem;
  transition: 0.2s;
}
.btn-danger:hover {
  background: #dc2626;
}


/* ---------------------------------------
   INPUT
---------------------------------------- */

.form-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  font-size: 0.9rem;
  background: white;
  transition: 0.2s;
}
.form-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  outline: none;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.25rem;
  display: block;
}

/* ---------------------------------------
   SIDEBAR
---------------------------------------- */

/* SIDEBAR – il design che avevi resta valido */
#sidebar {
  background: #1e293b;
  color: white;
}

/* Bottoni sidebar (tuoi) */
.sidebar-btn {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-weight: 600;
  border-radius: 10px;
  background: #334155;
  transition: 0.2s;
}
.sidebar-btn:hover {
  background: #475569;
  transform: translateX(3px);
}

/* User box */
#sidebar-user {
  background: #334155;
  border: 1px solid #475569;
  border-radius: 12px;
}

/* MAIN CONTENT – spazio per sidebar solo su desktop */
#main-content {
  margin-left: 0;
}

@media (min-width: 1024px) {
  #main-content {
    margin-left: 16rem; /* 64 * 0.25rem */
  }
}

/* ---------------------------------------
   TABELLE
---------------------------------------- */

th.th {
  padding: 0.6rem 0.75rem;
  background: #f1f5f9;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
}

td.td {
  padding: 0.55rem 0.75rem;
  font-size: 0.8rem;
}

table {
  border-spacing: 0;
}

.table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 80vh; /* O l'altezza che preferisci */
    scrollbar-gutter: stable; /* Evita che la tabella "salti" quando appare la scrollbar */
}



/* ===============================================
   ADMIN – STICKY COLUMNS (FIX CAMBIO PAGINA)
   =============================================== */

/* 1. Blocca la colonna 1 (Checkbox) */
.admin-sticky-1 {
    position: sticky !important;
    left: 0 !important;
    width: 35px !important;
    min-width: 35px !important;
    max-width: 35px !important;
    z-index: 60 !important;
    background-color: inherit !important;
    border-right: 1px solid #d1d5db !important;
}

/* 2. Colonna 2 (Azioni) - IL MURO */
.admin-sticky-2 {
    position: sticky !important;
    left: 35px !important;
    z-index: 50 !important;
    background-color: #ffffff !important;
}

/* STATO APERTO: Forza il browser a ricalcolare la larghezza vera */
.admin-sticky-2:not(.collapsed-col) {
    /* Usiamo min-width per impedire il taglio dei bottoni */
    /* Se le tue icone sono tante, alza questo valore (es. 150px) */
    width: auto !important;
    min-width: fit-content !important; 
    max-width: none !important;
    
    border-right: 1px solid #d1d5db !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* 3. IL DIV INTERNO: Quello che contiene ingranaggio e graffetta */
.admin-sticky-2:not(.collapsed-col) > div {
    display: flex !important;
    width: max-content !important; /* Forza il div a prendersi tutto lo spazio delle icone */
    min-width: max-content !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    padding: 0 10px !important;
}

/* 4. ANTI-TAGLIO: Uccidiamo ogni tentativo del JS di mettere width o margin strani */
.admin-sticky-2 .ml-auto, 
.admin-sticky-2 .relative.inline-flex {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* 5. STATO CHIUSO: Sparisce all'istante */
.admin-sticky-2.collapsed-col {
    width: 0px !important;
    min-width: 0px !important;
    max-width: 0px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    overflow: hidden !important;
    display: none !important; /* Se è chiusa, sparisce proprio dal layout */
}





/* da qui non si tocca

/* Prima colonna Admin (CHECKBOX) */
.admin-sticky-1 {
  position: sticky !important;
  left: 0 !important;
  z-index: 40 !important;
  background: rgb(255, 255, 255);
  box-shadow: 2px 0 4px rgba(0,0,0,0.06);
  padding: 0 !important;
}


/* THEAD sopra tutto */
#admin-orders-table thead {
    position: sticky;
    top: 0;
    z-index: 100 !important;
    background: #e5e7eb; /* Grigio testata */
    border-collapse: separate !important; /* Mantieni separate per lo sticky... */
    border-spacing: 0 !important;        /* ...ma azzera lo spazio tra le celle! */
}


/* 🔥 Disabilita animazioni durante render massivo */
#orders-table-body.rendering * {
  animation: none !important;
  transition: none !important;
}

/* NON colorare mai il th */
#orders-header-row th.th-filter-active {
  background: transparent !important;
}

/* Evidenzia SOLO il contenuto reale dell'header */
#orders-header-row th.th-filter-active .th-header-inner {
  background-color: #e0f2fe;      /* azzurro stabile */
  border-bottom: 2px solid #0284c7;
}

/* Evidenzia anche la freccia filtro */
#orders-header-row th.th-filter-active .excel-filter-trigger {
  color: #0284c7;
  font-weight: 900;
}

#admin-ghost {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Non deve bloccare i click sulla tabella vera */
    z-index: 10000;
    display: none;
}

/* Fondamentale: il TH deve essere il riferimento per il resizer */
th {
    position: relative !important;
}

.resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px; /* Area cliccabile */
    height: 100%;
    cursor: col-resize;
    z-index: 50; /* Deve stare sopra a tutto */
    transition: background 0.2s;
}

/* La riga visibile quando passi il mouse o trascini */
.resizer:hover, .resizing-active .resizer {
    border-right: 3px solid #3b82f6; /* Una bella linea blu visibile */
    background: rgba(59, 130, 246, 0.1); /* Un leggero alone */
}

/* Impedisce di selezionare il testo durante il trascinamento */
.is-resizing {
    user-select: none !important;
    cursor: col-resize !important;
}




/* 1. GRIGIO SOLO PER L'INTESTAZIONE (Titoli e Filtri) */
#admin-orders-table thead th {
    background-color: #e5e7eb !important; 
    color: #111827 !important;
    border-bottom: none !important; /* TOGLI IL BORDO SOTTO AI TITOLI */
}

#admin-orders-table thead td {
    background-color: #e5e7eb !important; 
    color: #111827 !important;
    border-top: 1px solid #d1d5db !important; /* METTI IL BORDO SOPRA AI FILTRI */
    /* IL TRUCCO: */
    transform: translateY(-1px); /* Sale di 1px e si incolla alla riga sopra */
}

/* AGGIUNGI QUESTO PEZZO QUI SOTTO: è il "salvavita" per lo scroll laterale */
#admin-orders-table thead .admin-sticky-1, 
#admin-orders-table thead .admin-sticky-2 {
    z-index: 150 !important;
    background-color: #e5e7eb !important;
    /* Assicurati che il bordo destro sia identico per entrambi */
    border-right: 1px solid #d1d5db !important; 
} 

/* 2. COLONNA AZIONI NEL BODY: Bianca senza !important */
#orders-table-body td.admin-sticky-2 {
    background-color: #ffffff; 
}


/* 3. SE IL JS NON METTE COLORE, FORZIAMO IL BIANCO DI BASE MA CON PRIORITÀ BASSA */
#orders-table-body tr td {
    background-color: #ffffff;
}

/* L'header deve vincere su tutto quello che c'è sotto */
#admin-orders-table thead {
    position: sticky;
    top: 0;
    z-index: 100 !important; /* Molto alto */
}

/* Le celle dell'header devono stare sopra le celle del body */
#admin-orders-table thead th,
#admin-orders-table thead td {
    background-color: #e5e7eb !important; /* Grigio testata */
    color: #1a1a1a !important;
    z-index: 110 !important;
}

/* Alziamo a 40 per coerenza, così restano sopra le altre celle del body */
#orders-table-body td.admin-sticky-1,
#orders-table-body td.admin-sticky-2 {
    z-index: 40 !important;
}



/* --- EVIDENZIATORE "SUSSURRATO" --- */

/* Applica un giallo crema chiarissimo solo quando la riga ha la classe .row-selected */
tr.row-selected td {
    background-color: #ebf7fc !important; /* Quasi bianco, ma caldo */
    transition: background-color 0.3s ease; /* Sfuma dolcemente */
}

/* Lascia che la prima cella (Checkbox) mantenga il suo colore di stato (Azzurro/Arancio/ecc) */
tr.row-selected td.admin-sticky-1 {
    background-color: inherit !important;
}

/* Se vuoi un tocco di classe, aggiungi un bordino dorato sottilissimo solo a sinistra */
tr.row-selected {
    box-shadow: inset 3px 0 0 0 #547ff5;
}
/* ===============================================
   WORKER — TABELLA PROFESSIONALE (FIX TOTALE)
   =============================================== */
/* 1. RIPRISTINO SCROLL */
#worker-table-container, 
#worker-view .overflow-x-auto {
    height: 60vh !important;    /* Ripristiniamo la tua altezza originale */
    overflow: auto !important;   /* Forza la ricomparsa delle barre */
    position: relative;
    border-collapse: separate;  /* Fondamentale per lo sticky */
}

/* 2. LA TABELLA */
#worker-orders-table {
    width: 100%;
    border-spacing: 0;
    /* Rimuoviamo min-width se ti bloccava lo scroll */
}

/* 3. FIX CHIRURGICO: BLOCCO INTESTAZIONE (Verticale) */
/* Questo è quello che ti mancava: lo sticky su TUTTE le TH */
#worker-orders-table thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    background: #f1f5f9 !important; /* Colore solido */
}

/* 4. FIX CHIRURGICO: BLOCCO FILTRI (Verticale) */

#worker-filter-row td {
    position: sticky !important;
    top: 44px !important; /* <--- Aumentato per scendere SOTTO i titoli */
    z-index: 140 !important; /* Deve essere più basso dell'header (che è 150) */
    background: #f8fafc !important;
    border-top: 1px solid #e2e8f0; /* Opzionale: aggiunge una linea di separazione */
}

/* 5. FIX COLONNE FISSE (Orizzontale - Come le avevi prima) */
.worker-order-cb-column, 
.worker-sticky-1 {
    position: sticky !important;
    background: white !important;
    z-index: 20;
}
.worker-order-cb-column { left: 0 !important; }
.worker-sticky-1 { left: 40px !important; }

/* 6. GLI ANGOLI */
#worker-orders-header th.worker-order-cb-column,
#worker-orders-header th.worker-sticky-1 {
    z-index: 150 !important; /* L'intestazione vince sempre */
    top: 0 !important;
}

#worker-filter-row td.worker-order-cb-column,
#worker-filter-row td.worker-sticky-1 {
    z-index: 145 !important; /* Sotto l'header ma sopra i dati */
    top: 44px !important;    /* <--- DEVE ESSERE IDENTICO AL PUNTO SOPRA */
}


#worker-orders-header {
    z-index: 150 !important;
}

/* --- FIX COLLAPSE TOTALE (A zero sulla checkbox) --- */

.worker-collapsed .worker-sticky-1 {
    width: 40px !important;      /* Stessa larghezza della checkbox per simmetria */
    min-width: 40px !important;
    max-width: 40px !important;
    left: 40px !important;       /* Si incolla al bordo della checkbox */
    padding: 8px 0 !important;   /* Rimuove padding laterale che crea spazio */
    text-align: center !important;
    overflow: hidden !important;
}

/* Assicurati che l'header e la riga filtri seguano lo stesso collasso */
.worker-collapsed th.worker-sticky-1,
.worker-collapsed td.worker-sticky-1 {
    left: 40px !important;
}

/* Nasconde tutto il contenuto tranne il pulsante freccia */
.worker-collapsed .worker-sticky-1 > *:not(#toggle-worker-col) {
    display: none !important;
}

/* Centra perfettamente il pulsante freccia quando è chiuso */
.worker-collapsed #toggle-worker-col {
    margin: 0 auto !important;
    display: block !important;
}

/* 1. Linea sotto l'header (se non usi i filtri) o per dare profondità */
#worker-orders-table thead th {
    /* ... tue regole precedenti ... */
    box-shadow: inset 0 -2px 0 #e2e8f0 !important; 
}

/* 2. Linea di separazione tra la riga Filtri e i dati (La più importante) */
#worker-filter-row td {
    /* ... tue regole precedenti ... */
    box-shadow: inset 0 -1px 0 #e2e8f0, 0 2px 4px rgba(0,0,0,0.05) !important;
    /* L'ombra esterna (0 2px 4px) crea l'effetto "rialzato" stile Excel */
}

/* 3. Linea verticale tra le colonne sticky (Azioni) e i dati */
.worker-sticky-1 {
    /* ... tue regole precedenti ... */
    box-shadow: inset -2px 0 0 #e2e8f0 !important;
}

.worker-collapsed .worker-sticky-1 {
    /* ... tue regole precedenti ... */
    box-shadow: inset -2px 0 0 #e2e8f0 !important;
}

#worker-orders-table td.cursor-not-allowed span {
    opacity: 0.7;
    font-style: italic;
}


/* Colonna con filtro Excel attivo */
#worker-orders-header th.th-filter-active {
    background-color: #b3d4f0bb !important; /* Giallo Ambra chiaro */
    transition: background-color 0.2s ease;
    border-bottom: 2px solid #1b0bf5 !important; /* Linea arancione marcata */
}

/* Cambia anche il colore della freccetta ▼ per farla risaltare */
#worker-orders-header th.th-filter-active .excel-trigger {
    color: #0953b4ec !important;
    opacity: 1 !important;
}

/* Se preferisci l'effetto "Riga Blu" (Basta cambiare i colori qui) */
/* .th-filter-active {
    background-color: #dbeafe !important;
    border-bottom: 2px solid #3b82f6 !important;
}
*/

/* Posizionamento chirurgico del tasto Reset */
.card {
    position: relative !important;
}

#btn-reset-worker-filters {
    position: absolute !important;
    right: 20px !important; /* Distanza dal bordo destro della card */
    top: 20px !important;   /* Allineato all'altezza del titolo */
    
    /* Stile estetico */
    background-color: #fff1f2 !important; /* rose-50 */
    color: #e11d48 !important;            /* rose-600 */
    border: 1px solid #fecdd3 !important; /* rose-200 */
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    cursor: pointer !important;
    z-index: 10 !important;
    transition: all 0.2s;
}

#btn-reset-worker-filters:hover {
    background-color: #e11d48 !important;
    color: white !important;
}

/* Quando è nascosto */
#btn-reset-worker-filters.hidden {
    display: none !important;
}

/* RESET BUTTON FIX */
#btn-reset-worker-filters {
    display: inline-block !important; /* Forza la visibilità per il test */
    position: absolute !important;
    right: 1.5rem !important; 
    top: 1.5rem !important;
    z-index: 9999 !important; /* Sopra a TUTTO */
    
    background-color: #fff1f2 !important;
    color: #e11d48 !important;
    border: 1px solid #fecdd3 !important;
    padding: 5px 10px !important;
    border-radius: 6px !important;
    font-size: 11px !important;
    font-weight: bold !important;
    cursor: pointer !important;
}

/* Se vedi il bottone, allora rimuovi 'display: inline-block !important' 
   dal blocco sopra e usa questa classe per gestirlo col JS */
#btn-reset-worker-filters.is-hidden {
    display: none !important;
}




/* Lo spinner fiko */
.loader-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3; /* Grigio chiaro */
    border-top: 3px solid #2563eb; /* Blu acceso */
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* ===============================================
   PERFORMANCE OPTIMIZATION PER GRANDI VOLUMI
   =============================================== */

#admin-orders-table {
    table-layout: fixed; /* Velocizza il calcolo delle colonne */
    contain: paint layout style; /* Isola la tabella dal resto della pagina */
}

#orders-table-body tr {
    content-visibility: auto;
    contain-intrinsic-size: 0 38px; /* Mantiene l'altezza corretta mentre scrolli */
}

/* ===============================================
   CUSTOMER TABLE - FIX STICKY
   =============================================== */

/* BLOCCO FISSA-TESTATA CUSTOMER (VERSIONE DEFINITIVA) */
#customer-scroll-area {
    max-height: 450px !important; 
    overflow-y: auto !important;
    overflow-x: auto !important;
    position: relative;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    max-width: 100%;
}

#customer-scroll-area table {
    border-collapse: separate !important; /* Questo "ancora" lo sticky */
    border-spacing: 0 !important;
    width: 100%;
    min-width: 800px;
}

/* 1. Titoli (Grigio scuro) */
#customer-scroll-area thead tr:first-child th {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    background-color: #e5e7eb !important; 
    box-shadow: inset 0 -1px 0 #cbd5e1;
}

#customer-scroll-area thead tr:first-child th:first-child {
    z-index: 150 !important;
    left: 0 !important;
}

#customer-scroll-area thead tr:nth-child(2) th:first-child {
    z-index: 145 !important;
    left: 0 !important;
    background-color: #f8fafc !important;
}


/* 2. Filtri (Sfondo chiaro) */
#customer-scroll-area thead tr:nth-child(2) th {
    position: sticky !important;
    top: 38px !important; /* Se vedi un buco o sovrapposizione, ritocca questo numero */
    z-index: 95 !important;
    background-color: #f8fafc !important;
    box-shadow: inset 0 -1px 0 #cbd5e1;
}


#customer-stats-bar > div {
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

#customer-stats-bar > div:hover {
    transform: translateY(-2px);
    filter: brightness(0.95);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

#customer-stats-bar > div:active {
    transform: translateY(0);
}

/* Effetto "premuto" quando clicchi sui KPI dei clienti */
#customer-stats-bar > div:active {
    transform: scale(0.95);
    filter: contrast(1.2);
}

#customer-table-body td {
    white-space: nowrap !important;
    padding: 10px 15px !important;
}

/* ---------------------------------------
   MODALI
---------------------------------------- */

.modal-panel {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.2);
}

/* Modale Link Media sempre sopra a tutto */
#links-modal {
  position: fixed !important;
  z-index: 99999 !important;
}

/* Il pannello interno rimane sopra allo sfondo */
#links-modal .modal-panel {
  position: relative !important;
  z-index: 1 !important;
}
/* ---------------------------------------
   TOAST
---------------------------------------- */

#toast-container {
  background: #1e293b;
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: 0 3px 12px rgba(0,0,0,0.2);

  /* 🔥 Aggiungi queste righe fondamentali */
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 99999;
  pointer-events: none;
  max-width: 300px;
}


/* ===============================
   📅 FULLCALENDAR – UX FIX
   =============================== */

/* contenitore eventi del giorno */
.fc-daygrid-day-events {
  max-height: 140px;
  overflow-y: auto;
  padding-right: 4px;
}

/* evento singolo */
.fc-daygrid-event {
  font-size: 11px;
  line-height: 1.25;
  padding: 2px 6px;
  border-radius: 6px;

  /* 🔥 QUESTO È IL FIX */
  user-select: text !important;
  cursor: text !important;
}

/* titolo evento */
.fc-event-title {
  white-space: normal !important;
  word-break: break-word;
  user-select: text !important;
}

/* disattiva drag & blocchi FC */
.fc-event,
.fc-daygrid-event-harness {
  pointer-events: auto !important;
}

/* scrollbar discreta */
.fc-daygrid-day-events::-webkit-scrollbar {
  width: 6px;
}
.fc-daygrid-day-events::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

#calendar-modal .flex-1.overflow-y-auto {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

#calendar-modal .flex-1.overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

#calendar-modal .flex-1.overflow-y-auto::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}
/* ---------------------------------------
   x filtri attivi nelle tabelle
---------------------------------------- */

/* 🔎 Colonna con filtro attivo */
.th-filter-active {
  background-color: #e0f2fe; /* azzurrino */
  box-shadow: inset 0 -2px 0 #0284c7;
}

.th-filter-active .excel-filter-trigger {
  color: #0284c7;
  font-weight: 900;
}

/* ---------------------------------------
   ANIMAZIONI
---------------------------------------- */

.card-pop {
  transform: scale(0.97);
  opacity: 0;
  animation: cardPopIn 0.15s ease-out forwards;
}

@keyframes cardPopIn {
  from {
    transform: scale(0.97);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Questa classe evidenzia la ricerca senza rompere il colore del testo originale */
.search-highlight {
    background-color: #3b82f6 !important; /* Blu */
    color: white !important;
    font-weight: bold !important;
    border-radius: 2px;
}

/* La riga trovata */
.row-found {
    outline: 4px solid yellow !important;
    box-shadow: 0 0 15px yellow !important;
}






/* Fondamentale: Il link deve essere il punto di riferimento */
.preview-link-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Il tooltip deve galleggiare SOTTO (absolute) */
.preview-tooltip {
    visibility: hidden;
    position: absolute;
    z-index: 999999 !important; /* Massimo livello */
    
    /* --- SPOSTAMENTO VERSO IL BASSO --- */
    top: 120%; /* Lo posiziona esattamente sotto il link */
    left: 0;
    
    width: 200px;
    background: white;
    border: 2px solid #1e293b;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    padding: 5px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(-10px); /* Effetto entrata dal basso verso l'alto */
}

.preview-link-container:hover .preview-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.preview-tooltip img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 250px;
    object-fit: contain;
    border-radius: 8px;
      
}

/* 1. Forza il contenitore dei link a essere il livello dominante */
#modal-links-content {
    position: relative !important;
    z-index: 10 !important; /* Questo crea il piano base elevato */
    overflow-y: auto !important; /* Lo scroll deve rimanere qui */
    overflow-x: visible !important; /* Permette al tooltip di uscire lateralmente */
}

/* Solo la riga del link può avere overflow visible per il tooltip */
.preview-link-container {
    position: relative;
    overflow: visible !important; 
}

/* Impedisce ai link di rompere il layout */
.preview-link-container a {
    display: block;
    word-break: break-all;
    white-space: normal;
    max-width: 100%;
}




/* 1. Il contenitore che racchiude SIA la barra bulk SIA la tabella */
/* Assicurati di sapere qual è il padre comune */
.parent-container {
    display: flex !important;
    flex-direction: column;
    justify-content: flex-end; /* Spinge tutto verso il basso */
}

#worker-bulk-actions-container {
    display: flex !important;
    flex-direction: column;
    overflow: hidden !important;
    
    /* STATO CHIUSO */
    max-height: 0;
    opacity: 0;
    margin: 0 !important;
    padding: 0 !important;
    
    /* Transizione fluida */
    transition: max-height 0.4s ease-out, opacity 0.3s ease;
}

/* STATO APERTO */
#worker-bulk-actions-container.is-active {
    max-height: 85px; 
    opacity: 1;
    margin-top: 0 !important;
    margin-bottom: 1rem !important; /* Spazio verso la tabella */
    
    background: #1e293b; 
    border: 1px solid #334155 !important;
    border-radius: 12px;
}


/* 1. La barretta dello scroll orizzontale della tabella ADMIN */
#admin-orders-table-container::-webkit-scrollbar,
.overflow-x-auto::-webkit-scrollbar {
    height: 8px !important; /* Spessore umano, non quel mostro grigio */
}

/* 2. Il colore della barretta che trascini */
#admin-orders-table-container::-webkit-scrollbar-thumb,
.overflow-x-auto::-webkit-scrollbar-thumb {
    background: #cbd5e1 !important; /* Grigio pulito */
    border-radius: 10px !important;
    border: 2px solid #ffffff !important; /* Crea stacco così non si incolla ai bordi */
}

/* 3. Lo sfondo sotto la barretta (deve essere trasparente o bianco) */
#admin-orders-table-container::-webkit-scrollbar-track,
.overflow-x-auto::-webkit-scrollbar-track {
    background: #f8fafc !important; /* Grigio quasi bianco, pulitissimo */
}


/* --- ABBELLIMENTO SCROLL TABELLA ADMIN (ORIZZONTALE E VERTICALE) --- */

/* 1. Lo spessore delle barre (8px è il compromesso perfetto tra eleganza e click) */
#admin-horizontal-wrapper::-webkit-scrollbar {
    height: 8px !important; /* Spessore barra orizzontale */
}

#admin-table-container::-webkit-scrollbar {
    width: 8px !important;  /* Spessore barra verticale */
}

/* 2. La barretta che trascini (il Thumb) */
#admin-horizontal-wrapper::-webkit-scrollbar-thumb,
#admin-table-container::-webkit-scrollbar-thumb {
    background-color: #cbd5e1 !important; /* Grigio Slate-300: moderno e pulito */
    border-radius: 10px !important;       /* Arrotondata stile iOS */
    border: 2px solid #ffffff !important; /* Margine bianco interno per farla "galleggiare" */
}

/* 3. Colore della barretta quando ci passi sopra col mouse */
#admin-horizontal-wrapper::-webkit-scrollbar-thumb:hover,
#admin-table-container::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8 !important; /* Si scurisce un po' (Slate-400) */
}

/* 4. Lo sfondo della traccia (Track) */
#admin-horizontal-wrapper::-webkit-scrollbar-track,
#admin-table-container::-webkit-scrollbar-track {
    background: #f8fafc !important; /* Grigio chiarissimo quasi bianco */
    border-radius: 10px;
}

/* Per Firefox (che è sempre il più difficile) */
#admin-horizontal-wrapper, 
#admin-table-container {
    scrollbar-width: thin !important;
    scrollbar-color: #cbd5e1 #f8fafc !important;
}




/* Quando entriamo in modalità cinema, pialliamo tutto il resto */
body.cinema-mode-active .sidebar, 
body.cinema-mode-active aside, 
body.cinema-mode-active header,
body.cinema-mode-active .nav-main {
    display: none !important; /* La sidebar scompare fisicamente */
}

/* #main-content ha overflow-x-hidden + position:relative: un antenato così
   TAGLIA visivamente i figli position:fixed, anche se il fixed calcola
   correttamente left:0/width:100vw rispetto al viewport. Senza questa riga
   la cinema mode si ferma dove finiva la sidebar (margine lg:ml-64), invece
   di coprire tutto lo schermo. */
body.cinema-mode-active #main-content {
    overflow: visible !important;
}

/* La card si incolla ai bordi del monitor */
.cinema-active {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    margin: 0 !important;
    padding: 10px !important; /* Un minimo di bordo per non appiccicare il testo al vetro */
    background: white !important;
    border: none !important;
    border-radius: 0 !important;
}

/* Tabella a tutta altezza: calcoliamo lo spazio togliendo header e footer della card */
.cinema-active #admin-table-container {
    height: calc(100vh - 150px) !important; 
    max-height: none !important;
}

.cinema-active #admin-orders-table {
    font-size: 13px !important; /* Un filo più grande per leggere meglio */
}




/* Forza il Google Picker sopra ogni modale (Tailwind usa spesso z-50 o z-100) */
.picker-dialog {
    z-index: 9999 !important;
}

/* A volte Google usa questa classe per l'overlay scuro */
.picker-dialog-bg {
    z-index: 9998 !important;
}


/* per far pulsare le notifiche */
@keyframes pulse-inside {
    0% { 
        background-color: #dc2626; /* Rosso base */
        box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0.4);
        transform: scale(1);
    }
    50% { 
        background-color: #ef4444; /* Rosso più acceso */
        box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0);
        transform: scale(1.1); /* Lo ingrandiamo un pelo ma resta nel suo spazio */
    }
    100% { 
        background-color: #dc2626;
        box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0);
        transform: scale(1);
    }
}

.animate-unread {
    animation: pulse-inside 1.5s infinite ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Evitiamo che il bottone sia troppo attaccato al bordo destro */
    margin-right: 5px; 
}




/* 1. Selezione chirurgica delle righe nelle tre tabelle principali */
#orders-table-body tr, 
#worker-orders-body tr, 
#customer-table-body tr {
    transition: background-color 0.15s ease-in-out;
    cursor: pointer;
}

/* 2. Effetto hover sulla riga */
#orders-table-body tr:hover, 
#worker-orders-body tr:hover, 
#customer-table-body tr:hover {
    background-color: #f8fafc !important; /* Grigio solido, non trasparente */
}

/* 3. FIX CHIRURGICO: Sfondo trasparente per le celle normali, SOLIDO per le sticky */
#worker-orders-body tr:hover td {
    background-color: transparent !important;
}

/* 🎯 IL MURO: Queste non devono MAI diventare trasparenti */
#worker-orders-body tr:hover td.worker-order-cb-column, 
#worker-orders-body tr:hover td.worker-sticky-1 {
    background-color: #f8fafc !important; /* Lo stesso grigio dell'hover, ma COPRIENTE */
    opacity: 1 !important;
    z-index: 20;
}

/* Protezione per quando NON sei in hover (devono essere bianche e coprenti) */
#worker-orders-body td.worker-order-cb-column, 
#worker-orders-body td.worker-sticky-1 {
    background-color: white !important;
    opacity: 1 !important;
}

/* 4. Manteniamo i bordi divisori per non perdere il filo (La "Madonna" è contenta) */
#orders-table-body td, 
#worker-orders-body td, 
#customer-table-body td {
    border-bottom: 1px solid #f1f5f9;
}



/* tabella customer */
.custom-scrollbar::-webkit-scrollbar {
    height: 6px; /* Spessore della barra orizzontale */
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f5f9; /* Colore binario */
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1; /* Colore maniglia */
    border-radius: 10px;
}




/* Evita che i bottoni si restringano per stare nello schermo */
#customer-stats-bar div {
    flex-shrink: 0;
}



/* 1. UCCIDI LA SCROLLBAR ENORME DEL BROWSER (SUL BODY) */
html, body {
    scrollbar-width: none; /* Per Firefox */
    -ms-overflow-style: none; /* Per Edge/IE */
}

body::-webkit-scrollbar {
    display: none; /* Per Chrome, Safari e Opera */
}

/* 2. CREA UNA SCROLLBAR STILOSA SOLO PER IL TUO DIV INTERNO */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px; /* Sottile, non invade lo schermo */
    height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05); /* Binario quasi invisibile */
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #475569; /* Colore Slate-600 (elegante) */
    border-radius: 10px;
    border: 2px solid transparent; /* Crea un po' di padding */
    background-clip: content-box;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #0f172a; /* Diventa scura quando ci passi sopra */
}

/* Forza la reattività delle celle del calendario */
.fc-daygrid-day {
    cursor: pointer !important;
    z-index: 1 !important;
}

/* Se hai un modal o un overlay che copre tutto */
.fc-view-harness {
    z-index: 2;
    pointer-events: auto !important;
}

.custom-scrollbar {
    overflow-y: scroll !important; /* Forza la presenza dello scroll */
    scrollbar-gutter: stable;      /* Blocca lo spazio della barra, non scompare più */
}


/* Animazione per far salire il menu dal basso su mobile */
@keyframes slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.animate-slide-up {
    animation: slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}





/* --- ANIMAZIONE VERDE (Nuovo nome: animate-green-radar) --- */
@keyframes pulse-green-radar {
    0% { background-color: #10b981; transform: scale(1); box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0.4); }
    50% { background-color: #34d399; transform: scale(1.1); box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0); }
    100% { background-color: #10b981; transform: scale(1); box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0); }
}

.animate-green-radar {
    animation: pulse-green-radar 1.5s infinite ease-in-out !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: #10b981 !important; 
    color: white !important; 
    font-weight: 900 !important;
    border-radius: 9999px !important;
    padding: 2px 6px !important;
    min-width: 20px !important;
    height: 20px !important;
    font-size: 10px !important;
    margin-right: 5px;
}

#orders-table-body tr:hover td:not(.admin-sticky-1):not(.admin-sticky-2) {
    background-color: #f8fafc !important;
}

html {
    background-color: #0f172a !important;
}


.admin-tools-hidden {
    display: none !important;
}

#tools-icon, #tools2-icon {
    display: inline-block;
    transition: transform .3s ease;
}

#tools-icon.rotated, #tools2-icon.rotated {
    transform: rotate(180deg);
}