/* --- css/dashboard.css (Versione Definitiva) --- */

:root {
    --sidebar-width: 260px;
    --sidebar-closed: 80px;
    --header-height: 70px;
    --radius-card: 16px;
}

body {
    overflow-x: hidden;
    touch-action: pan-x pan-y;
    -webkit-text-size-adjust: 100%;
}

/* --- MAIN CONTENT & HEADER FISSO --- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1), width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;

    /* Forza i tuoi esatti colori Light originali solo per quest'area */
    --bg-deep: #f8fafc;
    --bg-surface: #ffffff;
    --neon-blue: #0052D4;
    --neon-cyan: #06b6d4;
    --text-main: #0f172a;
    --text-dim: #64748b;
    --border-color: #e2e8f0;
    --input-bg: #f8fafc;
    --orb-glow: rgba(0, 82, 212, 0.1);
    --shadow-color: rgba(0,0,0,0.05);

    background-color: var(--bg-deep) !important;
    color: var(--text-main) !important;
}

.top-header {
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    
    /* REGOLE HEADER FISSO */
    position: fixed;
    top: 0;
    right: 0;
    width: calc(100% - var(--sidebar-width));
    z-index: 1001;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.content-area {
    margin-top: var(--header-height); /* Compensa l'header fisso */
    padding: 30px 40px; /* Il tuo padding originale */
}

/* --- SIDEBAR --- */
/* (Mantiene i colori dinamici del body, così il tasto tema continua a funzionare) */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-deep);
    color: var(--text-main);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    z-index: 2000;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    white-space: nowrap;
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 20px rgba(0,0,0,0.08); /* L'ombra di profondità */
}

.brand-area { height: var(--header-height); min-height: var(--header-height); flex-shrink: 0; display: flex; align-items: center; padding-left: 24px; font-size: 1.5rem; font-weight: 800; letter-spacing: 0.5px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); background: rgba(0, 0, 0, 0.15); }
.brand-icon { font-size: 1.4rem; min-width: 30px; display: flex; justify-content: center; margin-right: 12px; transform: rotate(-10deg); color: transparent; background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue)); -webkit-background-clip: text; filter: drop-shadow(0 0 5px var(--orb-glow)); }
.nav-menu { padding-top: 10px; flex-grow: 1; width: 100%; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.nav-item { display: flex; align-items: center; padding: 0 24px; height: 50px; color: var(--text-dim); text-decoration: none; transition: all 0.2s; border-left: 3px solid transparent; }
.nav-item:hover { color: var(--text-main); background: var(--input-bg); }
.nav-item.active { color: var(--text-main); background: linear-gradient(90deg, var(--orb-glow), transparent); border-left-color: var(--neon-cyan); font-weight: 600; }
.nav-item.active i { color: transparent; background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue)); -webkit-background-clip: text; }
.nav-item i { min-width: 24px; font-size: 1.1rem; margin-right: 12px; display: flex; justify-content: center; transition: margin 0.3s; }
.nav-text { opacity: 1; transition: opacity 0.2s; }

/* LOGICA COLLAPSE DESKTOP */
body.is-collapsed .sidebar { width: var(--sidebar-closed); }
body.is-collapsed .main-content { margin-left: var(--sidebar-closed); width: calc(100% - var(--sidebar-closed)); }
body.is-collapsed .top-header { width: calc(100% - var(--sidebar-closed)); }
body.is-collapsed .nav-text, body.is-collapsed .brand-text { display: none; }
body.is-collapsed .nav-item { padding: 0; justify-content: center; }
body.is-collapsed .nav-item i { margin-right: 0; }
body.is-collapsed .brand-area { padding-left: 0; justify-content: center; }
body.is-collapsed .brand-icon { margin-right: 0; font-size: 1.6rem; }

/* INTERFACCIA E UTENTE */
#menu-toggle { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--text-dim); padding: 8px; border-radius: 8px; transition: 0.2s; position: relative; z-index: 1002; margin-right: 10px; }
#menu-toggle:hover { background: var(--bg-deep); color: var(--neon-cyan); }
.company-name-block { flex-grow: 1; margin-left: 10px; }
.company-name-block h2 { color: var(--text-main) !important; }
.client-logo-container { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; justify-content: center; height: 100%; pointer-events: none; }
.client-logo { max-height: 40px; max-width: 180px; object-fit: contain; }

.user-profile-container { position: relative; display: flex; align-items: center; }
.user-profile { display: flex; align-items: center; gap: 12px; cursor: pointer; color: var(--text-main); font-weight: 600; font-size: 0.9rem; padding: 5px 10px; border-radius: 8px; transition: 0.2s; }
.user-profile:hover { background: var(--bg-deep); }
.avatar { width: 38px; height: 38px; border-radius: 50%; color: white; background: linear-gradient(135deg, var(--neon-blue), var(--neon-cyan)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-dropdown { position: absolute; top: 110%; right: 0; background: var(--bg-surface); width: 200px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); border: 1px solid var(--border-color); opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all 0.2s; z-index: 2000; }
.user-dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--text-main); text-decoration: none; font-size: 0.9rem; transition: 0.2s; }
.dropdown-item:hover { background: var(--bg-deep); color: var(--neon-cyan); }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 4px 0; }
.dropdown-item.danger { color: #ef4444; }
.dropdown-item.danger:hover { background: rgba(239, 68, 68, 0.1); }

/* --- CARDS E HERO SECTION --- */
.card-widget, .hero-section { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-card); box-shadow: 0 10px 30px rgba(0,0,0,0.03); min-width: 0; }
.widget-title { color: var(--text-main); font-weight: 800; }
.list-row { color: var(--text-dim); }

.hero-section { padding: 30px; margin-bottom: 30px; display: flex; align-items: center; justify-content: space-between; gap: 20px; position: relative; overflow: hidden; }
.hero-section::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 40%; background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.05)); z-index: 0; pointer-events: none; }
.hero-text { z-index: 1; max-width: 400px; }
.hero-controls { z-index: 1; display: flex; align-items: center; gap: 12px; }

/* TYPOGRAPHY "NUOVO PREVENTIVO" BLINDATA DA BOOTSTRAP */
.hero-text h1 {
    font-family: 'Inter', sans-serif !important;
    font-size: 2.2rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.5px !important;
    margin-bottom: 6px !important;
    color: var(--text-main) !important;
    line-height: 1.2 !important;
}

.hero-text p {
    font-family: 'Inter', sans-serif !important;
    font-size: 0.95rem !important;
    color: var(--text-dim) !important;
    margin: 0 !important;
    font-weight: 400 !important;
}

/* Input Targa Originale (Altezza 60px) */
.combined-input-group { display: flex; align-items: center; background: #ffffff; border: 1px solid var(--border-color); border-radius: 12px; padding: 4px; transition: all 0.3s ease; height: 60px; }
.combined-input-group:focus-within { border-color: var(--neon-cyan); box-shadow: 0 0 15px var(--orb-glow); }
.plate-box { width: 160px; height: 100%; border-right: 1px solid var(--border-color); position: relative; margin-right: 8px; }
.plate-strip { position: absolute; top: 2px; bottom: 2px; width: 14px; background: #003399; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 2; border-radius: 4px; }
.plate-strip.left { left: 4px; }
.plate-strip.right { right: 4px; }
.plate-strip i { color: #fbbf24; font-size: 8px; margin-bottom: 2px; }
.plate-strip span { color: white; font-size: 8px; font-weight: bold; }
.plate-input { width: 100%; height: 100%; border: none; text-align: center; font-family: 'Consolas', monospace; font-size: 1.4rem; font-weight: 700; text-transform: uppercase; color: var(--text-main); background: transparent; outline: none; letter-spacing: 2px; }
.plate-input::placeholder { color: var(--text-dim); font-weight: 400; opacity: 0.6; }

.type-selector { display: flex; gap: 4px; padding-right: 4px; height: 100%; align-items: center; }
.type-icon-btn { background: transparent; border: none; color: var(--text-dim); width: 44px; height: 44px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: all 0.2s; }
.type-icon-btn i { font-size: 1.1rem; margin-bottom: 2px; }
.type-icon-btn span { font-size: 0.6rem; font-weight: 600; text-transform: uppercase; }
.type-icon-btn.active { background: var(--orb-glow); color: var(--neon-blue); }
.btn-primary { background: linear-gradient(90deg, var(--neon-blue), var(--neon-cyan)) !important; border: none !important; color: white !important; }

/* --- SPAZIATURE GRIGLIA BOOTSTRAP --- */
.kpi-row { --bs-gutter-x: 20px; --bs-gutter-y: 20px; margin-bottom: 30px; }
.widget-row { --bs-gutter-x: 24px; --bs-gutter-y: 24px; }

/* --- KPI CARDS ORIGINALI --- */
.kpi-card { display: flex; flex-direction: column; padding: 20px; height: 100%; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-card); box-shadow: 0 10px 30px rgba(0,0,0,0.03); transition: transform 0.2s, box-shadow 0.2s; }
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 15px 35px rgba(0,0,0,0.06); }
.kpi-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.kpi-title { font-size: 0.75rem; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin: 0; }
.kpi-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.kpi-icon.blue { background: rgba(6, 182, 212, 0.1); color: var(--neon-cyan); }
.kpi-icon.green { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.kpi-icon.purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.kpi-card-body { margin-bottom: 15px; }
.kpi-value { font-size: 2.2rem; font-weight: 800; line-height: 1; color: var(--text-main); }
.kpi-card-footer { padding-top: 15px; border-top: 1px solid var(--border-color); font-size: 0.75rem; }
.kpi-status.ok { color: #10b981; font-weight: 600; }
.kpi-status.trend-up { color: #10b981; font-weight: 700; }
.kpi-status.trend-down { color: #ef4444; font-weight: 700; }
.kpi-status i { margin-right: 4px; }

/* --- WIDGETS ORIGINALI --- */
.card-widget { padding: 24px; height: 100%; display: flex; flex-direction: column; }
.chart-container { position: relative; height: 250px; width: 100%; }

/* Radar Gamification (Sempre Scuro) */
.game-card { background: linear-gradient(165deg, #0f172a, #1e293b) !important; color: white !important; border: 1px solid rgba(6, 182, 212, 0.3) !important; padding: 24px; border-radius: var(--radius-card); position: relative; }
.game-card .widget-title, .game-card .rank-value { color: white !important; }
.game-card .text-main, .game-card div { color: white !important; }
.perf-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.user-rank-box { text-align: right; }
.rank-value { font-size: 1.1rem; font-weight: 800; color: #fbbf24 !important; text-shadow: 0 0 10px rgba(251, 191, 36, 0.3); }
.target-section { margin-top: auto; }
.target-header { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 8px; color: white; font-weight: 600; }
.target-track { width: 100%; height: 12px; background: rgba(0,0,0,0.4); border-radius: 6px; position: relative; overflow: hidden; border: 1px solid rgba(255,255,255,0.1); }
.target-bar { height: 100%; width: 68%; background: linear-gradient(90deg, var(--neon-blue), var(--neon-cyan)); border-radius: 6px; box-shadow: 0 0 15px var(--neon-blue); position: relative; }

/* Task Card */
.task-card { border-top: 3px solid var(--neon-blue) !important; background: linear-gradient(180deg, rgba(59, 130, 246, 0.03) 0%, var(--bg-surface) 100%); }
.task-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg-deep); border-radius: 10px; margin-bottom: 10px; border: 1px solid var(--border-color); transition: transform 0.2s, box-shadow 0.2s; }
.task-item:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.05); border-color: var(--neon-cyan); }
.task-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.task-icon.warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.task-icon.danger { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.task-icon.info { background: rgba(6, 182, 212, 0.1); color: var(--neon-cyan); }
.task-icon.dark { background: rgba(100, 116, 139, 0.1); color: #64748b; }
.task-text { flex: 1; display: flex; flex-direction: column; }
.task-text strong { font-size: 0.85rem; color: var(--text-main); }
.task-text span { font-size: 0.7rem; color: var(--text-dim); line-height: 1.3; margin-top: 2px; }

/* --- MOBILE QUERIES --- */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); width: 280px; }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; width: 100% !important; }
    body.is-collapsed .main-content { margin-left: 0; width: 100% !important; }
    
    .top-header { height: auto; min-height: 70px; flex-wrap: nowrap; padding: 10px 15px; align-items: center; gap: 15px; width: 100% !important; }
    body.is-collapsed .top-header { width: 100% !important; }
    
    #menu-toggle, .user-profile-container { order: unset; margin: 0; flex-shrink: 0; }
    .company-name-block { order: unset; width: auto; flex: 1; margin: 0; padding: 0; text-align: center; display: flex; align-items: center; justify-content: center; }
    .company-name-block h2 { font-size: 1rem !important; white-space: normal; line-height: 1.2; word-break: break-word; }
    .user-name, .user-profile .fa-chevron-down, .client-logo-container { display: none; }
    .user-profile { padding: 0; gap: 0; }

    .content-area, .hero-section { padding: 20px; }
    .hero-section { flex-direction: column; text-align: center; }
    .hero-controls { flex-direction: column; width: 100%; gap: 15px; }

    .combined-input-group { flex-direction: column; width: 100%; height: auto; padding: 0; gap: 15px; background: transparent; border: none; }
    .plate-box { width: 100%; height: 60px; border: 1px solid var(--border-color); border-radius: 8px; margin: 0; background: white; }
    .type-selector { width: 100%; background: white; border: 1px solid var(--border-color); border-radius: 8px; padding: 5px; justify-content: space-between; height: 60px; }
    .type-icon-btn { flex: 1; height: 100%; }
    
    input, select, textarea { font-size: 16px !important; }
    
    .mobile-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 1500; opacity: 0; pointer-events: none; transition: 0.3s; }
    .mobile-overlay.active { opacity: 1; pointer-events: auto; }
}