@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ═══════════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════════ */
:root {
    --bg:           #080d14;
    --bg2:          #0d1520;
    --bg3:          #111e2e;
    --surface:      #131f30;
    --surface2:     #1a2840;
    --border:       #1f3050;
    --border-light: #2a4060;

    --cyan:         #00d4ff;
    --cyan-dim:     rgba(0, 212, 255, 0.12);
    --cyan-glow:    rgba(0, 212, 255, 0.25);
    --green:        #00e5a0;
    --green-dim:    rgba(0, 229, 160, 0.12);
    --amber:        #ffb400;
    --amber-dim:    rgba(255, 180, 0, 0.12);
    --red:          #ff4d6a;
    --red-dim:      rgba(255, 77, 106, 0.12);

    --text:         #e8f4ff;
    --text-2:       #8aa8cc;
    --text-3:       #4a6a8a;

    --mono:         'DM Mono', monospace;
    --sans:         'DM Sans', sans-serif;

    --r-sm:  6px;
    --r-md:  10px;
    --r-lg:  14px;
    --r-xl:  18px;

    --shadow: 0 4px 24px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 4rem;
    /* Subtle grid texture */
    background-image:
        linear-gradient(rgba(0,212,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,212,255,0.015) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* ═══════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════ */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ═══════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════ */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: 1.25rem 1.75rem;
    margin-bottom: 2.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    position: relative;
    overflow: hidden;
}

/* top accent line */
header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--cyan), var(--green), transparent);
}

header h1 {
    font-family: var(--sans);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

header h1 span.accent {
    color: var(--cyan);
}

/* ═══════════════════════════════════════════════
   NAVIGATION
═══════════════════════════════════════════════ */
.nav-menu {
    display: flex;
    gap: 0.375rem;
    background: var(--bg2);
    padding: 0.375rem;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
}

.nav-link {
    padding: 0.5rem 1.1rem;
    border-radius: var(--r-md);
    text-decoration: none;
    color: var(--text-2);
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface2);
}

.nav-link.active {
    background: var(--cyan-dim);
    color: var(--cyan);
    border: 1px solid rgba(0,212,255,0.3);
    box-shadow: 0 0 16px rgba(0,212,255,0.1);
}

/* ═══════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    transition: border-color 0.2s ease;
}

.card:hover { border-color: var(--border-light); }

.card h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
}

/* ═══════════════════════════════════════════════
   KPI GRID
═══════════════════════════════════════════════ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem 1.25rem;
    position: relative;
    overflow: hidden;
    transition: all 0.25s ease;
}

.kpi-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--cyan), var(--green));
    transform: scaleX(0);
    transition: transform 0.3s ease;
    transform-origin: left;
}

.kpi-card:hover { border-color: var(--border-light); transform: translateY(-2px); }
.kpi-card:hover::after { transform: scaleX(1); }

.kpi-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 0.625rem;
}

.kpi-value {
    font-family: var(--mono);
    font-size: 1.75rem;
    font-weight: 500;
    color: var(--cyan);
    line-height: 1.1;
}

/* ═══════════════════════════════════════════════
   CHARTS GRID
═══════════════════════════════════════════════ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

/* ═══════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border-radius: var(--r-md);
    border: none;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
    background: var(--cyan-dim);
    color: var(--cyan);
    border: 1px solid rgba(0,212,255,0.35);
}
.btn-primary:hover:not(:disabled) {
    background: rgba(0,212,255,0.2);
    box-shadow: 0 0 20px rgba(0,212,255,0.2);
}

.btn-success {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid rgba(0,229,160,0.35);
}
.btn-success:hover:not(:disabled) {
    background: rgba(0,229,160,0.2);
    box-shadow: 0 0 20px rgba(0,229,160,0.2);
}

.btn-delete {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(255,77,106,0.3);
    border-radius: var(--r-sm);
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.btn-delete:hover {
    background: rgba(255,77,106,0.25);
    box-shadow: 0 0 12px rgba(255,77,106,0.3);
    transform: scale(1.1);
}

/* ═══════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #ccddf5;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Badge "⚡ auto" affiché dans le label */
.label-auto {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--cyan);
    background: var(--cyan-dim);
    border: 1px solid rgba(0,212,255,0.25);
    border-radius: 20px;
    padding: 0.1rem 0.45rem;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
}

input, select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
}

select {
    font-family: var(--sans);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234a6a8a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2.2rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0,212,255,0.1);
    background: var(--bg3);
}

input::placeholder { color: var(--text-3); font-family: var(--sans); }

/* ═══════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

thead {
    background: var(--bg2);
    position: sticky;
    top: 0;
    z-index: 1;
}

th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 0.8rem 1rem;
    font-size: 0.88rem;
    border-bottom: 1px solid rgba(31,48,80,0.6);
    vertical-align: middle;
}

tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: rgba(0,212,255,0.04); }
tbody tr:last-child td { border-bottom: none; }

td.mono { font-family: var(--mono); font-size: 0.85rem; }

.badge-reseau {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--cyan-dim);
    color: var(--cyan);
    border: 1px solid rgba(0,212,255,0.2);
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════
   STATUS MESSAGE
═══════════════════════════════════════════════ */
.status-ok {
    background: var(--green-dim);
    border: 1px solid rgba(0,229,160,0.3);
    color: var(--green);
    padding: 1rem 1.25rem;
    border-radius: var(--r-md);
}

.status-err {
    background: var(--red-dim);
    border: 1px solid rgba(255,77,106,0.3);
    color: var(--red);
    padding: 1rem 1.25rem;
    border-radius: var(--r-md);
}

/* ═══════════════════════════════════════════════
   COMPARE — vehicle cards & ranking
═══════════════════════════════════════════════ */
.vehicle-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    transition: border-color 0.2s ease;
}

.vehicle-card:hover { border-color: var(--border-light); }

.vehicle-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1.1rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(31,48,80,0.7);
    font-size: 0.88rem;
}

.info-row:last-child { border-bottom: none; }

.info-row label {
    color: var(--text-2);
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.85rem;
    margin: 0;
}

.info-row.highlight {
    margin-top: 0.5rem;
    padding: 0.75rem 0.875rem;
    background: var(--green-dim);
    border: 1px solid rgba(0,229,160,0.2);
    border-radius: var(--r-md);
    font-family: var(--mono);
    font-size: 1.1rem;
    color: var(--green);
    font-weight: 500;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    margin-bottom: 0.6rem;
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 0.92rem;
    transition: transform 0.15s ease;
    border: 1px solid transparent;
}

.ranking-item:hover { transform: translateX(3px); }

.ranking-item.green {
    background: var(--green-dim);
    border-color: rgba(0,229,160,0.25);
    color: var(--green);
}
.ranking-item.yellow {
    background: var(--amber-dim);
    border-color: rgba(255,180,0,0.25);
    color: var(--amber);
}
.ranking-item.red {
    background: var(--red-dim);
    border-color: rgba(255,77,106,0.25);
    color: var(--red);
}

/* ═══════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════ */
footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-3);
    font-size: 0.8rem;
    font-family: var(--mono);
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .container { padding: 1rem; }

    header {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    header h1 { font-size: 1.2rem; }

    .nav-menu {
        width: 100%;
        justify-content: stretch;
    }

    .nav-link {
        flex: 1;
        justify-content: center;
        padding: 0.5rem 0.5rem;
        font-size: 0.78rem;
    }

    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }

    .kpi-value { font-size: 1.35rem; }

    .charts-grid { grid-template-columns: 1fr; }

    .card { padding: 1.25rem; }

    th, td { padding: 0.6rem 0.7rem; }

    table { font-size: 0.82rem; }

    .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }

    .nav-link span.nav-text { display: none; }
}

/* ═══════════════════════════════════════════════
   GÉOLOCALISATION
═══════════════════════════════════════════════ */
.input-with-btn { display:flex; gap:0.5rem; align-items:stretch; }
.input-with-btn input { flex:1; }
.btn-geo {
    flex-shrink:0; width:2.6rem; height:2.6rem;
    border-radius:var(--r-md); border:1px solid var(--border);
    background:var(--bg2); color:var(--text);
    font-size:1.1rem; cursor:pointer;
    display:flex; align-items:center; justify-content:center;
    transition:all 0.2s; padding:0; line-height:1;
}
.btn-geo:hover:not(:disabled) { border-color:var(--cyan); background:var(--cyan-dim); box-shadow:0 0 12px rgba(0,212,255,0.2); }
.btn-geo:disabled { opacity:0.45; cursor:not-allowed; }
.geo-status { font-size:0.74rem; font-family:var(--mono); margin-top:0.3rem; display:block; min-height:1rem; }
.geo-ok   { color:var(--green); }
.geo-err  { color:var(--red); }
.geo-info { color:var(--cyan); }
.geo-warn { color:var(--amber); }

/* ═══════════════════════════════════════════════
   GESTION DONNÉES
═══════════════════════════════════════════════ */
.card-data-mgmt { border-color:var(--border-light); }
.data-actions { display:flex; flex-wrap:wrap; gap:0.75rem; }
.data-actions .btn { flex:1; min-width:140px; font-size:0.85rem; padding:0.6rem 1rem; }
.btn-danger { background:var(--red-dim); color:var(--red); border:1px solid rgba(255,77,106,0.35); }
.btn-danger:hover:not(:disabled) { background:rgba(255,77,106,0.22); box-shadow:0 0 20px rgba(255,77,106,0.2); }
.count-badge {
    font-size:0.72rem; font-weight:500; color:var(--text-3);
    background:var(--bg2); border:1px solid var(--border);
    border-radius:20px; padding:0.15rem 0.6rem; margin-left:0.5rem;
    font-family:var(--mono); text-transform:none; letter-spacing:0; vertical-align:middle;
}

/* ═══════════════════════════════════════════════
   MODALE
═══════════════════════════════════════════════ */
.modal-overlay {
    position:fixed; inset:0; background:rgba(0,0,0,0.75);
    backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
    z-index:1000; display:flex; align-items:center; justify-content:center; padding:1.5rem;
}
.modal-box {
    background:var(--surface); border:1px solid var(--border-light);
    border-radius:var(--r-xl); padding:2rem; max-width:420px; width:100%;
    box-shadow:var(--shadow-lg);
}
.modal-box h3 { font-size:1.1rem; font-weight:700; color:var(--red); margin-bottom:1rem; }
.modal-box p  { color:var(--text-2); font-size:0.9rem; line-height:1.6; }
.modal-box input { margin-top:0.75rem; font-family:var(--mono); font-weight:600; letter-spacing:1px; text-align:center; font-size:1rem; }
.modal-actions { display:flex; gap:0.75rem; margin-top:1.5rem; }
.modal-actions .btn { flex:1; }

/* ═══════════════════════════════════════════════
   LABEL AUTO BADGE
═══════════════════════════════════════════════ */
label { display:flex; align-items:center; gap:0.4rem; flex-wrap:wrap; }
.label-auto {
    font-size:0.65rem; font-weight:600; color:var(--cyan);
    background:var(--cyan-dim); border:1px solid rgba(0,212,255,0.25);
    border-radius:20px; padding:0.1rem 0.45rem;
    text-transform:none; letter-spacing:0; white-space:nowrap;
}
