/* === ÉCLAIREUR CITOYEN — Theme sombre investigation === */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #1c2128;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border: #30363d;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --red: #f85149;
    --red-bg: rgba(248, 81, 73, 0.1);
    --yellow: #d29922;
    --yellow-bg: rgba(210, 153, 34, 0.1);
    --green: #3fb950;
    --green-bg: rgba(63, 185, 80, 0.1);
    --orange: #d18616;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* === HEADER === */

header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

h1 .icon {
    font-size: 1.3rem;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

select, button {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

select:hover, button:hover {
    border-color: var(--accent);
}

button:active {
    background: var(--bg-secondary);
}

/* === ALERTS BANNER === */

.alerts-banner {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
}

.alerts-banner.hidden { display: none; }

.alerts-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.alert-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.alert-badge.critical {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red);
}

.alert-badge.warning {
    background: var(--yellow-bg);
    color: var(--yellow);
    border: 1px solid var(--yellow);
}

.alerts-list {
    list-style: none;
    font-size: 0.85rem;
}

.alerts-list li {
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alerts-list li:last-child { border-bottom: none; }

.alert-icon-critical::before { content: "\1F534"; }
.alert-icon-warning::before { content: "\1F7E1"; }
.alert-icon-info::before { content: "\1F535"; }

/* === LOADING === */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--text-secondary);
}

.loading.hidden { display: none; }

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === TABS === */

.tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    overflow-x: auto;
}

.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 0;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* === MAIN CONTENT === */

main {
    padding: 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.count-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

/* === CHARTS === */

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.chart-full {
    margin-bottom: 1.5rem;
}

/* === TABLES === */

.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead th {
    background: var(--bg-tertiary);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

tbody td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

tbody tr:hover {
    background: var(--bg-tertiary);
}

tbody tr:last-child td { border-bottom: none; }

/* Signalement cells */
.flag-none { color: var(--green); }
.flag-warning { color: var(--yellow); font-weight: 600; }
.flag-critical { color: var(--red); font-weight: 600; }

.link-detected {
    background: var(--yellow-bg);
    border-left: 3px solid var(--yellow);
}

/* === BUDGET CARDS === */

.budget-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.budget-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.budget-card .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.budget-card .value {
    font-size: 1.4rem;
    font-weight: 700;
}

.budget-card .trend {
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

.trend-up { color: var(--red); }
.trend-down { color: var(--green); }
.trend-stable { color: var(--text-muted); }

/* === ANALYSE === */

#analyse-results {
    margin-bottom: 2rem;
}

.analyse-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.analyse-card.critical {
    border-left: 4px solid var(--red);
}

.analyse-card.warning {
    border-left: 4px solid var(--yellow);
}

.analyse-card.info {
    border-left: 4px solid var(--accent);
}

.analyse-card h4 {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analyse-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.analyse-card .details {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* === METHODOLOGY === */

.methodology {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.methodology h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.methodology h4 {
    margin: 1rem 0 0.5rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.methodology ul {
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.methodology li {
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.methodology a {
    color: var(--accent);
    text-decoration: none;
}

.methodology a:hover {
    text-decoration: underline;
}

/* === FOOTER === */

footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1.5rem 2rem;
    margin-top: 2rem;
}

.disclaimer {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.7;
}

.sources-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* === RESPONSIVE === */

@media (max-width: 768px) {
    header {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .controls {
        width: 100%;
    }

    select {
        flex: 1;
    }

    .tabs {
        padding: 0 0.5rem;
    }

    .tab {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }

    main {
        padding: 1rem;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    table {
        font-size: 0.75rem;
    }

    thead th, tbody td {
        padding: 0.5rem;
    }

    .budget-cards {
        grid-template-columns: 1fr 1fr;
    }
}

/* === EMPTY STATE === */

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
}

/* === TOOLTIP === */

.tooltip {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--text-muted);
}

.tooltip:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 10;
    color: var(--text-primary);
}
