/* ===========================================
   EVERYPART DEMO - Station de Connexion
   Charte graphique Every.Parts officielle
   =========================================== */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
    --ep-green: #1ab16d;
    --ep-green-light: #2dd47f;
    --ep-green-dark: #15925a;
    --ep-gray: #515159;
    --ep-gray-light: #bdc8d3;
    --ep-gray-lighter: #f3f4f6;
    --ep-gray-dark: #1f2937;
    --ep-red: #ff5050;
    --ep-orange: #f59e0b;
    --ep-blue: #1980d8;
    --ep-bg: #f8faf9;
    --ep-bg-dark: #020101;
    --ep-white: #ffffff;
    --cable-inactive: #d1d5db;
    --cable-active: var(--ep-green);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        "Inter",
        system-ui,
        -apple-system,
        sans-serif;
    background: var(--ep-bg);
    color: var(--ep-gray-dark);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header */
.header {
    background: var(--ep-white);
    border-bottom: 3px solid var(--ep-green);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 2000;
}

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

.logo-img {
    height: 40px;
    width: auto;
}

.moto-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.moto-selector label {
    font-weight: 500;
    color: var(--ep-gray);
}

.moto-selector select {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--ep-gray-light);
    border-radius: 8px;
    background: var(--ep-white);
    cursor: pointer;
    min-width: 250px;
}

.moto-selector select:focus {
    outline: none;
    border-color: var(--ep-green);
}

/* Main Layout */
.main-container {
    display: grid;
    grid-template-columns: 260px 1fr 280px;
    gap: 0;
    padding: 1.5rem 2rem;
    max-width: 1500px;
    margin: 0 auto;
    min-height: 420px;
    position: relative;
}

/* Button Group */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

/* Cables SVG Layer */
.cables-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.cable-path {
    fill: none;
    stroke: var(--cable-inactive);
    stroke-width: 4;
    stroke-linecap: round;
    transition:
        stroke 0.4s ease,
        stroke-width 0.3s ease,
        filter 0.4s ease;
}

.cable-path.active {
    stroke: var(--ep-green);
    stroke-width: 5;
    filter: drop-shadow(0 0 6px rgba(26, 177, 109, 0.6));
}

.cable-path.flowing {
    stroke-dasharray: 12 6;
    animation: cableFlow 1s linear infinite;
}

@keyframes cableFlow {
    0% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: -18;
    }
}

/* Cable connector dots */
.cable-connector {
    fill: var(--cable-inactive);
    transition:
        fill 0.3s ease,
        filter 0.3s ease;
}

.cable-connector.active {
    fill: var(--ep-green);
    filter: drop-shadow(0 0 4px rgba(26, 177, 109, 0.8));
}

/* Sources Panel */
.sources-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
    z-index: 10;
    padding-right: 1rem;
}

.source-category-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ep-gray);
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    padding-left: 0.5rem;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    background: var(--ep-white);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    position: relative;
}

.source-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.source-item.connected {
    border-color: var(--ep-green);
    background: linear-gradient(
        135deg,
        rgba(26, 177, 109, 0.08) 0%,
        rgba(26, 177, 109, 0.02) 100%
    );
    transform: translateX(4px);
}

.source-icon {
    font-size: 0.8rem;
    font-weight: 700;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--ep-white);
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.source-item.connected .source-icon {
    box-shadow: 0 2px 8px rgba(26, 177, 109, 0.4);
}

.source-info {
    flex: 1;
    min-width: 0;
}

.source-name {
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ep-gray-dark);
}

.source-specialty {
    font-size: 0.65rem;
    color: var(--ep-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-plug {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--cable-inactive);
    border: 2px solid var(--ep-white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.source-item.connected .source-plug {
    background: var(--ep-green);
    box-shadow:
        0 0 8px rgba(26, 177, 109, 0.6),
        0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Vehicle Panel (Center) */
.vehicle-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    position: relative;
    z-index: 10;
    padding: 0 2rem;
}

.vehicle-hub {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hub-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid var(--ep-gray-light);
    border-radius: 50%;
    transition: all 0.5s ease;
}

.hub-ring.active {
    border-color: var(--ep-green);
    box-shadow:
        0 0 30px rgba(26, 177, 109, 0.3),
        inset 0 0 20px rgba(26, 177, 109, 0.1);
}

.hub-content {
    background: var(--ep-white);
    border-radius: 50%;
    width: 160px;
    height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    text-align: center;
    padding: 1rem;
    position: relative;
    z-index: 2;
}

.vehicle-icon {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
}

.vehicle-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ep-gray-dark);
    line-height: 1.2;
}

.vehicle-year {
    font-size: 0.8rem;
    color: var(--ep-gray);
    font-weight: 500;
}

/* Gauge */
.gauge-container {
    background: var(--ep-white);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 280px;
}

.gauge-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.gauge-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ep-gray-dark);
}

.gauge-percent {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ep-green);
}

.gauge-bar {
    height: 20px;
    background: var(--ep-gray-lighter);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.gauge-fill {
    height: 100%;
    background: linear-gradient(
        90deg,
        var(--ep-green-dark),
        var(--ep-green),
        var(--ep-green-light)
    );
    border-radius: 10px;
    transition: width 0.5s ease;
    position: relative;
}

.gauge-fill::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.4) 0%,
        transparent 60%
    );
    border-radius: 10px;
}

/* Everypart Button - Styled */
.everypart-button {
    position: relative;
    background: linear-gradient(135deg, var(--ep-white) 0%, #f0fdf7 100%);
    border: 3px solid var(--ep-green);
    border-radius: 16px;
    padding: 0.875rem 1.75rem 0.875rem 1rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ep-green);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow:
        0 4px 15px rgba(26, 177, 109, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

.everypart-button::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(26, 177, 109, 0.15),
        transparent
    );
    transition: left 0.6s ease;
}

.everypart-button:hover:not(:disabled)::before {
    left: 100%;
}

.everypart-button:hover:not(:disabled) {
    background: linear-gradient(
        135deg,
        var(--ep-green) 0%,
        var(--ep-green-light) 100%
    );
    color: var(--ep-white);
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 8px 25px rgba(26, 177, 109, 0.35),
        0 0 0 4px rgba(26, 177, 109, 0.1);
    border-color: var(--ep-green-dark);
}

.everypart-button:hover:not(:disabled) .ep-logo-icon {
    filter: brightness(0) invert(1);
    transform: rotate(360deg) scale(1.1);
}

.everypart-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.everypart-button.active {
    background: linear-gradient(
        135deg,
        var(--ep-green) 0%,
        var(--ep-green-dark) 100%
    );
    color: var(--ep-white);
    border-color: var(--ep-green-dark);
    box-shadow:
        0 0 30px rgba(26, 177, 109, 0.5),
        0 0 60px rgba(26, 177, 109, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.everypart-button.active .ep-logo-icon {
    filter: brightness(0) invert(1);
    animation: logoSpin 3s linear infinite;
}

.everypart-button.active .ep-pulse-ring {
    display: block;
}

/* Logo icon in button */
.ep-logo-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex-shrink: 0;
}

@keyframes logoSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Button text */
.ep-btn-text {
    position: relative;
    z-index: 2;
}

/* Pulse ring effect when active */
.ep-pulse-ring {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 16px;
    animation: pulseRing 2s ease-out infinite;
    pointer-events: none;
}

.ep-pulse-ring::before,
.ep-pulse-ring::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid var(--ep-green);
    border-radius: 16px;
    animation: pulseRing 2s ease-out infinite;
}

.ep-pulse-ring::after {
    animation-delay: 1s;
}

@keyframes pulseRing {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* Reset Button */
.reset-button {
    background: var(--ep-white);
    border: 2px solid var(--ep-gray-light);
    border-radius: 10px;
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ep-gray);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reset-button:hover {
    border-color: var(--ep-red);
    color: var(--ep-red);
    background: rgba(255, 80, 80, 0.05);
}

.reset-button .icon {
    font-size: 1rem;
}

/* Data Panel */
.data-panel {
    background: var(--ep-white);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    overflow-y: auto;
    max-height: calc(100vh - 140px);
    position: relative;
    z-index: 10;
    margin-left: 1rem;
}

.data-panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ep-gray-dark);
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid var(--ep-green);
}

.data-placeholder {
    color: var(--ep-gray);
    font-size: 0.85rem;
    text-align: center;
    padding: 2rem 1rem;
}

.data-category {
    margin-bottom: 1.25rem;
}

.data-category:last-child {
    margin-bottom: 0;
}

.data-category-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ep-gray);
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.data-field {
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--ep-gray-lighter);
}

.data-field:last-child {
    border-bottom: none;
}

.field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}

.field-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ep-gray-dark);
}

.field-value {
    font-size: 0.8rem;
    font-weight: 600;
}

.field-value.has-value {
    color: var(--ep-gray-dark);
}

.field-value.no-value {
    color: var(--ep-red);
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
}

.field-value.conflict {
    color: var(--ep-orange);
}

.field-value.recommended {
    color: var(--ep-green);
}

.broken-icon {
    font-size: 0.7rem;
}

.field-bar {
    height: 5px;
    background: var(--ep-gray-lighter);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.2rem;
}

.field-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.field-bar-fill.low {
    background: var(--ep-red);
}

.field-bar-fill.medium {
    background: var(--ep-orange);
}

.field-bar-fill.high {
    background: var(--ep-green);
}

.field-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-top: 0.25rem;
}

.field-source-tag {
    font-size: 0.6rem;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: var(--ep-gray-lighter);
    color: var(--ep-gray);
}

.field-source-tag.recommended {
    background: var(--ep-green);
    color: var(--ep-white);
}

.field-source-tag.conflict {
    border: 1px solid var(--ep-orange);
    background: rgba(245, 158, 11, 0.1);
    color: var(--ep-orange);
}

/* ==========================================
   COMPARISON SECTION (Full Width Bottom)
   ========================================== */

.comparison-section {
    background: var(--ep-white);
    border-top: 3px solid var(--ep-green);
    padding: 1.5rem 2rem;
    margin-top: 0;
    transition: all 0.4s ease;
    position: relative;
}

/* Expanded mode - takes over the screen */
.comparison-section.expanded {
    position: fixed;
    top: 70px; /* Below header */
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    padding-top: 3rem;
    overflow: hidden;
    border-top: 3px solid var(--ep-green);
}

.comparison-section.expanded .comparison-content {
    max-height: calc(100vh - 200px);
}

.comparison-section.expanded .expand-toggle {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2001;
}

/* Expand Toggle Button */
.expand-toggle {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ep-green);
    border: none;
    border-radius: 20px;
    padding: 0.35rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    color: var(--ep-white);
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(26, 177, 109, 0.3);
    transition: all 0.3s ease;
    z-index: 10;
}

.expand-toggle:hover {
    background: var(--ep-green-dark);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 177, 109, 0.4);
}

.expand-icon {
    font-size: 0.65rem;
    transition: transform 0.3s ease;
}

.comparison-section.expanded .expand-icon {
    transform: rotate(180deg);
}

.comparison-section.expanded .expand-label::after {
    content: "Reduire";
}

.comparison-section.expanded .expand-label {
    font-size: 0;
}

.comparison-section.expanded .expand-label::after {
    font-size: 0.75rem;
}

.comparison-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    max-width: 1500px;
    margin-left: auto;
    margin-right: auto;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--ep-gray-lighter);
}

.comparison-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ep-gray-dark);
    margin: 0;
}

.comparison-hint {
    font-size: 0.8rem;
    color: var(--ep-gray);
}

.comparison-content {
    max-width: 1500px;
    margin: 0 auto;
    max-height: 350px;
    overflow-y: auto;
    overflow-x: auto;
    scroll-behavior: smooth;
}

.comparison-content .data-placeholder {
    padding: 3rem 1rem;
}

/* ==========================================
   SIMPLE VIEW (Right Panel)
   ========================================== */

/* Simple fields grid */
.simple-fields-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.simple-field {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    background: var(--ep-gray-lighter);
    border-radius: 6px;
    border-left: 3px solid var(--ep-gray-light);
}

.simple-field.has-value {
    border-left-color: var(--ep-green);
}

.simple-field.no-value {
    border-left-color: var(--ep-red);
    background: rgba(255, 80, 80, 0.05);
}

.simple-field.conflict {
    border-left-color: var(--ep-orange);
    background: rgba(245, 158, 11, 0.05);
}

.simple-field-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ep-gray);
    margin-bottom: 0.15rem;
}

.simple-field-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ep-gray-dark);
}

.simple-field.no-value .simple-field-value {
    color: var(--ep-red);
    font-size: 0.75rem;
}

.simple-field.conflict .simple-field-value {
    color: var(--ep-orange);
}

.simple-field.has-value.recommended .simple-field-value {
    color: var(--ep-green);
}

/* Comparison Table (Full Width) */
.comparison-table-wrapper {
    overflow-x: auto;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.comparison-table th,
.comparison-table td {
    padding: 0.75rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--ep-gray-lighter);
}

.comparison-table th {
    background: var(--ep-gray-lighter);
    font-weight: 600;
    color: var(--ep-gray-dark);
    position: sticky;
    top: 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    z-index: 10;
}

.comparison-table th:first-child {
    text-align: left;
    padding-left: 1rem;
    min-width: 140px;
}

.comparison-table td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--ep-gray-dark);
    padding-left: 1rem;
    white-space: nowrap;
    background: var(--ep-white);
    position: sticky;
    left: 0;
    z-index: 5;
}

.comparison-table th.source-header {
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comparison-table th.ep-header {
    background: var(--ep-green);
    color: var(--ep-white);
}

/* Table cells */
.cell-value {
    font-weight: 500;
}

.cell-empty {
    color: var(--ep-red);
    font-weight: 400;
}

.cell-conflict {
    color: var(--ep-orange);
    font-weight: 600;
}

.cell-recommended {
    color: var(--ep-green);
    font-weight: 700;
    background: rgba(26, 177, 109, 0.1);
}

.cell-match {
    color: var(--ep-gray-dark);
}

.cell-mismatch {
    color: var(--ep-orange);
    background: rgba(245, 158, 11, 0.08);
}

/* EP Column */
.comparison-table td.ep-column {
    background: rgba(26, 177, 109, 0.08);
    font-weight: 600;
    color: var(--ep-green-dark);
    border-left: 2px solid var(--ep-green);
}

/* Row hover */
.comparison-table tbody tr:hover {
    background: rgba(26, 177, 109, 0.03);
}

/* Stats row */
.comparison-table tr.stats-row td {
    background: var(--ep-gray-lighter);
    font-weight: 600;
    font-size: 0.65rem;
    border-top: 2px solid var(--ep-gray-light);
}

.stats-good {
    color: var(--ep-green);
}

.stats-bad {
    color: var(--ep-red);
}

.stats-medium {
    color: var(--ep-orange);
}

/* Responsive */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .cables-layer {
        display: none;
    }

    .sources-panel {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 0.75rem;
        padding-right: 0;
    }

    .source-category-label {
        grid-column: 1 / -1;
    }

    .vehicle-panel {
        order: -1;
        padding: 0;
    }

    .data-panel {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .moto-selector select {
        min-width: 200px;
    }

    .main-container {
        padding: 1rem;
    }
}
