/* =========================================
   1. VARIABILI (TEMA CHIARO FISSO)
   ========================================= */
:root {
    /* Sfondi Chiari */
    --bg-body: #f8fafc;       /* Grigio chiarissimo quasi bianco */
    --bg-card: #ffffff;       /* Bianco puro */
    --bg-header: rgba(255, 255, 255, 0.95);
    --bg-input: #f1f5f9;
    
    /* Testi Scuri (per contrasto su sfondo chiaro) */
    --text-main: #0f172a;     /* Blu notte molto scuro */
    --text-muted: #64748b;    /* Grigio scuro */
    --border: #e2e8f0;        /* Grigio molto chiaro per i bordi */
    
    /* Accenti */
    --primary: #3b82f6;       /* Blu */
    --primary-glow: rgba(59, 130, 246, 0.15);
    --success: #22c55e;       /* Verde */
    --danger: #ef4444;        /* Rosso */
    --highlight: #f59e0b;     /* Arancio */
    
    /* Mappa */
    --map-bg: #e2e8f0;
}

/* =========================================
   2. BASE & LAYOUT
   ========================================= */
* { box-sizing: border-box; }
body { 
    margin: 0; padding: 0; 
    font-family: 'Inter', system-ui, sans-serif; 
    background: var(--bg-body); 
    color: var(--text-main);
}

/* HEADER */
.app-header {
    height: 64px; background: var(--bg-header); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
    position: fixed; top: 0; width: 100%; z-index: 9999; backdrop-filter: blur(10px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.logo { font-weight: 800; font-size: 1.2rem; display: flex; align-items: center; gap: 10px; color: var(--text-main); }
.logo-highlight { color: var(--primary); } /* Blu Luxottica */
.header-controls { display: flex; align-items: center; gap: 20px; }

.user-profile { display: flex; align-items: center; gap: 10px; }
.user-avatar { 
    width: 32px; height: 32px; background: var(--primary); color: #fff; 
    border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-name { font-size: 0.9rem; font-weight: 600; color: var(--text-main); }

/* MAPPA HERO */
.map-section {
    margin-top: 64px; width: 100%; height: 50vh; background: var(--map-bg); position: relative;
    border-bottom: 1px solid var(--border);
}
#europeMap { width: 100%; height: 100%; z-index: 1; }

.map-title-overlay {
    position: absolute; top: 24px; left: 24px; z-index: 500;
    background: rgba(255, 255, 255, 0.9); padding: 20px 24px; border-radius: 12px;
    border: 1px solid var(--border); pointer-events: none; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.08); backdrop-filter: blur(4px);
}
.map-title-overlay h1 { margin: 0; font-size: 1.4rem; font-weight: 800; color: var(--text-main); }
.map-title-overlay p { margin: 6px 0 0; color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }

.marker-pin {
    background: var(--primary); border: 2px solid #fff; color: #fff;
    border-radius: 50%; width: 34px; height: 34px; text-align: center; font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center; 
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.4);
    transition: transform 0.2s; cursor: pointer;
}
.marker-pin:hover { transform: scale(1.3); z-index: 100; background: #0f172a; color: #fff; border-color: #0f172a; }
.marker-pin.active { background: var(--success); transform: scale(1.2); border-color: #fff; }

/* DASHBOARD BODY */
.dashboard-body { padding: 30px; max-width: 1600px; margin: 0 auto; }

/* =========================================
   3. BARRA FILTRI
   ========================================= */
.filters-toolbar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 24px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.filter-label { font-weight: 700; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
.date-range-group { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.input-wrapper { display: flex; align-items: center; gap: 8px; }
.input-wrapper label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }

.date-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    font-weight: 500;
}
.date-input:focus { border-color: var(--primary); background: #fff; }

/* =========================================
   4. KPI & GRAFICI
   ========================================= */
.kpi-container {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px; margin-bottom: 30px;
}
.kpi-box {
    background: var(--bg-card); padding: 24px; border-radius: 16px; 
    border: 1px solid var(--border); text-align: center; transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.kpi-box:hover { transform: translateY(-3px); box-shadow: 0 10px 15px rgba(0,0,0,0.05); }
.kpi-val { display: block; font-size: 1.8rem; font-weight: 800; margin-bottom: 8px; color: var(--text-main); }
.kpi-label { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; font-weight: 700; letter-spacing: 0.5px; }
.kpi-highlight { border-color: var(--primary); background: #eff6ff; }

.charts-container {
    display: grid; grid-template-columns: 2.5fr 1fr; gap: 24px; margin-bottom: 30px;
}
.chart-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
    padding: 24px; display: flex; flex-direction: column;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.chart-header h3 { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--text-main); }

.filter-badge {
    background: var(--primary); color: #fff; padding: 4px 10px; 
    border-radius: 20px; font-size: 0.75rem; font-weight: 600;
}

.canvas-box { position: relative; height: 340px; width: 100%; flex-shrink: 0; margin-bottom: 20px; }

/* Controlli Flag */
.chart-controls {
    margin-top: auto; padding-top: 20px; border-top: 1px solid var(--border);
    display: flex; gap: 30px; flex-wrap: wrap;
}
.control-group label {
    display: block; color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase;
    font-weight: 700; margin-bottom: 10px;
}
.btn-row { display: flex; gap: 8px; }

.btn-flag {
    background: transparent; border: 1px solid var(--border); color: var(--text-muted);
    padding: 8px 16px; border-radius: 50px; cursor: pointer; font-size: 0.8rem; font-weight: 600;
    transition: all 0.2s; display: flex; align-items: center; gap: 6px;
}
.btn-flag:hover { background: var(--bg-input); color: var(--text-main); border-color: #cbd5e1; }
.btn-flag.active { color: #fff; border-color: transparent; }
.btn-flag.active.btn-blue { background: var(--primary); box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3); }
.btn-flag.active.btn-green { background: var(--success); box-shadow: 0 4px 10px rgba(34, 197, 94, 0.3); }
.btn-flag.active.btn-red { background: var(--danger); box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3); }
.btn-flag.active.btn-subtle { background: #64748b; box-shadow: 0 4px 10px rgba(100, 116, 139, 0.3); }

.stats-footer {
    margin-top: 20px; background: var(--bg-input); border-radius: 12px; padding: 15px;
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; border: 1px solid var(--border);
}
.stat-item small { display: block; color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; font-weight: 700; }
.stat-item strong { display: block; font-size: 1.1rem; margin-top: 4px; color: var(--text-main); font-weight: 800; }

/* =========================================
   5. TABELLA
   ========================================= */
.table-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 24px; box-shadow: 0 2px 4px rgba(0,0,0,0.03); }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

.data-table thead th {
    text-align: left; color: var(--text-muted); padding: 16px 12px;
    border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-card);
    font-weight: 700; text-transform: uppercase; font-size: 0.75rem;
    vertical-align: middle;
}

.data-table td { 
    padding: 14px 12px; border-bottom: 1px solid var(--border); color: var(--text-main);
    vertical-align: middle; font-weight: 500;
}

.data-table tr:hover td { background: #f8fafc; }

/* CLASSI UTILI */
.text-right { text-align: right; }
.text-center { text-align: center !important; }
.text-green { color: var(--success); }
.text-red { color: var(--danger); }

.form-floating {
	margin-bottom: 5px;
}
.gb_form-container {
	text-align: center;
	padding: 10%;
	width:800px;
	margin: 0px auto;
}

.dropdown-menu {
	display: none;
}

@media(max-width: 1000px) {
    .charts-container { grid-template-columns: 1fr; }
    .chart-controls { flex-direction: column; gap: 20px; }
    .filters-toolbar { flex-direction: column; align-items: flex-start; }
    .date-range-group { width: 100%; justify-content: space-between; }
}