/* QF PRO - SAAS CORE THEME 
    Strategia: Normalizzazione Dark Mode & Contrast Ratio
*/

:root { 
    --bg:#0b0f14; 
    --panel:#101826; 
    --line:#223047; 
    --info:#60a5fa; 
    --ok:#22c55e; 
    --warn:#fbbf24; 
    --crit:#f87171; 
    --text:#e5e7eb; 
    --text-muted:#9ca3af;
    --input-bg:#162235;
}

/* --- RESET & CORE --- */
body { background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif; margin: 0; overflow: hidden; }
.hide { display: none !important; }
.app-layout { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }

/* --- NAVIGATION --- */
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 25px; display: flex; flex-direction: column; }
.nav-link { padding: 12px 15px; cursor: pointer; border-radius: 8px; color: var(--text-muted); margin-bottom: 8px; transition: 0.3s; display: flex; align-items: center; gap: 10px; }
.nav-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-link.active { background: rgba(96,165,250,0.15); color: var(--info); font-weight: bold; }

.active-supplier-badge {
    margin: 20px 0; padding: 15px; background: rgba(96,165,250,0.05); 
    border: 1px dashed var(--info); border-radius: 12px; font-size: 0.85rem;
}
.active-supplier-badge span { display: block; color: var(--info); font-weight: bold; margin-top: 5px; }

/* --- LAYOUT & CARDS --- */
main { overflow-y: auto; padding: 20px; height: 100vh; box-sizing: border-box; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; color: var(--text); }

/* --- FORM ELEMENTS (Normalizzazione Universale) --- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }

label, .form-label { color: #f1f5f9 !important; margin-bottom: 8px; display: block; font-weight: 500; font-size: 0.9rem; }

input, select, textarea, .form-control { 
    background: var(--input-bg) !important; 
    border: 1px solid var(--line) !important; 
    color: #ffffff !important; 
    padding: 12px; 
    border-radius: 8px; 
    width: 100%; 
    box-sizing: border-box; 
    font-size: 0.9rem; 
}

input:focus, textarea:focus, select:focus { border-color: var(--info) !important; outline: none; box-shadow: 0 0 0 2px rgba(96,165,250,0.2); }

/* --- TABLES --- */
table, .table { width: 100%; border-collapse: collapse; margin-top: 10px; color: var(--text) !important; }
th { text-align: left; padding: 12px; border-bottom: 2px solid var(--line); color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
td { padding: 14px 12px; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.9rem; color: var(--text); }
tr:hover td { background: rgba(255,255,255,0.02); }

/* --- BOOTSTRAP MODALS (Fix Definitivo per SaaS) --- */
.modal-content { background-color: var(--panel) !important; border: 1px solid var(--line) !important; color: var(--text) !important; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5); }
.modal-header { border-bottom: 1px solid var(--line) !important; background-color: rgba(255,255,255,0.02); }
.modal-footer { border-top: 1px solid var(--line) !important; }
.modal-title { color: var(--info) !important; font-weight: bold; }
/* Fix chiusura modale */
.btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* --- UI COMPONENTS (Badges & Pills) --- */
.status-pill { padding: 4px 12px; border-radius: 20px; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; text-align: center; }
.badge-crit { padding: 6px 12px; border-radius: 50px; font-size: 0.75rem; font-weight: bold; color: white; text-transform: uppercase; }

.crit-alto { background-color: var(--crit) !important; box-shadow: 0 0 10px rgba(248,113,113,0.3); }
.crit-medio { background-color: var(--warn) !important; color: #1e293b; }
.crit-basso { background-color: var(--ok) !important; }

/* Status NC */
.badge-aperta { background: #ef4444; color: #fff; }
.badge-incorso { background: #f59e0b; color: #fff; }
.badge-risolta { background: #3b82f6; color: #fff; }
.badge-chiusa { background: #10b981; color: #fff; }

/* --- MODULE SPECIFIC FIXES --- */

/* Audit & Matrix */
[id^="view-audit"] h2, [id^="view-audit"] h4 { color: #fff !important; }
.item-matrice-admin { display: flex; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); transition: 0.2s; }
.item-matrice-admin:hover { background: rgba(255,255,255,0.03); }
.peso-tag { background: var(--line); color: var(--info); padding: 2px 8px; border-radius: 4px; font-family: monospace; }

/* Calendario - Normalizzazione contrasto */
#calendar-root { color: #1e293b !important; background: #f8fafc; border-radius: 12px; padding: 15px; border: 1px solid var(--line); }
.fc-theme-standard td, .fc-theme-standard th { border: 1px solid #e2e8f0 !important; }

/* Select2 Customization */
.select2-container--default .select2-selection--single { background-color: var(--input-bg) !important; border: 1px solid var(--line) !important; color: white !important; }
.select2-dropdown { background-color: var(--panel) !important; color: white !important; border: 1px solid var(--info) !important; }

/* --- ANIMATIONS --- */
@keyframes pulse-red { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.rating-low { color: var(--crit); font-weight: bold; animation: pulse-red 2s infinite; }

/* Modifica queste regole nel tuo style.css */

.sidebar { 
    background: var(--panel); 
    border-right: 1px solid var(--line); 
    padding: 25px; 
    display: flex; 
    flex-direction: column; 
    height: 100vh; /* Forza l'altezza totale */
    overflow: hidden; /* Impedisce alla sidebar intera di scrollare */
}

.sidebar nav { 
    display: flex; 
    flex-direction: column; 
    flex-grow: 1; /* Prende tutto lo spazio disponibile */
    overflow-y: auto; /* Abilita lo scroll solo per la lista dei link */
    margin-right: -10px; /* Recupera spazio per la scrollbar */
    padding-right: 10px;
}

/* Personalizzazione Scrollbar per un look SaaS professionale */
.sidebar nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar nav::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 10px;
}
/* --- FIX CONTRASTO HOVER LISTA CLIENTI --- */

/* Assicuriamoci che le celle delle tabelle non perdano colore */
/* --- FIX CONTRASTO HOVER LISTA CLIENTI --- */

/* Assicuriamoci che le celle delle tabelle non perdano colore */
/* --- FIX DEFINITIVO TABELLA ANAGRAFICA CLIENTI --- */

/* 1. Stato Normale: Forza visibilità totale */
#view-gestione-clienti table td, 
#view-gestione-clienti table th {
    color: #ffffff !important; /* Bianco puro sempre */
    opacity: 1 !important;     /* Nessuna trasparenza */
    background-color: transparent !important;
    border-bottom: 1px solid var(--line) !important;
}

/* 2. Stato Hover: Evidenziazione senza sparizione */
#view-gestione-clienti table tr:hover td {
    background-color: rgba(96, 165, 250, 0.15) !important; /* Blu QF PRO leggero */
    color: var(--info) !important; /* Il testo diventa azzurro per feedback visivo */
    cursor: pointer;
}

/* 3. Rimozione interferenze Bootstrap */
#view-gestione-clienti .table {
    --bs-table-bg: transparent !important;
    --bs-table-color: #ffffff !important;
    color: #ffffff !important;
}

/* 4. Fix Etichette e Intestazioni */
#view-gestione-clienti thead th {
    color: var(--text-muted) !important;
    background-color: rgba(255,255,255,0.02) !important;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
}
/* --- OTTIMIZZAZIONE PULSANTI AZIONE TABELLA --- */
/* --- ICONE AZIONE SAAS --- */
.btn-action {
    border: none;
    border-radius: 6px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
    margin: 0 3px;
}

/* Icona Matita (Edit) */
.btn-edit {
    background: rgba(96, 165, 250, 0.15);
    color: var(--info);
}
.btn-edit:hover {
    background: var(--info);
    color: white;
    transform: scale(1.1);
}

/* Icona Cestino (Delete) */
.btn-delete {
    background: rgba(248, 113, 113, 0.15);
    color: var(--crit);
}
.btn-delete:hover {
    background: var(--crit);
    color: white;
    transform: scale(1.1);
}

/* Forza la dimensione dell'icona interna */
.btn-action i {
    font-size: 0.9rem;
}

/* Questa è la parte mancante che crea l'effetto visivo */
.flash-update {
    animation: flash-green 0.6s ease-out;
}

@keyframes flash-green {
    0% { 
        background: rgba(16, 185, 129, 0.4) !important; 
        box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
        transform: scale(1.03);
    }
    100% { 
        background: rgba(255, 255, 255, 0.03); 
        box-shadow: none;
        transform: scale(1);
    }
}

/* Assicuriamoci che le card abbiano una transizione fluida */
.card-mini, .card.shadow-sm {
    transition: all 0.3s ease;
}
/* Correzione visibilità tabella categorie/master */
.table-dark-custom {
    color: #e2e8f0 !important; /* Grigio chiaro quasi bianco */
    background-color: #1e293b !important; /* Blu scuro/notte invece di nero totale */
    border-color: #334155;
}

.table-dark-custom thead th {
    background-color: #0f172a;
    color: var(--info);
    border-bottom: 2px solid #334155;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.table-dark-custom tbody tr {
    background-color: #1e293b !important;
    border-bottom: 1px solid #334155;
    transition: background 0.2s;
}

/* Effetto Hover: Evita il "tutto nero" al passaggio del mouse */
.table-dark-custom tbody tr:hover {
    background-color: #92ABB9 !important; 
    color: #ffffff !important;
}

.table-dark-custom td {
    padding: 12px 8px;
    vertical-align: middle;
    color: #364154;
}

/* Forza il testo bianco nitido nella tabella categorie */
#table-categorie, 
#table-categorie-anagrafica {
    color: #ffffff !important;
}

#table-categorie thead th {
    color: var(--info); /* Le intestazioni le teniamo azzurre per gerarchia */
    border-bottom: 2px solid #334155;
    text-transform: uppercase;
    font-size: 0.8rem;
}

#table-categorie tbody td {
    color: #ffffff !important; /* Testo delle celle bianco puro */
    vertical-align: middle;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Evidenzia il nome della categoria */
#table-categorie tbody tr td:first-child {
    font-weight: 600;
    color: #f1f5f9 !important;
}

/* Colore delle percentuali (Pesi) per contrasto */
.text-peso-q { color: #38bdf8 !important; } /* Azzurro Qualità */
.text-peso-l { color: #fbbf24 !important; } /* Arancio Logistica */
.text-peso-e { color: #34d399 !important; } /* Verde ESG */
/* Box della notifica per simulare lo stile degli input */
/* Box della notifica armonizzato */
.custom-notification-box {
    background: var(--input-bg) !important;
    border: 1px solid var(--line) !important;
    /* Aumentiamo il padding sinistro per dare respiro alla levetta */
    padding: 12px 12px 12px 55px !important; 
    border-radius: 8px;
    display: flex;
    align-items: center;
    min-height: 48px;
    position: relative; /* Necessario per il posizionamento corretto dello switch */
    transition: all 0.2s;
}

/* Posizionamento preciso dello Switch */
.custom-notification-box .form-check-input {
    width: 1.1em !important;
    height: 1.1em !important;
    /* Lo stacchiamo dal bordo sinistro con un margine positivo */
    margin-left: -42px !important; 
    margin-top: 0 !important;
    background-color: #444 !important;
    border-color: var(--line) !important;
    cursor: pointer;
    flex-shrink: 0; /* Impedisce che si schiacci */
}

/* Colore attivo */
.custom-notification-box .form-check-input:checked {
    background-color: var(--info) !important;
    border-color: var(--info) !important;
}

/* Label del testo */
.custom-notification-box .form-check-label {
    color: #ffffff !important;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 0;
    user-select: none; /* Impedisce la selezione del testo al click */
}

/* Hover effetto per coerenza con focus input */
.custom-notification-box:hover {
    border-color: var(--info) !important;
}
/* Rendi i placeholder visibili e leggibili nel modal scuro */
#modalGestioneModelli .form-control::placeholder {
    color: #aaaaaa !important; /* Grigio chiaro visibile */
    opacity: 1; /* Forza l'opacità su Firefox */
    font-style: italic; /* Opzionale: li distingue dal testo digitato */
}

/* Specifico per Chrome, Safari e Edge */
#modalGestioneModelli .form-control::-webkit-input-placeholder {
    color: #aaaaaa !important;
}

/* Specifico per Firefox */
#modalGestioneModelli .form-control::-moz-placeholder {
    color: #aaaaaa !important;
}

/* Migliora anche il contrasto del testo digitato per sicurezza */
#modalGestioneModelli .form-control {
    color: #ffffff !important;
    border-color: #666 !important;
}

/* Effetto al focus per vedere bene dove si sta scrivendo */
#modalGestioneModelli .form-control:focus {
    background-color: #222 !important;
    border-color: #0ea5e9 !important; /* Azzurro info */
    box-shadow: 0 0 0 0.25rem rgba(14, 165, 233, 0.25);
    
/* --- VIEW CANDIDATURE - SPECIFIC SAAS THEME --- */

/* Forza lo sfondo del pannello e della tabella per evitare il bianco di Bootstrap */
/* --- VIEW CANDIDATURE - FULL RESET STILE CATEGORIE --- */

/* Forza il contenitore card allo stile "Categorie" */
#view-candidature .card {
    background-color: #1e293b !important;
    border: 1px solid #334155 !important;
    border-radius: 12px;
    box-shadow: none !important;
    overflow: hidden;
}

/* Rimoziome stili tabella standard Bootstrap */
#view-candidature .table {
    --bs-table-bg: #1e293b !important;
    --bs-table-color: #ffffff !important;
    background-color: #1e293b !important;
    color: #ffffff !important;
    border-color: #334155 !important;
    margin-bottom: 0 !important;
}

/* Intestazioni (Thead) - Identiche a Tabella Pesi */
#view-candidature thead th {
    background-color: #0f172a !important; /* Testata scura nitida */
    color: var(--info) !important;       /* Azzurro QF Pro */
    border-bottom: 2px solid #334155 !important;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 12px 15px !important;
}

/* Celle (Tbody) - Testo bianco puro e bordi sottili */
#view-candidature table td {
    background-color: #1e293b !important;
    color: #ffffff !important;
    vertical-align: middle;
    padding: 14px 15px !important;
    border-bottom: 1px solid #334155 !important;
}

/* --- EFFETTO HOVER IDENTICO A CATEGORIE --- */
#view-candidature table tbody tr {
    transition: background 0.2s ease;
}

#view-candidature table tbody tr:hover td {
    background-color: #2d3a4f !important; /* Grigio-blu scuro per contrasto */
    color: #ffffff !important;
    cursor: pointer;
}

/* Badge di stato dinamici (Stile Pill SaaS) */
.status-nuova { 
    background: rgba(96, 165, 250, 0.2) !important; 
    color: #60a5fa !important; 
    border: 1px solid rgba(96, 165, 250, 0.3) !important;
    padding: 4px 10px; border-radius: 6px; font-size: 0.7rem; font-weight: 700;
}

.status-in-revisione { 
    background: rgba(251, 191, 36, 0.2) !important; 
    color: #fbbf24 !important; 
    border: 1px solid rgba(251, 191, 36, 0.3) !important;
    padding: 4px 10px; border-radius: 6px; font-size: 0.7rem; font-weight: 700;
}

.status-approvata { 
    background: rgba(34, 197, 94, 0.2) !important; 
    color: #22c55e !important; 
    border: 1px solid rgba(34, 197, 94, 0.3) !important;
    padding: 4px 10px; border-radius: 6px; font-size: 0.7rem; font-weight: 700;
}

.status-rifiutata { 
    background: rgba(248, 113, 113, 0.2) !important; 
    color: #f87171 !important; 
    border: 1px solid rgba(248, 113, 113, 0.3) !important;
    padding: 4px 10px; border-radius: 6px; font-size: 0.7rem; font-weight: 700;
}

/* Link Allegati PDF */
.btn-outline-primary {
    border: 1px solid #38bdf8 !important;
    color: #38bdf8 !important;
    background: transparent !important;
    font-size: 0.8rem;
    padding: 4px 10px;
}

.btn-outline-primary:hover {
    background: #38bdf8 !important;
    color: #0f172a !important;
}

/* Pulsanti Azione coordinati */
#view-candidature .btn-success {
    background: rgba(34, 197, 94, 0.15) !important;
    color: #4ade80 !important;
    border: 1px solid rgba(34, 197, 94, 0.3) !important;
    margin-left: 5px;
}

#view-candidature .btn-danger {
    background: rgba(248, 113, 113, 0.15) !important;
    color: #f87171 !important;
    border: 1px solid rgba(248, 113, 113, 0.3) !important;
    margin-left: 5px;
}

/* Badge Contatore in alto */
#count-candidature {
    background: #0ea5e9 !important;
    color: #ffffff !important;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 6px;
}

/* Status Legacy (Compatibilità) */
.status-aperta { color: #f87171 !important; font-weight: bold; }
.status-chiusa { color: #4ade80 !important; font-weight: bold; }

.mobile-header { display: none !important; }

.app-layout { 
    display: grid; 
    grid-template-columns: 280px 1fr; 
    height: 100vh; 
}

/* 1. Forza la colonna a non allungarsi (fondamentale per Flexbox) */
.col-md-4.sticky-form-container {
    align-self: flex-start !important;
    position: relative !important; /* Serve come binario per la card */
    overflow: visible !important;
}