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

:root {
    --bg: #e8e8e8;
    --panel-bg: transparent;
    --card: #ffffff;
    --border: rgba(0, 0, 0, 0.06);
    --text: #1a1a1a;
    --text-muted: #888888;
    --accent: #1a1a1a;
    --accent-hover: #333333;
    --accent-light: rgba(0, 0, 0, 0.05);
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.configurator {
    display: grid;
    grid-template-columns: 1fr 340px;
    height: 100vh;
    height: 100dvh;
}

/* Viewport */
.configurator__viewport {
    position: relative;
    overflow: hidden;
    background: var(--bg);
    touch-action: none;
}

#canvas3d {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
    outline: none;
}

#canvas3d:active {
    cursor: grabbing;
}

.configurator__loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    transition: opacity 0.4s ease;
    z-index: 10;
}

.configurator__loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.configurator__spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(0,0,0,0.08);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Door toggle (viewport overlay) */
.configurator__door-toggle {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--card);
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    z-index: 5;
    transition: background 0.2s ease;
    user-select: none;
}

.configurator__door-toggle:hover {
    background: #e8e8e8;
}

.configurator__door-toggle input {
    display: none;
}

.configurator__door-toggle svg {
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.configurator__door-toggle:has(input:checked) svg {
    opacity: 1;
}

/* Tabs */
.configurator__tabs {
    display: flex;
    gap: 0;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 5;
    flex-shrink: 0;
}

.configurator__tab {
    flex: 1;
    padding: 10px 0;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.configurator__tab:hover {
    color: var(--text);
}

.configurator__tab--active {
    color: var(--text);
    font-weight: 700;
    border-bottom-color: var(--accent);
}

.configurator__tab-content {
    display: none;
}

.configurator__tab-content--active {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Panel */
.configurator__panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: var(--panel-bg);
    overflow-y: auto;
    scrollbar-width: none;
}

.configurator__panel::-webkit-scrollbar {
    display: none;
}

/* Sections = cards arrondies independantes */
.configurator__section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.configurator__section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 14px;
}

/* Color rows */
.configurator__color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.configurator__color-row:last-child {
    margin-bottom: 0;
}

.configurator__color-label {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
}

/* Swatches */
.configurator__swatches {
    display: flex;
    gap: 8px;
}

.configurator__swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
    padding: 0;
    outline: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.configurator__swatch:hover {
    transform: scale(1.12);
}

.configurator__swatch--active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent);
}

/* Toggle switch rows */
.configurator__toggle-row {
    display: flex;
    align-items: center;
    padding: 8px 0;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.configurator__toggle-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.configurator__toggle-row:first-of-type {
    padding-top: 0;
}

.configurator__toggle-label {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
    flex: 1;
}

.configurator__toggle-price {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: 12px;
    white-space: nowrap;
}

.configurator__toggle-row input[type="checkbox"],
.configurator__toggle-row input[type="radio"] {
    display: none;
}

.configurator__toggle-switch {
    position: relative;
    width: 38px;
    height: 22px;
    background: #d4d4d4;
    border-radius: 11px;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.configurator__toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform 0.2s ease;
}

input:checked + .configurator__toggle-switch {
    background: var(--accent);
}

input:checked + .configurator__toggle-switch::after {
    transform: translateX(16px);
}

/* Radio cards (siege) */
.configurator__radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.configurator__radio-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 10px;
    background: var(--panel-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    text-align: center;
}

.configurator__radio-card:hover {
    background: #e8e8e8;
}

.configurator__radio-card input {
    display: none;
}

.configurator__radio-card:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-light);
}

.configurator__radio-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.configurator__radio-price {
    font-size: 11px;
    color: var(--text-muted);
}

/* Slider */
.configurator__slider-group {
    margin-bottom: 0;
}

.configurator__slider-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text);
}

.configurator__slider-value {
    font-weight: 700;
    color: var(--text);
}

.configurator__slider {
    width: 100%;
    height: 5px;
    appearance: none;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.configurator__slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    transition: transform 0.15s ease;
}

.configurator__slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.configurator__slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* Price section */
.configurator__section--price {
    margin-top: auto;
    text-align: center;
    background: var(--card);
    position: sticky;
    bottom: 0;
}

.configurator__price {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    letter-spacing: -0.02em;
}

.configurator__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 24px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.configurator__cta:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.configurator__cta:active {
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    html, body {
        height: auto;
        overflow: auto;
        font-size: 13px;
    }

    .configurator {
        display: flex;
        flex-direction: column;
        height: auto;
    }

    .configurator__viewport {
        width: 100%;
        height: 100vw;
        max-height: 70vh;
        flex-shrink: 0;
    }

    .configurator__panel {
        overflow: visible;
        padding: 10px;
        gap: 8px;
    }

    .configurator__section {
        padding: 12px 14px;
    }

    .configurator__section--price {
        position: sticky;
        bottom: 0;
        z-index: 5;
    }

    .configurator__swatch {
        width: 24px;
        height: 24px;
    }

    .configurator__door-toggle {
        display: none;
    }

    .configurator__tabs {
        position: static;
    }
}

@media (max-width: 480px) {
    .configurator__viewport {
        height: 80vw;
        max-height: 60vh;
    }

    .configurator__panel {
        padding: 8px;
        gap: 6px;
    }

    .configurator__section {
        padding: 10px 12px;
    }

    .configurator__price {
        font-size: 18px;
        margin-bottom: 8px;
    }

    .configurator__cta {
        padding: 8px 16px;
        font-size: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .configurator__spinner {
        animation: none;
    }

    .configurator__swatch,
    .configurator__toggle-switch,
    .configurator__toggle-switch::after,
    .configurator__cta {
        transition: none;
    }
}
