:root {
    --primary: #123121; /* Forest 900 */
    --primary-hover: #18422d; /* Forest 800 */
    --bg-light: #E6E0D4; /* Sand 50 */
    --panel-bg: rgba(223, 217, 203, 0.95); /* Sand 100 with opacity */
    --text: #1C1917; /* Charcoal */
    --text-muted: #555555;
    --danger: #e63946;
    --border: rgba(28, 25, 23, 0.15); /* Charcoal with opacity */
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Montserrat', 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text);
    overflow: hidden;
}

/* --- NEW PREMIUM NAVBAR --- */
.site-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 96px; /* h-24 */
    background-color: var(--primary);
    color: var(--bg-light);
    z-index: 50;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-container {
    max-width: 1152px; /* max-w-6xl */
    margin: 0 auto;
    padding: 0 24px; /* px-6 */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px; /* gap-4 */
    text-decoration: none;
    color: inherit;
    transition: color 0.3s;
}

.brand:hover .site-name {
    color: #fff;
}

.logo-circle {
    height: 48px;
    width: 48px;
    border-radius: 50%;
    background: url('logo.png') center/cover no-repeat;
    background-color: rgba(255,255,255,0.1); /* fallback */
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.site-name {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    transition: color 0.2s;
}

.desktop-nav {
    display: flex;
    gap: 32px; /* gap-8 */
}

.desktop-nav a {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    color: inherit;
    opacity: 0.8;
    transition: opacity 0.2s, color 0.2s;
}

.desktop-nav a:hover {
    opacity: 1;
    color: #fff;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    opacity: 0.9;
    cursor: pointer;
}
.header-actions:hover {
    opacity: 1;
    color: #fff;
}

/* --- PREMIUM UI PANEL --- */
.premium-panel {
    position: relative;
    width: 420px;
    flex-shrink: 0;
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 20px;
    z-index: 10;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px); /* Fit within screen */
    overflow: hidden; /* Hide main overflow, scroll inner */
}

.panel-header {
    padding: 16px 20px 10px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.panel-header h2 {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.panel-content {
    flex: 1;
    min-height: 0;
    padding: 12px 20px 16px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* --- CUSTOM SCROLLBARS --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}
#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

.spacings-container {
    margin-top: 5px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    border: 1px solid var(--border);
}
.spacings-container h4 {
    margin: 0 0 10px 0;
    font-size: 12px;
}

/* MODAL DEVIS (Stylisé comme la page Contact) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: #f3efe8; /* Sand 50 */
    border: 1px solid rgba(18, 49, 33, 0.1); /* Forest 900 / 10% */
    padding: 32px;
    border-radius: 16px;
    width: 450px;
    max-width: 90vw;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    font-family: 'Montserrat', 'Inter', sans-serif;
}

.modal-content h2 {
    margin-top: 0;
    color: var(--primary);
    font-size: 24px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    text-align: center;
}

.modal-content p {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    margin-bottom: 24px;
}

.modal-content .control-group {
    margin-bottom: 16px;
}

.modal-content label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary);
    margin-bottom: 6px;
}

.modal-content input, .modal-content textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(18, 49, 33, 0.15);
    border-radius: 8px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    transition: all 0.2s ease;
    outline: none;
}

.modal-content input:focus, .modal-content textarea:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(18, 49, 33, 0.1);
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
}

.btn-primary {
    flex: 1;
    background: var(--primary);
    color: white;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    padding: 14px 20px;
    border: 1px solid rgba(28, 25, 23, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
}
.btn-secondary:hover { background: rgba(0,0,0,0.05); color: var(--text); }

.btn-quote {
    width: 100%;
    background: var(--primary);
    color: white;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 5px;
    transition: background 0.2s;
}
.btn-quote:hover {
    background: var(--primary-hover);
}
/* --- SCHEMA 2D INTERACTIF --- */

.schema-meuble {
    border: 6px solid var(--primary);
    border-bottom: none;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    width: 130px;
    margin: 8px auto;
    background-color: var(--panel-bg);
}

.niche-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 24px;
}

.niche-input {
    width: 55px;
    padding: 2px;
    border: 1px solid var(--primary);
    border-radius: 4px;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    color: var(--text);
    background: #fff;
    outline: none;
}

.schema-shelf-line {
    height: 4px;
    background-color: var(--primary);
    width: 100%;
    border-radius: 2px;
}

.distribute-btn {
    width: 100%;
    padding: 6px;
    margin-bottom: 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
}
.distribute-btn:hover {
    opacity: 0.9;
}

.schema-space {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 40px;
}

.schema-shelf {
    height: 6px;
    background: var(--primary);
    border-radius: 2px;
}

.schema-input-wrapper {
    display: flex;
    align-items: center;
    background: white;
    padding: 2px;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    z-index: 2;
}

.schema-input-wrapper input {
    width: 40px;
    padding: 2px;
    border: none;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--text);
    outline: none;
}

.schema-input-wrapper input.locked {
    color: var(--primary);
    font-weight: bold;
}

.schema-input-wrapper button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.schema-input-wrapper button:hover {
    opacity: 1;
}

.schema-input-wrapper button.locked {
    opacity: 1;
}


.schema-space-arrows {
    position: absolute;
    left: 20px;
    top: 5px;
    bottom: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--primary);
    font-size: 10px;
    opacity: 0.6;
}

.schema-space-arrows .arrow-up,
.schema-space-arrows .arrow-down {
    line-height: 1;
}

.schema-space-arrows .arrow-line {
    flex: 1;
    width: 1px;
    background-color: var(--primary);
    margin: 2px 0;
}

h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: var(--primary);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
}

input[type=number] {
    width: 100%;
    background: white;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
}

input[type=number]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 5px rgba(138, 106, 75, 0.3);
}

.shelf-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
}

.btn-icon {
    background: white;
    border: 1px solid var(--border);
    color: var(--text);
    width: 40px;
    height: 40px;
    border-radius: 6px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(0,0,0,0.05);
}

.btn-icon:active {
    transform: scale(0.95);
}

#shelf-count {
    font-weight: 600;
    font-size: 1.2rem;
}

.warning {
    color: var(--danger);
    font-size: 0.8rem;
    background: rgba(255, 76, 76, 0.1);
    padding: 8px;
    border-radius: 6px;
    border-left: 3px solid var(--danger);
    transition: opacity 0.3s ease;
}

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

.info-box {
    margin-top: 5px;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 10px;
}

/* --- MOBILE RESPONSIVENESS --- */


/* --- UI/UX PREMIUM SPLIT-SCREEN --- */
#app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-family: 'Montserrat', 'Inter', sans-serif;
    margin: 0;
}

#viewer-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#scene-background, #canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#scene-background {
    background-size: cover;
    background-position: center;
    background-color: var(--bg-light); /* Fallback */
    /* background-image: url('fond.jpg'); */
    z-index: 1;
}

#canvas-container {
    z-index: 2;
}

#canvas-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

/* --- VISUAL GRIDS --- */
.visual-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 10px;
}

.visual-card {
    position: relative;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.visual-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #ccc;
}

.visual-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.visual-card img {
    width: 100%;
    height: 80px;
    object-fit: contain;
    padding: 5px;
    box-sizing: border-box;
    background-color: #fff;
    border-bottom: 1px solid #f0f0f0;
}

.visual-card span {
    padding: 8px 5px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.check-icon {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--primary);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
}

.visual-card.active .check-icon {
    opacity: 1;
    transform: scale(1);
}

/* --- ACCORDIONS --- */
.accordion-container {
    padding: 0;
    margin: 0;
}
.accordion-item {
    border-bottom: 1px solid #eee;
}
.accordion-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    transition: background 0.2s;
}
.accordion-header:hover {
    background: #f0f0f0;
}
.accordion-header .chevron {
    transition: transform 0.3s ease;
}
.accordion-item.active > .accordion-header .chevron {
    transform: rotate(180deg);
}
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    padding: 0 20px;
    opacity: 0;
}
.accordion-item.active > .accordion-content {
    padding: 10px 20px 20px 20px;
    opacity: 1;
    max-height: 1500px;
}

/* Sous-accordéon */
.sub-accordion {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}
.sub-header {
    background: #f8f8f8;
    font-size: 14px;
    padding: 12px 15px;
}
.sub-accordion.active .sub-header {
    border-bottom: 1px solid #ddd;
}

/* --- TOOLTIPS --- */
.tooltip-container {
    position: relative;
    display: flex;
    align-items: center;
}
.info-icon {
    cursor: help;
}
.tooltip-box {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    width: 250px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    pointer-events: none;
}
.tooltip-container:hover .tooltip-box,
.info-icon:hover + .tooltip-box {
    opacity: 1;
    visibility: visible;
    transform: translateY(-4px);
}
.tooltip-box::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 20px;
    border-width: 6px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}
.tooltip-down .tooltip-box {
    bottom: auto;
    top: 100%;
    margin-bottom: 0;
    margin-top: 8px;
}
.tooltip-down .tooltip-box::after {
    top: auto;
    bottom: 100%;
    border-color: transparent transparent #333 transparent;
}

/* --- SVG CONTAINERS --- */
.svg-container {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    border-bottom: 1px solid #f0f0f0;
}
.svg-container svg {
    width: 40px;
    height: 40px;
}

/* --- COLOR GRID --- */
.color-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}
.color-swatch {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid #ddd;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.color-swatch.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}
.color-swatch[data-color="noir"] { background-color: #1a1a1a; }
.color-swatch[data-color="blanc"] { background-color: #f9f9f9; }
.color-swatch[data-color="brut"] { background: linear-gradient(135deg, #888, #555); }
.color-swatch[data-color="custom"] { 
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red); 
}
.color-swatch .check-icon {
    display: none;
    color: white;
    position: static;
    background: none;
    width: auto; height: auto; border-radius: 0;
}
.color-swatch[data-color="blanc"] .check-icon { color: black; }
.color-swatch.active .check-icon { display: block; }

@media (max-width: 768px) {
    body {
        overflow-y: auto !important;
        overflow-x: hidden;
    }
    html {
        overflow-y: auto !important;
    }

    #app-container {
        height: auto;
        overflow: visible;
        display: flex;
        flex-direction: column;
    }
    #viewer-area {
        flex: none;
        height: 60vh;
        width: 100vw;
    }
    #canvas-container {
        height: 100%;
        width: 100%;
    }
    .premium-panel {
        position: relative;
        width: 100vw;
        height: auto;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
        display: block;
    }
    .panel-content {
        overflow-y: visible;
        flex: none;
    }
}
