/* ═══════════════════════════════════════════════════════
   SimuPatrimoine — Charte Graphique Premium
   ═══════════════════════════════════════════════════════ */

:root {
    /* Couleurs principales */
    --cream: #FAF9F6;
    --cream-dark: #F0EDE8;
    --anthracite: #2C3E50;
    --anthracite-light: #4A5568;
    --sauge: #87A96B;
    --sauge-light: #A8C690;
    --sauge-dark: #6B8A54;
    --terracotta: #E2725B;
    --terracotta-light: #F09A88;
    --terracotta-dark: #C4563F;

    /* Couleurs véhicules */
    --c-pp: #87A96B;
    --c-sciir: #E2725B;
    --c-sciis: #5B8FB9;
    --c-sarl: #D4A574;
    --c-sas: #8B7EC8;

    /* Surfaces */
    --surface: #FFFFFF;
    --surface-raised: #FFFFFF;
    --border: #E8E4DF;
    --border-light: #F0EDE8;

    /* Texte */
    --text-primary: #2C3E50;
    --text-secondary: #6B7B8D;
    --text-muted: #9BA8B5;

    /* Typographie */
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, sans-serif;

    /* Espacements */
    --sidebar-width: 380px;
    --header-height: 64px;
    --radius: 10px;
    --radius-sm: 6px;

    /* Ombres */
    --shadow-sm: 0 1px 3px rgba(44,62,80,0.06);
    --shadow-md: 0 4px 16px rgba(44,62,80,0.08);
    --shadow-lg: 0 8px 32px rgba(44,62,80,0.12);
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--cream);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ═══════ HEADER ═══════ */
.site-header {
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.92);
}

.header-inner {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo-icon {
    font-size: 1.6rem;
    color: var(--sauge);
    line-height: 1;
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.55rem;
    font-weight: 600;
    color: var(--anthracite);
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 0.82rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* ═══════ LAYOUT ═══════ */
.app-layout {
    display: flex;
    min-height: calc(100vh - var(--header-height));
}

/* ═══════ SIDEBAR ═══════ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1.5rem;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    transition: transform 0.3s ease, min-width 0.3s ease, width 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    min-width: 0;
    width: 0;
    padding: 0;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid var(--sauge);
}

.sidebar-header h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--anthracite);
}

.btn-toggle-sidebar {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--cream);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-toggle-sidebar:hover {
    background: var(--sauge);
    color: white;
    border-color: var(--sauge);
}

/* ─── Input Sections ─── */
.input-section {
    margin-bottom: 1.4rem;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.08rem;
    font-weight: 600;
    color: var(--anthracite);
    margin-bottom: 0.7rem;
    padding: 0.35rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title::before {
    content: attr(data-icon);
    font-size: 1.1rem;
}

.field-group {
    margin-bottom: 0.6rem;
}

.field-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
    letter-spacing: 0.01em;
}

.field-row {
    display: flex;
    gap: 0.8rem;
}

.field-row .field-group {
    flex: 1;
}

input[type="number"],
select {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.88rem;
    color: var(--text-primary);
    background: var(--cream);
    transition: all 0.2s;
    outline: none;
}

input[type="number"]:focus,
select:focus {
    border-color: var(--sauge);
    box-shadow: 0 0 0 3px rgba(135,169,107,0.15);
}

/* Distinction visuelle : hypothèses */
.field-hyp {
    background: #FFF8F0 !important;
    border-color: var(--terracotta-light) !important;
    border-style: dashed !important;
}

.field-hyp:focus {
    border-color: var(--terracotta) !important;
    box-shadow: 0 0 0 3px rgba(226,114,91,0.15) !important;
}

/* ─── Calculate Button ─── */
.btn-calculate {
    width: 100%;
    padding: 0.85rem;
    background: linear-gradient(135deg, var(--sauge), var(--sauge-dark));
    color: white;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.25s;
    margin-top: 1rem;
    letter-spacing: 0.02em;
}

.btn-calculate:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    filter: brightness(1.05);
}

.btn-calculate:active {
    transform: translateY(0);
}

/* ═══════ CONTENT AREA ═══════ */
.content {
    flex: 1;
    padding: 2rem;
    min-width: 0;
    overflow-x: hidden;
}

/* ─── Placeholder ─── */
.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
}

.placeholder-inner {
    max-width: 520px;
}

.placeholder-icon {
    font-size: 3.5rem;
    color: var(--sauge);
    display: block;
    margin-bottom: 1rem;
    opacity: 0.6;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.placeholder h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--anthracite);
    margin-bottom: 0.6rem;
}

.placeholder p {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.7;
}

.vehicle-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.chip {
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.chip-pp { background: rgba(135,169,107,0.15); color: var(--c-pp); }
.chip-sciir { background: rgba(226,114,91,0.15); color: var(--c-sciir); }
.chip-sciis { background: rgba(91,143,185,0.15); color: var(--c-sciis); }
.chip-sarl { background: rgba(212,165,116,0.15); color: #A07845; }
.chip-sas { background: rgba(139,126,200,0.15); color: var(--c-sas); }

/* ═══════ RESULTS ═══════ */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h2 {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 600;
    color: var(--anthracite);
}

.btn-export {
    padding: 0.55rem 1.2rem;
    background: var(--terracotta);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-export:hover {
    background: var(--terracotta-dark);
    transform: translateY(-1px);
}

/* ─── Result Cards ─── */
.result-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--anthracite);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.inline-select {
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--cream);
    color: var(--text-primary);
    cursor: pointer;
}

/* ─── Table ─── */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#compTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#compTable th {
    background: var(--cream-dark);
    padding: 0.7rem 0.8rem;
    text-align: left;
    font-weight: 600;
    color: var(--anthracite);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

#compTable td {
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

#compTable tbody tr:hover {
    background: rgba(135,169,107,0.04);
}

#compTable .best-score {
    background: rgba(135,169,107,0.1);
}

.score-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.82rem;
}

.score-excellent { background: rgba(135,169,107,0.18); color: var(--sauge-dark); }
.score-good { background: rgba(91,143,185,0.15); color: #3D7BA8; }
.score-average { background: rgba(212,165,116,0.2); color: #A07845; }
.score-poor { background: rgba(226,114,91,0.15); color: var(--terracotta-dark); }

.reco-tag {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-weight: 500;
}

.reco-best { background: var(--sauge); color: white; }
.reco-ok { background: var(--cream-dark); color: var(--text-secondary); }

/* ─── Charts ─── */
.chart-container {
    position: relative;
    width: 100%;
}

.chart-radar {
    max-width: 550px;
    margin: 0 auto;
    aspect-ratio: 1;
}

.chart-line {
    height: 380px;
}

.chart-waterfall {
    height: 350px;
}

/* ═══════ WATERFALL LEGEND ═══════ */
.waterfall-legend {
    display: flex;
    gap: 1.2rem;
    justify-content: center;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}

.wf-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.wf-dot {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.wf-dot-deduct { background: #E2725B88; }
.wf-dot-nondeduct { background: #C9B8A8; }
.wf-dot-result { background: #87A96B; }

/* ═══════ DIAGNOSTIC / CONSEILS ═══════ */
.card-title-diagnostic {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.diag-icon {
    font-size: 1.3rem;
}

.diag-intro {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
    line-height: 1.6;
}

.diag-vehicle {
    margin-bottom: 1.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--cream);
}

.diag-vehicle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.diag-vehicle-header:hover {
    background: var(--cream-dark);
}

.diag-vehicle-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--anthracite);
}

.diag-deficit-badge {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 12px;
    background: rgba(226,114,91,0.13);
    color: var(--terracotta-dark);
}

.diag-chevron {
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: transform 0.25s;
}

.diag-vehicle.open .diag-chevron {
    transform: rotate(90deg);
}

.diag-vehicle-body {
    display: none;
    padding: 0 1rem 1rem 1rem;
}

.diag-vehicle.open .diag-vehicle-body {
    display: block;
}

.diag-leviers {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.8rem;
    margin-top: 0.5rem;
}

.diag-levier {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.diag-levier:hover {
    border-color: var(--sauge-light);
    box-shadow: var(--shadow-sm);
}

.diag-levier-icon {
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
}

.diag-levier-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--anthracite);
    margin-bottom: 0.35rem;
}

.diag-levier-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.55;
}

.diag-levier-target {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.4rem;
    padding: 0.2rem 0.55rem;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
}

.diag-target-neutral {
    background: rgba(91,143,185,0.12);
    color: #3D7BA8;
}

.diag-target-positive {
    background: rgba(135,169,107,0.15);
    color: var(--sauge-dark);
}

.diag-impact-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 0 var(--radius-sm);
    transition: width 0.4s ease;
}

.diag-impact-high { background: var(--sauge); }
.diag-impact-medium { background: var(--c-sarl); }
.diag-impact-low { background: var(--c-sciis); }

.diag-summary {
    margin-top: 0.8rem;
    padding: 0.7rem 0.9rem;
    background: rgba(135,169,107,0.07);
    border-left: 3px solid var(--sauge);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.82rem;
    color: var(--anthracite-light);
    line-height: 1.6;
}

.diag-all-positive {
    text-align: center;
    padding: 2rem 1rem;
}

.diag-all-positive-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.7rem;
}

.diag-all-positive h4 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--sauge-dark);
    margin-bottom: 0.3rem;
}

.diag-all-positive p {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* ─── Legal Notice ─── */
.legal-notice {
    margin-top: 1.5rem;
    padding: 1rem 1.2rem;
    background: #FFF8F0;
    border: 1px dashed var(--terracotta-light);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--terracotta-dark);
    line-height: 1.6;
}

/* ═══════ REOPEN SIDEBAR BUTTON (desktop) ═══════ */
.btn-reopen-sidebar {
    display: none; /* hidden by default, shown when sidebar is collapsed */
    position: fixed;
    top: calc(var(--header-height) + 1rem);
    left: 0;
    z-index: 120;
    width: 32px;
    height: 48px;
    background: var(--sauge);
    color: white;
    border: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
    align-items: center;
    justify-content: center;
}

.btn-reopen-sidebar:hover {
    width: 40px;
    background: var(--sauge-dark);
}

.btn-reopen-sidebar.visible {
    display: flex;
}

/* ═══════ MOBILE TOGGLE ═══════ */
.btn-mobile-sidebar {
    display: none;
    position: fixed;
    bottom: 1.2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.65rem 1.5rem;
    background: var(--anthracite);
    color: white;
    border: none;
    border-radius: 30px;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    z-index: 200;
    box-shadow: var(--shadow-lg);
}

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        z-index: 150;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        width: min(380px, 90vw);
        min-width: 0;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .btn-mobile-sidebar {
        display: block;
    }

    .btn-toggle-sidebar {
        display: none;
    }

    .btn-reopen-sidebar {
        display: none !important;
    }

    .content {
        padding: 1.2rem;
    }

    .tagline {
        display: none;
    }

    .chart-radar {
        max-width: 100%;
    }
}

@media (max-width: 600px) {
    html { font-size: 14px; }

    .header-inner { padding: 0 1rem; }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-line, .chart-waterfall {
        height: 280px;
    }

    #compTable {
        font-size: 0.78rem;
    }
}

/* ═══════ PRINT / PDF ═══════ */
@media print {
    .sidebar, .btn-mobile-sidebar, .btn-export, .btn-toggle-sidebar,
    .site-header, .placeholder { display: none !important; }

    .content { padding: 0; }
    .result-card { break-inside: avoid; }
}

/* ═══════ SCROLLBAR ═══════ */
.sidebar::-webkit-scrollbar {
    width: 5px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ═══════ LOADING ANIMATION ═══════ */
.btn-calculate.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-calculate.loading .btn-icon {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0); }
    to { transform: rotate(360deg); }
}

/* Color dot for vehicle names in table */
.vehicle-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.4rem;
    vertical-align: middle;
}
