/* ============================
   LOUPWATCH — STYLESHEET
   Style : sobre, institutionnel
   Palette : navy, gris, blanc, rouge alerte
   Police : Inter (sans-serif)
   ============================ */

:root {
    --c-navy: #1B2A4A;
    --c-navy-light: #2D4068;
    --c-blue: #3B6BA5;
    --c-blue-light: #5B8BC5;
    --c-red: #C53030;
    --c-red-light: #E53E3E;
    --c-orange: #DD6B20;
    --c-dark: #1E2330;
    --c-text: #3A3F4B;
    --c-text-light: #6B7280;
    --c-text-muted: #9CA3AF;
    --c-white: #FFFFFF;
    --c-bg: #F8F9FB;
    --c-bg-alt: #F1F3F7;
    --c-border: #E2E5EA;
    --c-border-light: #EDF0F4;
    --c-green: #2F855A;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(27, 42, 74, 0.06);
    --shadow-md: 0 4px 16px rgba(27, 42, 74, 0.08);
    --shadow-lg: 0 12px 40px rgba(27, 42, 74, 0.12);
    --transition: 0.3s ease;
    --max-width: 1400px;
}

/* ---------- RESET ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    color: var(--c-text);
    background: var(--c-bg);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: var(--c-blue); transition: var(--transition); }
a:hover { color: var(--c-navy); }
ul { list-style: none; }

/* ---------- LAYOUT ---------- */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

/* ---------- HEADER ---------- */
.header { position: sticky; top: 0; z-index: 1000; }

.header__bar {
    background: var(--c-navy);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--c-white);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo__icon { font-size: 1.3rem; }
.logo__accent { color: var(--c-blue-light); font-weight: 400; }

.header__info {
    display: flex;
    align-items: center;
    gap: 24px;
}

.header__zone {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.02em;
}

.header__live {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.8);
}

.header__link {
    font-size: 0.78rem;
    color: var(--c-blue-light);
    padding: 4px 12px;
    border: 1px solid rgba(91, 139, 197, 0.3);
    border-radius: 4px;
    transition: var(--transition);
}

.header__link:hover {
    background: rgba(91, 139, 197, 0.1);
    color: var(--c-white);
}

/* Attack detail panel */
.attack-row { cursor: pointer; transition: background 0.15s; }
.attack-row:hover { background: var(--c-bg-alt) !important; }
.attack-row:active { background: rgba(59, 107, 165, 0.05) !important; }

.detail-row > td { padding: 0 !important; border: none !important; }

.detail-panel {
    background: var(--c-bg-alt);
    border-top: 2px solid var(--c-blue);
    padding: 20px 24px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--c-text-muted);
}

.detail-value {
    font-size: 0.88rem;
    color: var(--c-text);
    font-weight: 500;
}

.detail-value.text-red { color: var(--c-red); font-weight: 600; }

.severity {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}
.severity--critique { background: rgba(197, 48, 48, 0.12); color: var(--c-red); }
.severity--grave { background: rgba(221, 107, 32, 0.12); color: var(--c-orange); }
.severity--modérée { background: rgba(59, 107, 165, 0.1); color: var(--c-blue); }
.severity--mineure { background: var(--c-bg-alt); color: var(--c-text-muted); }

.detail-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid var(--c-border);
}

.detail-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    background: var(--c-white);
    border: 1px solid var(--c-border);
    color: var(--c-blue);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.detail-link:hover {
    background: var(--c-blue);
    color: var(--c-white);
    border-color: var(--c-blue);
}

.detail-link--btn {
    font-family: var(--font);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--c-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(47, 133, 90, 0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(47, 133, 90, 0); }
}

/* ---------- STATS BAR ---------- */
.stats-bar {
    background: var(--c-white);
    border-bottom: 1px solid var(--c-border);
    box-shadow: var(--shadow-sm);
}

.stats-bar__inner {
    display: flex;
    justify-content: space-between;
    padding: 20px 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.stat-block { text-align: center; flex: 1; min-width: 120px; }

.stat-block__num {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--c-navy);
    letter-spacing: -0.02em;
}

.stat-block__label {
    font-size: 0.75rem;
    color: var(--c-text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---------- FILTERS ---------- */
.filters {
    background: var(--c-bg-alt);
    border-bottom: 1px solid var(--c-border);
    padding: 14px 0;
}

.filters__inner {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-search { flex: 1; min-width: 180px; }

.filter-group label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--c-navy);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-select, .filter-input {
    padding: 8px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.88rem;
    color: var(--c-text);
    background: var(--c-white);
    transition: var(--transition);
    cursor: pointer;
}

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3px rgba(59, 107, 165, 0.08);
}

.filter-input { cursor: text; }

/* ---------- MAIN CONTENT ---------- */
.main-content { padding: 24px 0; }

.main-content__inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ---------- MAP PANEL ---------- */
.map-panel {
    background: var(--c-white);
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.map-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--c-border-light);
}

.map-panel__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--c-navy);
}

.map-legend { display: flex; gap: 14px; }

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: var(--c-text-light);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid var(--c-white);
}

.legend-dot--recent { background: #FF0000; }
.legend-dot--month { background: #FF8C00; }
.legend-dot--old { background: #8B4513; }

#map { width: 100%; height: 520px; }

/* Mapbox popup overrides */
.mapboxgl-popup-content {
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-md) !important;
    padding: 0 !important;
}

.map-popup { padding: 14px 16px; min-width: 200px; }

.map-popup__date {
    font-weight: 600;
    color: var(--c-navy);
    font-size: 0.88rem;
    margin-bottom: 4px;
}

.map-popup__commune { font-size: 0.82rem; color: var(--c-text); margin-bottom: 2px; }
.map-popup__lieu { font-size: 0.78rem; color: var(--c-text-light); margin-bottom: 2px; }
.map-popup__type {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--c-blue);
    background: rgba(59, 107, 165, 0.07);
    padding: 2px 8px;
    border-radius: 4px;
    margin: 4px 0;
}

.map-popup__victims { font-size: 0.82rem; color: var(--c-text); margin-top: 6px; }
.map-popup__victims span { display: block; }
.map-popup__victims .killed { color: var(--c-red); font-weight: 600; }

.map-popup__meta {
    font-size: 0.72rem;
    color: var(--c-text-muted);
    margin-top: 6px;
    border-top: 1px solid var(--c-border-light);
    padding-top: 6px;
}

/* ---------- TABLE PANEL ---------- */
.table-panel {
    background: var(--c-white);
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.table-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--c-border-light);
}

.table-panel__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--c-navy);
}

.table-panel__count {
    font-size: 0.78rem;
    color: var(--c-text-light);
}

.table-wrap {
    overflow: auto;
    max-height: 520px;
}

.attacks-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.attacks-table thead {
    position: sticky;
    top: 0;
    background: var(--c-bg-alt);
    z-index: 10;
}

.attacks-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--c-navy);
    border-bottom: 1px solid var(--c-border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.attacks-table th:hover { background: var(--c-border-light); }
.attacks-table th.num { text-align: right; }

.attacks-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--c-border-light);
    color: var(--c-text);
    white-space: nowrap;
}

.attacks-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.attacks-table tbody tr { transition: background 0.15s; }
.attacks-table tbody tr:hover { background: var(--c-bg-alt); }

.attacks-table .killed-cell { color: var(--c-red); font-weight: 600; }
.attacks-table .killed-cell.zero { color: var(--c-text-muted); font-weight: 400; }

.attacks-table .type-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(59, 107, 165, 0.07);
    color: var(--c-blue);
}

.attacks-table .prec-badge {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 3px;
}
.attacks-table .prec-badge.fiable { background: rgba(47, 133, 90, 0.1); color: var(--c-green); }
.attacks-table .prec-badge.approximative { background: rgba(221, 107, 32, 0.1); color: var(--c-orange); }
.attacks-table .prec-badge.NA { background: var(--c-bg-alt); color: var(--c-text-muted); }

.loading-row { text-align: center; padding: 40px; color: var(--c-text-muted); }

/* ---------- CHARTS ---------- */
.charts-section { padding: 0 0 32px; }

.charts-section__inner {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
}

.chart-panel {
    background: var(--c-white);
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.chart-panel__title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--c-navy);
    margin-bottom: 16px;
}

.chart-container { min-height: 200px; }

/* Bar chart (CSS only) */
.bar-chart { display: flex; flex-direction: column; gap: 6px; }

.bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
}

.bar-row__label { width: 90px; text-align: right; color: var(--c-text-light); flex-shrink: 0; }
.bar-row__track { flex: 1; height: 20px; background: var(--c-bg-alt); border-radius: 4px; overflow: hidden; }
.bar-row__fill { height: 100%; background: var(--c-blue); border-radius: 4px; transition: width 0.5s ease; }
.bar-row__fill.red { background: var(--c-red); }
.bar-row__value { width: 50px; font-weight: 600; color: var(--c-navy); font-variant-numeric: tabular-nums; }

/* ---------- FOOTER ---------- */
.footer {
    background: var(--c-navy);
    color: rgba(255, 255, 255, 0.5);
    padding: 24px 0;
    font-size: 0.78rem;
    text-align: center;
}

.footer a { color: var(--c-blue-light); }
.footer p { margin-bottom: 4px; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
    .main-content__inner { grid-template-columns: 1fr; }
    .charts-section__inner { grid-template-columns: 1fr; }
    #map { height: 400px; }
}

@media (max-width: 768px) {
    .stats-bar__inner { gap: 8px; }
    .stat-block { min-width: 100px; }
    .stat-block__num { font-size: 1.4rem; }
    .filters__inner { gap: 10px; }
    .filter-group { flex: 1; min-width: 120px; }
    .header__zone { display: none; }
    .table-wrap { max-height: 400px; }
    .attacks-table { font-size: 0.75rem; }
    .attacks-table th, .attacks-table td { padding: 7px 8px; }
}

@media (max-width: 480px) {
    .stats-bar__inner { flex-direction: column; }
    .stat-block { width: 100%; border-bottom: 1px solid var(--c-border-light); padding-bottom: 8px; }
}
