/* ============================================================
   Ecocup Configurateur 3D — Designer CSS
   Scope: .cv-configurator   |   
   Font: Bricolage Grotesque  |   Colors: #1E1E1E / #D3D2D0 / #F2F2F2
   ============================================================ */

/* =========================
   BASE RESET (scoped)
   ========================= */
.cv-configurator {
    font-family: 'Bricolage Grotesque', sans-serif;
    color: #1E1E1E;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.4;
    -webkit-user-select: none;
    user-select: none;
}

.cv-configurator input,
.cv-configurator textarea,
.cv-configurator .cv-recap-section {
    -webkit-user-select: text;
    user-select: text;
}

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

.cv-configurator button {
    font-family: 'Bricolage Grotesque', sans-serif;
    cursor: pointer;
}

.cv-configurator select {
    font-family: 'Bricolage Grotesque', sans-serif;
}

[x-cloak] {
    display: none !important;
}

/* =========================
   THREE.JS / FABRIC CONTAINERS
   ========================= */
.cv-three {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #F2F2F2;
}

/* Fabric canvas — JS sets custom properties, CSS applies safety clamps.
   top clamped via max() so fabric never overlaps header (≥120px from top).
   max-height (only when zoomed) ensures fabric never overlaps bottom actions. */
#fabric_container.cv-fabric {
    position: fixed;
    z-index: 15;
    border-radius: 8px;
    overflow: hidden;
    pointer-events: auto;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    /* !important on top to override inline style — CSS max() enforces minimum 120px */
    top: max(var(--cv-fc-top, 120px), 120px) !important;
}

/* max-height removed — JS (_calcBigRect) already computes correct dimensions
   respecting aspect ratio + header/bottom bounds. CSS max-height was truncating
   height without adjusting width, causing aspect ratio distortion. */

.cv-fabric .canvas-container {
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
}

.cv-fabric .canvas-container .lower-canvas,
.cv-fabric .canvas-container .upper-canvas {
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
}

/* #fabric_toggle — override cvmanager.css circle → sleek pill button */
#fabric_toggle {
    position: fixed !important;
    left: 16px !important;
    bottom: 16px !important;
    width: auto !important;
    height: auto !important;
    border-radius: 20px !important;
    background: rgba(30, 30, 30, 0.85) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff !important;
    font-family: 'Bricolage Grotesque', sans-serif !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0.3px;
    padding: 8px 16px !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    z-index: 20 !important;
    user-select: none !important;
    transition: background 0.2s ease, box-shadow 0.2s ease !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px;
}

#fabric_toggle:hover {
    background: rgba(30, 30, 30, 0.95) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* =========================
   HEADER
   ========================= */
.cv-header {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 8px;
}

.cv-logo {
    height: 52px;
    flex-shrink: 0;
}

.cv-logo img {
    height: 52px;
    width: auto;
    display: block;
}

.cv-header-sep {
    width: 2px;
    height: 42px;
    background: #D3D2D0;
    flex-shrink: 0;
}

.cv-header-title {
    font-size: 30px;
    font-weight: 700;
    color: #1E1E1E;
    white-space: nowrap;
}

/* =========================
   DESKTOP GRID LAYOUT
   ========================= */
.cv-desktop-grid {
    position: fixed;
    inset: 0;
    z-index: 16;
    pointer-events: none;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto 1fr auto;
    padding: 24px 24px 32px 16px;
    gap: 0 16px;
    max-height: 100vh;
    overflow: hidden;
}

.cv-desktop-grid>* {
    pointer-events: auto;
}

/* Close button inside header — pushed to the right */
.cv-header .cv3d-modal-close {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: none;
    cursor: pointer;
    color: #1E1E1E;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 0;
    transition: opacity 0.15s;
}

.cv-header .cv3d-modal-close:hover {
    opacity: 0.6;
}

/* Fabric placeholder — col 1 row 3, JS reads getBoundingClientRect for reduced canvas */
.cv-grid-left-fabric {
    grid-column: 1;
    grid-row: 3;
    pointer-events: none;
}


/* Right column — flex wrapper for sidebar + tapzone */
.cv-grid-right-col {
    grid-column: 3;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 310px;
    min-height: 0;
    /* allow shrinking inside 1fr grid row */
    overflow: hidden;
}

/* Tapzone — interactive click target, spans rows 2-3 col 3 */
.cv-grid-right-tapzone {
    grid-column: 3;
    grid-row: 2 / -1;
    min-height: 300px;
    cursor: url('../../img/canva-magnify-32.png') 16 16, zoom-in;
    border-radius: 8px;
    align-self: end;
}

@media (max-height: 899px) {
    .cv-grid-right-tapzone {
        min-height: 150px;
    }
}

/* =========================
   LEFT SIDEBAR — Navigation
   ========================= */
.cv-sidebar-left {
    grid-column: 1;
    grid-row: 2;
    align-self: center;
    width: 82px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 6px;
}

/* Left flyout (couleur panel) — positioned right of sidebar-left */
.cv-left-flyout {
    position: fixed;
    left: 110px;
    z-index: 16;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.cv-plastics {
    display: flex;
    gap: 12px;
}

.cv-plastic-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: border-color 0.15s, opacity 0.15s;
}

.cv-plastic-opt.active {
    border-color: #1E1E1E;
}

.cv-plastic-opt.inactive {
    opacity: 0.5;
}

.cv-plastic-opt:hover {
    opacity: 1;
}

.cv-plastic-opt span {
    font-size: 12px;
    font-weight: 600;
    color: #1E1E1E;
}

.cv-plastic-cup {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.cv-plastic-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: #888;
}

.cv-nav-item {
    width: 100%;
    padding: 10px 0;
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    transition: opacity 0.2s;
    position: relative;
}

.cv-nav-item:hover {
    opacity: 0.6;
}

.cv-nav-item.active {
    opacity: 1;
}

.cv-nav-item span:not(.cv-tooltip) {
    color: #1E1E1E;
    font-size: 11px;
    font-weight: 400;
    text-align: center;
    line-height: 1.2;
}

.cv-nav-item i,
.cv-nav-item svg {
    width: 24px;
    height: 24px;
    color: #1E1E1E;
}

.cv-nav-icon {
    width: 24px;
    height: 24px;
    display: block;
}

.cv-nav-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1.5px solid #1E1E1E;
    margin-top: 1px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
    color: #1E1E1E;
    font-weight: 700;
}

.cv-nav-indicator::after {
    content: '+';
    display: block;
}

/* Texte nav item wrapper — contains the main button + the add button below */
.cv-nav-item-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 6px;
    position: relative;
}

.cv-nav-item-wrap .cv-nav-item {
    width: 100%;
    padding-bottom: 4px;
}

.cv-nav-add {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid #1E1E1E;
    background: transparent;
    padding: 0;
    margin: 0 auto 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    color: #1E1E1E;
    font-weight: 400;
    transition: background 0.15s, color 0.15s;
}

.cv-nav-add::after {
    content: '+';
    display: block;
}

.cv-nav-add:hover {
    background: #1E1E1E;
    color: #fff;
}

/* ── Sidebar tooltip (desktop) ── */
.cv-tooltip {
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #1E1E1E;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    width: max-content;
    max-width: 200px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 100;
    white-space: normal;
    text-align: left;
}

.cv-tooltip strong {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.cv-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: #1E1E1E;
}

.cv-nav-item:hover>.cv-tooltip,
.cv-nav-item-wrap:hover>.cv-tooltip {
    opacity: 1;
}

.cv-nav-item.active>.cv-tooltip {
    display: none;
}

/* cv-sidebar-sep, cv-undo-btn removed — Annuler/Refaire supprimés */

/* =========================
   LEFT FLYOUT — Couleur panel (desktop only)
   ========================= */
.cv-left-flyout {
    position: fixed;
    left: calc(16px + 82px + 12px);
    top: 0;
    background: white;
    border-radius: 6px;
    box-shadow: 0px -4px 34px rgba(0, 0, 0, 0.15);
    padding: 14px 15px;
    z-index: 15;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Flyout layout: options in a row */
.cv-left-flyout .cv-plastics {
    display: flex;
    flex-direction: row;
    gap: 14px;
    flex-wrap: nowrap;
}

.cv-left-flyout .cv-plastic-opt {
    display: flex;
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 6px;
    height: 64px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: border-color 0.15s, opacity 0.15s;
}

.cv-left-flyout .cv-plastic-opt:hover {
    opacity: 0.8;
}

.cv-left-flyout .cv-plastic-opt.active {
    border-color: #1E1E1E;
}

.cv-left-flyout .cv-plastic-opt.active span {
    color: #1E1E1E;
    font-weight: 700;
}

.cv-left-flyout .cv-plastic-opt.inactive span {
    color: #AAAAAA;
    font-weight: 700;
}

.cv-left-flyout .cv-plastic-opt.inactive .cv-plastic-cup {
    opacity: 0.45;
}

.cv-left-flyout .cv-plastic-cup {
    width: 36px;
    height: 54px;
    flex-shrink: 0;
    object-fit: contain;
}

.cv-left-flyout .cv-plastic-opt span {
    font-size: 18px;
    font-weight: 700;
    color: #1E1E1E;
    text-align: center;
    white-space: nowrap;
}

/* Hint line under plastic options */
.cv-plastic-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 13px;
    color: #555;
}

.cv-plastic-hint svg {
    flex-shrink: 0;
}

/* =========================
   RIGHT SIDEBAR — Panel container
   ========================= */
.cv-sidebar-right {
    flex: 0 1 auto;
    /* natural height, can shrink — never grows past content */
    min-height: 0;
    /* allow shrinking — critical for grid containment */
    overflow: hidden;
    background: white;
    border-radius: 6px;
    padding: 24px;
    box-shadow: 0 4px 34px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0;
    transition: margin-top 0.35s ease, max-height 0.35s ease;
}

/* Compact mode: when 3D is minimized (fabricZoomed), shrink sidebar to leave room for mini 3D */
.cv-sidebar-right.cv-sidebar-compact {
    max-height: calc(100vh - 420px);
    /* leave ~300px for tapzone + header + padding */
}

@media (max-height: 899px) {
    .cv-sidebar-right.cv-sidebar-compact {
        max-height: calc(100vh - 260px);
        /* smaller tapzone on short screens */
    }
}

/* Scrollbar styling */
.cv-sidebar-right::-webkit-scrollbar {
    width: 4px;
}

.cv-sidebar-right::-webkit-scrollbar-track {
    background: transparent;
}

.cv-sidebar-right::-webkit-scrollbar-thumb {
    background: #D3D2D0;
    border-radius: 4px;
}

/* Panel transition — 3 phases: fade-out content → animate height → fade-in content */
.cv-sidebar-right .cv-panel>* {
    transition: opacity 0.18s ease;
}

.cv-sidebar-right.cv-panel-fading .cv-panel>* {
    opacity: 0;
}

/* Height + centering animation between panels */
.cv-sidebar-right.cv-panel-resizing {
    transition: height 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        margin-top 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

/* Panel wrapper — CSS Grid: header / content / footer */
.cv-panel {
    display: grid;
    grid-template-rows: auto 1fr auto;
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin-right: -5px;
}

/* Recap panel: body is first child, spans all rows */
.cv-panel>.cv-panel-body:first-child {
    grid-row: 1 / -1;
}

/* Panel header — flex row, close button + panel-specific content */
.cv-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0 12px 0;
}

.cv-panel-header>*:not(.cv-panel-close) {
    flex: 1;
    min-width: 0;
}

/* Scrollable content area */
.cv-panel-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding-right: 8px;
}

.cv-panel-body::-webkit-scrollbar {
    width: 3px;
}

.cv-panel-body::-webkit-scrollbar-track {
    background: transparent;
}

.cv-panel-body::-webkit-scrollbar-thumb {
    background: #D3D2D0;
    border-radius: 3px;
}

/* Scrollable content area within panels — natural height, no flex grow */
.cv-motifs-grid,
.cv-tpl-grid-container {
    min-height: 0;
}

/* Panel close (X) button — first in DOM, visually last via order */
.cv-panel-close {
    order: 99;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #939798;
    cursor: pointer;
    transition: color 0.15s;
    padding: 0;
    flex-shrink: 0;
}

.cv-panel-close:hover {
    color: #1E1E1E;
}

/* Panel footer — CTA + help text, fixed at bottom */
.cv-panel-footer {
    display: flex;
    flex-direction: column;
    padding-top: 8px;
    background: white;
}

.cv-panel-recap {
    grid-template-rows: 1fr auto;
}

.cv-panel-recap>.cv-panel-body:first-child {
    grid-row: auto;
}

.cv-recap-footer {
    gap: 12px;
    padding-top: 12px;
}

.cv-recap-footer .cv-divider {
    margin: 0;
}

.cv-recap-qty {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cv-recap-qty label {
    font-size: 14px;
    font-weight: 700;
}

.cv-recap-qty .cv-qty-select {
    width: 110px;
}

.cv-recap-cta-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cv-recap-cta-row .cv-recap-pricing {
    flex: 0 0 auto;
    text-align: left;
}

.cv-recap-cta-row .cv-unit-price {
    font-size: 22px;
}

.cv-recap-cta-row .cv-btn-valider {
    flex: 1;
    margin: 0;
    padding: 12px 16px;
    width: auto;
    font-size: 14px;
}

/* Help text */
.cv-panel-help {
    font-size: 12px;
    color: #939798;
    text-align: center;
    line-height: 1.4;
    padding: 12px 0 4px;
}

/* =========================
   PANEL: RÉCAPITULATIF
   ========================= */
.cv-recap-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.cv-recap-section {
    padding: 12px 0;
}

.cv-recap-label {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
}

.cv-recap-color {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cv-recap-color-swatch {
    width: 40px;
    height: 56px;
    border-radius: 4px;
    border: 1px solid #E5E5E5;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.cv-recap-color-name {
    font-size: 14px;
    font-weight: 500;
}

.cv-recap-text {
    font-size: 14px;
    margin-bottom: 4px;
}

.cv-recap-text strong {
    font-weight: 700;
}

.cv-recap-images {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.cv-recap-img {
    width: 72px;
    height: 72px;
    border-radius: 6px;
    border: 1px solid #E5E5E5;
    object-fit: contain;
    background: #F8F8F8;
}

.cv-recap-graduation {
    font-size: 14px;
    font-weight: 500;
}

/* =========================
   PANEL: TEXTE — Text editing
   ========================= */
.cv-text-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 0;
    margin-bottom: 0;
}

.cv-text-block:last-of-type {
    padding-bottom: 0;
    margin-bottom: 0;
}

.cv-text-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.cv-text-block-title {
    font-size: 14px;
    font-weight: 700;
    color: #939798;
}

.cv-text-block.active .cv-text-block-title {
    color: #1E1E1E;
}

.cv-text-block-delete {
    background: transparent;
    border: none;
    color: #939798;
    transition: color 0.2s;
    padding: 4px;
    flex-shrink: 0;
    cursor: pointer;
}

.cv-text-block-delete:hover {
    color: #1E1E1E;
}

.cv-text-block-delete svg {
    width: 20px;
    height: 20px;
}

/* Text input line: chip row + delete button */
.cv-text-input-line {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.cv-text-input-line .cv-text-chip-row {
    flex: 1 1 0%;
    margin-bottom: 0;
}

/* Text input chip */
.cv-text-chip-row {
    display: flex;
    align-items: center;
    border: 1px solid #D3D2D0;
    border-radius: 6px;
    padding: 6px 10px;
    min-height: 40px;
    background: white;
    gap: 6px;
    margin-bottom: 10px;
    min-width: 0;
    overflow: hidden;
}

.cv-text-chip-row:focus-within,
.cv-text-block.active .cv-text-chip-row {
    border: 2px solid #1E1E1E;
    padding: 5px 9px;
}

.cv-text-chip-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.cv-text-chip-icon svg {
    width: 18px;
    height: 16px;
    color: #1E1E1E;
}

.cv-text-chip-input {
    border: none;
    outline: none;
    font-size: 14px;
    font-family: 'Bricolage Grotesque', sans-serif;
    color: #1E1E1E;
    background: transparent;
    flex: 1 1 0%;
    min-width: 0;
    width: 100%;
    resize: none;
    overflow: hidden;
    line-height: 1.4;
    padding: 0;
    field-sizing: content;
}

.cv-text-chip-input::placeholder {
    color: #939798;
}

.cv-text-chip-clear {
    width: 18px;
    height: 18px;
    background: #1E1E1E;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cv-text-chip-clear svg {
    width: 10px;
    height: 10px;
    color: white;
}

/* Textarea (for add text view) */
.cv-textarea {
    width: 100%;
    min-height: 100px;
    padding: 14px;
    border: 1px solid #D3D2D0;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Bricolage Grotesque', sans-serif;
    color: #1E1E1E;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.cv-textarea::placeholder {
    color: #939798;
}

.cv-textarea:focus {
    border-color: #1E1E1E;
}

/* =========================
   Font picker dropdown
   ========================= */
.cv-fontpick {
    position: relative;
}

/* Trigger (closed state) — thin border, font preview, chevron */
.cv-fontpick-trigger {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #fff;
    border: 1px solid #D3D2D0;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.cv-fontpick-trigger:hover {
    border-color: #1E1E1E;
}

.cv-fontpick-preview-wrap {
    flex: 1 1 0%;
    min-width: 0;
    height: 22px;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.cv-fontpick-preview {
    height: 22px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    object-position: left center;
}

.cv-fontpick-fallback {
    font-size: 14px;
    font-weight: 600;
    color: #1E1E1E;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cv-fontpick-chevron {
    flex-shrink: 0;
    color: #1E1E1E;
    transition: transform 0.2s;
}

.cv-fontpick-chevron.open {
    transform: rotate(180deg);
}

/* Dropdown panel (open state) — fixed so it escapes overflow:hidden parents */
.cv-fontpick-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid #D3D2D0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    overflow: hidden;
}

/* Panel wrapper — transparent on desktop, card on mobile */
.cv-fontpick-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Search bar inside dropdown */
.cv-fontpick-search-wrap {
    padding: 8px 10px 6px;
    border-bottom: 1px solid #EBEBEB;
}

.cv-fontpick-search {
    width: 100%;
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
    font-family: 'Bricolage Grotesque', sans-serif;
    color: #1E1E1E;
    background: #F5F5F5;
    border: 1px solid transparent;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s;
}

.cv-fontpick-search:focus {
    border-color: #1E1E1E;
    background: #fff;
}

.cv-fontpick-search::placeholder {
    color: #939798;
}

/* Scrollable list */
.cv-fontpick-list {
    max-height: 260px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 0;
}

.cv-fontpick-list::-webkit-scrollbar {
    width: 4px;
}

.cv-fontpick-list::-webkit-scrollbar-track {
    background: transparent;
}

.cv-fontpick-list::-webkit-scrollbar-thumb {
    background: #D3D2D0;
    border-radius: 4px;
}

/* Individual font option */
.cv-fontpick-item {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.1s;
}

.cv-fontpick-item:hover {
    background: #F5F5F5;
}

.cv-fontpick-item.active {
    background: #EBEBEB;
}

.cv-fontpick-item img {
    height: 24px;
    width: 100%;
    object-fit: contain;
    object-position: left center;
    pointer-events: none;
}

/* Formatting row: color + alignment */
.cv-fmt-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.cv-color-trigger {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    gap: 3px;
}

.cv-color-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #E5E5E5;
    transition: border-color 0.2s;
}

.cv-color-trigger:hover .cv-color-circle {
    border-color: #1E1E1E;
}

.cv-color-trigger span {
    font-size: 9px;
    color: #1E1E1E;
}

.cv-color-trigger input[type="color"] {
    display: none;
}

.cv-fmt-btn {
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #C0C0C0;
    transition: all 0.15s;
    border-radius: 4px;
}

.cv-fmt-btn:hover {
    color: #1E1E1E;
}

.cv-fmt-btn.active {
    color: #1E1E1E;
}

.cv-fmt-btn svg {
    width: 18px;
    height: 18px;
}

/* Alignment buttons */
.cv-align-btns {
    display: flex;
    gap: 2px;
    margin-top: 3px;
    /* vertically center with 32px color circle */
}

.cv-align-btn {
    width: 26px;
    height: 26px;
    background: #E5E5E5;
    border: none;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.15s;
}

.cv-align-btn:first-child {
    border-radius: 3px 0 0 3px;
}

.cv-align-btn:last-child {
    border-radius: 0 3px 3px 0;
}

.cv-align-btn.active {
    background: #1E1E1E;
    color: white;
}

.cv-align-btn::before,
.cv-align-btn::after {
    content: '';
    position: absolute;
    height: 1.5px;
    background: currentColor;
}

.cv-align-btn::before {
    width: 14px;
    top: 8px;
}

.cv-align-btn::after {
    width: 10px;
    top: 13px;
}

.cv-align-btn[data-align="left"]::before,
.cv-align-btn[data-align="left"]::after {
    left: 5px;
}

.cv-align-btn[data-align="center"]::before,
.cv-align-btn[data-align="center"]::after {
    left: 50%;
    transform: translateX(-50%);
}

.cv-align-btn[data-align="right"]::before,
.cv-align-btn[data-align="right"]::after {
    right: 5px;
}

/* Font size stepper */
.cv-size-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cv-size-row label {
    font-size: 14px;
    font-weight: 600;
}

.cv-size-stepper {
    display: flex;
    align-items: center;
    border: 1px solid #D3D2D0;
    border-radius: 6px;
    overflow: hidden;
}

.cv-size-stepper button {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #1E1E1E;
    transition: background 0.15s;
}

.cv-size-stepper button:hover {
    background: #F4F4F4;
}

.cv-size-val {
    min-width: 52px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    border-left: 1px solid #D3D2D0;
    border-right: 1px solid #D3D2D0;
    padding: 6px 8px;
    white-space: nowrap;
}

/* Edit actions — inline in fmt-row, pushed right */
.cv-edit-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    margin-top: 4px;
    /* vertically center with 32px color circle */
}

.cv-edit-action {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #939798;
    transition: color 0.15s;
    padding: 4px;
    cursor: pointer;
}

.cv-edit-action:hover {
    color: #1E1E1E;
}

.cv-edit-action svg {
    width: 16px;
    height: 16px;
}

/* =========================
   PANEL: COULEUR — Plastic selection
   ========================= */
.cv-plastics {
    display: flex;
    gap: 12px;
}

.cv-plastic-opt {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    border: 2px solid #F2F2F2;
    border-radius: 12px;
    padding: 20px 12px 16px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.cv-plastic-opt:hover {
    border-color: #D3D2D0;
}

.cv-plastic-opt.active {
    border-color: #1E1E1E;
}

.cv-plastic-cup {
    width: 48px;
    height: 66px;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.10));
}

.cv-plastic-opt span {
    font-size: 13px;
    font-weight: 500;
    color: #1E1E1E;
}

/* =========================
   PANEL: MOTIFS — Search + categories + grid
   ========================= */
.cv-motifs-search {
    position: relative;
    margin-bottom: 0;
}

.cv-motifs-search input {
    width: 100%;
    padding: 10px 40px 10px 14px;
    font-size: 14px;
    font-family: 'Bricolage Grotesque', sans-serif;
    color: #1E1E1E;
    border: 1px solid #D3D2D0;
    border-radius: 20px;
    outline: none;
    transition: border-color 0.2s;
}

.cv-motifs-search input::placeholder {
    color: #939798;
}

.cv-motifs-search input:focus {
    border-color: #1E1E1E;
}

.cv-motifs-search .cv-search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #1E1E1E;
    pointer-events: none;
}

.cv-motifs-heading {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
}

/* Category tag buttons (full-width stacked for motif search) */
.cv-category-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cv-category-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #1E1E1E;
    background: #F2F2F2;
    border: none;
    border-radius: 8px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.cv-category-btn:hover {
    background: #E5E5E5;
}

.cv-category-btn.active {
    background: #1E1E1E;
    color: white;
}

/* Motifs breadcrumb — reuses template breadcrumb styles */
.cv-motifs-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.cv-motifs-breadcrumb .cv-tpl-bc-item {
    background: transparent;
    border: none;
    font-size: 13px;
    color: #939798;
    padding: 2px 4px;
    cursor: pointer;
    font-family: 'Bricolage Grotesque', sans-serif;
    transition: color 0.15s;
}

.cv-motifs-breadcrumb .cv-tpl-bc-item:hover {
    color: #1E1E1E;
}

.cv-motifs-breadcrumb .cv-tpl-bc-item.active {
    color: #1E1E1E;
    font-weight: 700;
    cursor: default;
}

.cv-motifs-breadcrumb .cv-tpl-bc-sep-wrap {
    display: inline-flex;
    align-items: center;
}

.cv-motifs-breadcrumb .cv-tpl-bc-sep {
    color: #D3D2D0;
    font-size: 13px;
    margin: 0 2px;
}

/* Filter tags (inline, for after category selection) */
.cv-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.cv-filter-tag {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #1E1E1E;
    background: #F2F2F2;
    border: 1px solid #E5E5E5;
    border-radius: 4px;
    transition: all 0.15s;
}

.cv-filter-tag:hover {
    border-color: #1E1E1E;
}

.cv-filter-tag.active {
    background: #1E1E1E;
    color: white;
    border-color: #1E1E1E;
}

/* Active category chip with X */
.cv-active-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    background: #1E1E1E;
    border: none;
    border-radius: 16px;
    margin-bottom: 12px;
}

.cv-active-tag svg {
    width: 12px;
    height: 12px;
}

/* Motif grid */
@keyframes cv-motif-in {
    from {
        opacity: 0;
        transform: scale(0.82);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@property --cv-thumb-min {
    syntax: '<length>';
    inherits: true;
    initial-value: 70px;
}

.cv-motifs-grid {
    --cv-thumb-min: 70px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--cv-thumb-min), 1fr));
    gap: 8px;
    transition: --cv-thumb-min 0.35s ease, gap 0.35s ease;
}

/* Smaller thumbs when viewport height is limited */
@media (max-height: 800px) {
    .cv-motifs-grid {
        --cv-thumb-min: 55px;
        gap: 4px;
    }
}

@media (max-height: 600px) {
    .cv-motifs-grid {
        --cv-thumb-min: 44px;
        gap: 3px;
    }
}

@media (max-width: 768px) {
    .cv-motifs-grid {
        --cv-thumb-min: 35px;
        gap: 3px;
    }
}

.cv-motif-thumb {
    aspect-ratio: 1;
    border: none;
    border-radius: 0;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: opacity 0.2s, transform 0.2s ease;
    padding: 4px;
    animation: cv-motif-in 0.3s ease-out both;
}

.cv-motif-thumb:hover {
    opacity: 0.7;
    transform: scale(1.06);
}

.cv-motif-thumb.active {
    opacity: 0.7;
}

.cv-motif-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cv-motif-thumb span {
    font-size: 11px;
    color: #939798;
    text-align: center;
    padding: 4px;
}

/* =========================
   PANEL: MODÈLES (SVG Templates)
   ========================= */

/* Collection select dropdown */
.cv-tpl-select-wrap {
    position: relative;
}

.cv-tpl-select {
    width: 100%;
    padding: 12px 36px 12px 14px;
    font-size: 14px;
    font-weight: 500;
    color: #1E1E1E;
    background: #fff;
    border: 1px solid #D3D2D0;
    border-radius: 8px;
    font-family: 'Bricolage Grotesque', sans-serif;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23939798' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.cv-tpl-select:focus {
    outline: none;
    border-color: #1E1E1E;
}

/* Template thumbnail grid */
.cv-tpl-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.cv-tpl-thumb {
    aspect-ratio: 1;
    border: 1px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: transparent;
    transition: border-color 0.2s;
    position: relative;
}

.cv-tpl-thumb:hover {
    border-color: #D3D2D0;
}

.cv-tpl-thumb.active {
    border-color: #1E1E1E;
}

.cv-tpl-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cv-tpl-label {
    font-size: 11px;
    color: #939798;
    text-align: center;
    padding: 6px;
    line-height: 1.3;
}

/* Hover overlay label — shows template name on hover (above rotate overlays) */
.cv-tpl-hover-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    padding: 4px 2px;
    line-height: 1.2;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.cv-tpl-thumb:hover .cv-tpl-hover-label {
    opacity: 1;
}

/* =========================
   PANEL: IMPORTER
   ========================= */
.cv-import-heading {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.cv-import-zone {
    border: 2px dashed #D3D2D0;
    border-radius: 8px;
    padding: 40px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: #F8F8F8;
    margin-bottom: 16px;
}

.cv-import-zone:not(.disabled):hover {
    border-color: #1E1E1E;
    background: #F2F2F2;
}

.cv-import-zone.drag-over {
    border-color: #1E1E1E;
    background: #F2F2F2;
}

.cv-import-zone.disabled {
    opacity: 1;
    pointer-events: none;
}

.cv-import-zone-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.cv-import-zone-or {
    font-size: 14px;
    color: #939798;
    margin-bottom: 12px;
}

.cv-import-zone-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: #1E1E1E;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
}

.cv-import-zone-btn svg {
    width: 16px;
    height: 16px;
}

.cv-import-zone input[type="file"] {
    display: none;
}

.cv-import-warning {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #FFF9E6;
    border: 1px solid #F0E0A0;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}

.cv-import-warning-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: #939798;
    padding: 2px;
}

.cv-import-warning-close svg {
    width: 14px;
    height: 14px;
}

.cv-import-constraints {
    font-size: 13px;
    color: #1E1E1E;
    margin-bottom: 12px;
    line-height: 1.6;
}

.cv-import-constraints strong {
    font-weight: 700;
}

.cv-import-template-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #D4A843;
    font-size: 13px;
    text-decoration: none;
    margin-bottom: 16px;
    cursor: pointer;
}

.cv-import-template-link:hover {
    text-decoration: underline;
}

.cv-import-template-link svg {
    width: 16px;
    height: 16px;
}

.cv-import-wrap {
    position: relative;
}

.cv-import-rights {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border-radius: 8px;
    opacity: 1;
    transition: opacity 0.35s ease;
}

.cv-import-rights.cv-rights-accepted {
    opacity: 0;
    pointer-events: none;
}

.cv-import-rights input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: #1E1E1E;
    flex-shrink: 0;
}

.cv-import-rights label {
    font-size: 12px;
    color: #1E1E1E;
    line-height: 1.5;
    cursor: pointer;
}

/* Image edit panel (when imported image is selected) */
.cv-import-edit-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
}

.cv-import-edit-sub {
    font-size: 12px;
    color: #939798;
    margin-bottom: 16px;
}

.cv-import-edit-size-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
}

.cv-import-edit-size-current {
    font-size: 13px;
    color: #939798;
    margin-bottom: 12px;
}

.cv-import-edit-dimensions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.cv-import-dimension-field {
    flex: 1;
}

.cv-import-dimension-field label {
    display: block;
    font-size: 11px;
    color: #939798;
    margin-bottom: 4px;
}

.cv-import-dimension-field input {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    color: #1E1E1E;
    border: 1px solid #D3D2D0;
    border-radius: 6px;
    text-align: center;
    outline: none;
    font-family: 'Bricolage Grotesque', sans-serif;
}

.cv-import-dimension-field input:focus {
    border-color: #1E1E1E;
}

/* =========================
   PANEL: GRADUATION
   ========================= */
.cv-graduation-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.cv-graduation-desc {
    font-size: 13px;
    color: #939798;
    margin-bottom: 16px;
    line-height: 1.5;
}

.cv-checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.cv-checkbox-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #1E1E1E;
    flex-shrink: 0;
}

.cv-checkbox-row label {
    font-size: 14px;
    color: #1E1E1E;
    cursor: pointer;
}

.cv-graduation-options-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
}

.cv-graduation-sub-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    padding-left: 4px;
}

.cv-graduation-sub-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #1E1E1E;
    flex-shrink: 0;
    margin-top: 1px;
}

.cv-graduation-sub-option label {
    font-size: 13px;
    color: #1E1E1E;
    cursor: pointer;
    line-height: 1.4;
}

.cv-graduation-sub-label {
    font-size: 12px;
    color: #939798;
    display: block;
}

.cv-graduation-price {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #E5E5E5;
}

.cv-graduation-price-amount {
    font-size: 20px;
    font-weight: 700;
}

.cv-graduation-price-detail {
    font-size: 12px;
    color: #939798;
}

/* =========================
   QUANTITY ROW
   ========================= */
.cv-qty-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
}

.cv-qty-row label {
    font-size: 14px;
    font-weight: 700;
}

.cv-qty-select {
    padding: 8px 32px 8px 12px;
    font-size: 14px;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 600;
    color: #1E1E1E;
    border: 1px solid #D3D2D0;
    border-radius: 6px;
    appearance: none;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231E1E1E' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
    cursor: pointer;
}

/* Dividers */
.cv-divider {
    border: none;
    border-top: 1px solid #E5E5E5;
    margin: 0;
}

/* =========================
   ADD TEXT BUTTON
   ========================= */
.cv-add-text-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px;
    border: 1px dashed #D3D2D0;
    border-radius: 6px;
    background: transparent;
    color: #939798;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Bricolage Grotesque', sans-serif;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.cv-add-text-btn:hover {
    border-color: #1E1E1E;
    color: #1E1E1E;
}

.cv-add-text-btn svg {
    flex-shrink: 0;
}

/* =========================
   VALIDER BUTTON
   ========================= */
.cv-btn-valider {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    margin-bottom: 16px;
    background: #1E1E1E;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
    font-family: 'Bricolage Grotesque', sans-serif;
}

.cv-btn-valider:hover {
    background: #000;
}

/* cv-btn-valider: sticky override removed — now inside .cv-panel-footer via grid */

/* =========================
   BOTTOM ACTIONS (desktop)
   ========================= */
.cv-bottom-actions {
    grid-column: 2;
    grid-row: 3;
    justify-self: center;
    align-self: end;
    display: flex;
    gap: 40px;
}

.cv-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: #1E1E1E;
    transition: opacity 0.2s;
}

.cv-action-btn:hover {
    opacity: 0.7;
}

.cv-action-btn svg {
    width: 24px;
    height: 24px;
}

.cv-action-btn span {
    font-size: 11px;
}

/* cv-pricing removed — price in cv-sidebar-right recap */
.cv-unit-price {
    font-size: 24px;
    font-weight: 700;
    color: #D4A843;
}

.cv-price-detail {
    font-size: 12px;
    color: #939798;
}

.cv-total-price {
    font-size: 13px;
    color: #1E1E1E;
}

.cv-btn-cart {
    padding: 14px 28px;
    background: #1E1E1E;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    font-family: 'Bricolage Grotesque', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.cv-btn-cart:hover {
    background: #000;
}

/* =========================
   MOBILE BOTTOM-SHEET
   ========================= */
.cv-bottom-sheet {
    display: none;
}

/* =========================
   MOBILE SECOND TAB BAR (Texte/Motifs/Importer/Graduation)
   ========================= */
.cv-mobile-tab-bar {
    display: none;
}

/* =========================
   MOBILE BOTTOM NAV
   ========================= */
.cv-mobile-nav {
    display: none;
}

.cv-mobile-view-toggle {
    display: none;
}

/* =========================
   CV3D ENGINE OVERRIDES
   ========================= */
.ui_save,
#ui_tabs,
#ui_tab_dev,
#ui_tab_edit,
#ui_container,
#font_error_warning {
    display: none !important;
}

/* =========================
   PRELOADER
   ========================= */
.cv-preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #F2F2F2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cv-preloader-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cv-preloader-ring {
    width: 100px;
    height: 100px;
}

.cv-preloader-track {
    stroke: #E5E5E5;
    stroke-width: 4;
    fill: none;
}

.cv-preloader-fill {
    stroke: #1E1E1E;
    stroke-width: 4;
    fill: none;
    stroke-linecap: round;
    stroke-dasharray: 264;
    stroke-dashoffset: 264;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    transition: stroke-dashoffset 0.4s ease;
}

.cv-preloader-pct {
    position: absolute;
    font-size: 18px;
    font-weight: 600;
    color: #1E1E1E;
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
}

.cv-preloader.done {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

/* Hide CVManager built-in activity overlay (unstyled empty divs) */
[class*="cv3d-activity"] {
    display: none !important;
}

/* =========================
   RESPONSIVE: Tablet (≤1200px)
   ========================= */
@media (max-width: 1200px) {
    .cv-grid-right-col {
        width: 280px;
    }

    .cv-sidebar-right {
        padding: 20px;
    }

    .cv-header-title {
        font-size: 24px;
    }
}

@media (max-width: 992px) {
    .cv-header {
        padding: 0 4px;
    }

    .cv-sidebar-left {
        width: 72px;
    }

    .cv-desktop-grid {
        padding-left: 8px;
        padding-right: 16px;
    }

    .cv-grid-right-col {
        width: 260px;
    }

    .cv-sidebar-right {
        padding: 16px;
    }

    .cv-btn-cart {
        width: 100%;
        text-align: center;
    }
}

/* =========================
   RESPONSIVE: Mobile (≤768px)
   ========================= */
@media (max-width: 768px) {

    /* ── Full-screen fixed shell ── */
    .cv-configurator {
        position: fixed;
        inset: 0;
        overflow: hidden;
    }

    /* ── Header: slim bar, always on top ── */
    .cv-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 10px 16px;
        z-index: 20;
        gap: 12px;
        height: 52px;
        box-sizing: border-box;
    }

    .cv-logo {
        height: 30px;
    }

    .cv-logo img {
        height: 30px;
    }

    .cv-back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        background: none;
        cursor: pointer;
        color: #1E1E1E;
        padding: 0;
        margin: 9px -8px 0 -12px;
        flex-shrink: 0;
    }

    .cv-header-sep {
        height: 24px;
    }

    .cv-header-title {
        font-size: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
        flex: 1;
    }

    /* ── 3D viewport: truly fullscreen, header + nav overlay on top ──
         !important needed to override #three_container in cvmanager.css (ID > class) */
    .cv-three {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0;
        z-index: 1 !important;
    }

    /* ── Fabric 2D canvas: on mobile, no desktop clamps ── */
    #fabric_container.cv-fabric {
        position: fixed !important;
        z-index: 10;
        /* Override desktop max() clamp — mobile uses raw custom property value */
        top: var(--cv-fc-top, 0px) !important;
        max-height: none;
    }

    /* When fabric is the main view (2D mode), flush appearance */
    .cv-fabric.mobile-2d-main {
        border-radius: 4px;
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.10);
    }

    /* ── Hide desktop #fabric_toggle, use custom mobile button ── */
    #fabric_toggle {
        display: none !important;
    }

    /* ── Mobile 2D/3D toggle button — icon only, right:16 ── */
    .cv-mobile-view-toggle {
        position: fixed;
        bottom: 96px;
        right: 8px;
        z-index: 8;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(30, 30, 30, 0.82);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        border: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
        display: flex !important;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.2s, transform 0.2s;
        overflow: hidden;
    }

    .cv-mobile-view-toggle:active {
        transform: scale(0.90);
    }

    .cv-mobile-view-toggle svg {
        width: 16px;
        height: 16px;
        color: #fff;
        flex-shrink: 0;
    }

    .cv-mobile-view-toggle .cv-toggle-label {
        font-size: 13px;
        font-weight: 700;
        color: #fff;
        line-height: 1;
        font-family: 'Bricolage Grotesque', sans-serif;
    }


    /* ── Motifs search spacing in bottom-sheet ── */
    .cv-motifs-search {
        margin-bottom: 10px;
    }

    /* ── Mobile bottom-sheet: slides up over 3D ── */
    .cv-bottom-sheet {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 30;
        background: white;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.12);
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        max-height: 70vh;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-bottom: 72px;
    }

    .cv-bottom-sheet.open {
        transform: translateY(0);
    }

    /* After transition: remove transform so position:fixed children (font dropdown) work */
    .cv-bottom-sheet.settled {
        transform: none;
    }

    /* ── Enlarged touch area, visual pill via ::after ── */
    .cv-bottom-sheet-handle {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 10px 0 4px;
        margin: 0 0 8px;
        cursor: grab;
        flex-shrink: 0;
    }

    .cv-bottom-sheet-handle::before {
        content: '';
        width: 40px;
        height: 4px;
        background: #D3D2D0;
        border-radius: 2px;
        display: block;
        pointer-events: none;
    }

    .cv-bottom-sheet-handle::after {
        display: none;
    }

    .cv-bottom-sheet-title {
        font-size: 14px;
        font-weight: 600;
        color: #1E1E1E;
        text-align: center;
        margin-top: 6px;
    }

    .cv-tooltip {
        display: none !important;
    }

    .cv-bottom-sheet-content {
        padding: 0 20px 20px;
    }

    .cv-bottom-sheet.with-tabs {
        padding-bottom: 120px;
    }

    /* ── Mobile text panel: sticky footer (add-text + help + validate) ── */
    .cv-mobile-text-footer {
        position: sticky;
        bottom: 0;
        z-index: 2;
        background: #fff;
        padding-top: 4px;
    }

    .cv-add-text-btn {
        margin-top: 8px;
    }

    /* ── Mobile second tab bar (Texte / Motifs / Importer / Graduation) ── */
    .cv-mobile-tab-bar {
        display: flex !important;
        align-items: center;
        justify-content: space-around;
        background: white;
        border-top: 1px solid #E5E5E5;
        padding: 0;
        position: fixed;
        bottom: 64px;
        left: 0;
        right: 0;
        z-index: 32;
        height: 48px;
    }

    .cv-mobile-tab-bar.hidden {
        display: none !important;
    }

    .cv-mobile-tab-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        background: transparent;
        border: none;
        color: #939798;
        font-size: 10px;
        height: 100%;
        transition: color 0.15s;
    }

    .cv-mobile-tab-btn.active {
        color: #1E1E1E;
    }

    .cv-mobile-tab-btn svg {
        width: 18px;
        height: 18px;
    }

    /* ── Mobile bottom nav: always fixed at bottom ──
         display: flex !important overrides .cv-mobile-only { display: block !important } */
    .cv-mobile-nav {
        display: flex !important;
        align-items: center;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 35;
        background: white;
        box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.08);
        height: 64px;
    }

    .cv-mobile-nav-items {
        display: flex;
        align-items: center;
        flex: 1 1 0%;
        height: 100%;
    }

    .cv-mobile-nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        background: transparent;
        border: none;
        color: #1E1E1E;
        height: 100%;
    }

    .cv-mobile-nav-btn.active {
        color: #1E1E1E;
        font-weight: 600;
    }

    .cv-mobile-nav-btn svg {
        width: 20px;
        height: 20px;
    }

    .cv-mobile-nav-btn span {
        font-size: 10px;
    }

    .cv-mobile-nav-divider {
        width: 1px;
        height: 28px;
        background: #E5E5E5;
        flex-shrink: 0;
    }

    .cv-mobile-pricing {
        display: flex;
        flex-direction: column;
        padding: 0 12px;
        flex-shrink: 0;
        cursor: pointer;
    }

    .cv-mobile-pricing .cv-unit-price {
        font-size: 16px;
        font-weight: 700;
        color: #D4A843;
    }

    .cv-mobile-pricing .cv-price-detail {
        font-size: 9px;
        color: #939798;
    }

    .cv-mobile-pricing .cv-total-price {
        font-size: 10px;
        color: #1E1E1E;
    }

    .cv-mobile-pricing-cta {
        font-size: 9px;
        color: #D4A843;
        font-weight: 500;
    }

    /* Recap tab — floats above the bottom nav */
    .cv-mobile-recap-tab {
        position: fixed;
        bottom: 64px;
        right: 0;
        z-index: 36;
        display: flex;
        align-items: center;
        gap: 4px;
        background: #1E1E1E;
        color: #fff;
        padding: 4px 10px;
        border-radius: 8px 0 0 0;
        cursor: pointer;
    }

    .cv-mobile-recap-tab-price {
        font-size: 10px;
        font-weight: 700;
        color: #D4A843;
    }

    .cv-mobile-recap-tab-cta {
        font-size: 9px;
        color: #fff;
        opacity: 0.7;
    }

    .cv-mobile-cart-btn {
        width: 56px;
        height: 64px;
        background: #1E1E1E;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .cv-mobile-cart-btn svg {
        width: 24px;
        height: 24px;
        color: white;
    }

    .cv-mobile-recap-btn svg {
        width: 14px;
        height: 12px;
    }

    /* Diagonal resize-grip in bottom-right corner of cart btn */
    .cv-mobile-cart-btn {
        position: relative;
        overflow: hidden;
    }

    .cv-mobile-cart-btn::after {
        content: '';
        position: absolute;
        bottom: 4px;
        right: 4px;
        width: 12px;
        height: 12px;
        background: repeating-linear-gradient(-45deg,
                transparent 0px,
                transparent 2px,
                rgba(255, 255, 255, 0.30) 2px,
                rgba(255, 255, 255, 0.30) 3.5px);
    }
}

/* =========================
   UTILITY
   ========================= */
.cv-hidden {
    display: none !important;
}

.cv-desktop-only {
    display: block;
}

.cv-desktop-grid.cv-desktop-only {
    display: grid;
}

.cv-mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .cv-desktop-only {
        display: none !important;
    }

    .cv-mobile-only {
        display: block !important;
    }

    header.cv-mobile-only {
        display: flex !important;
    }

    /* ── Condense Text Block Controls on Mobile ── */
    .cv-text-block {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
        padding: 8px 0;
        margin: 0;
        border-bottom: 1px solid #F2F2F2;
    }

    .cv-text-block:last-of-type {
        border-bottom: none;
        padding-bottom: 0;
    }

    .cv-text-block .cv-text-block-header {
        display: none;
    }

    /* Line 1: input chip — full width */
    .cv-text-block .cv-text-input-line {
        flex: 0 0 100%;
        margin: 0;
    }

    /* Line 2: font + color + dup + del — single compact row */
    .cv-text-block>.cv-fontpick {
        flex: 1 1 0;
        min-width: 0;
        margin: 0;
    }

    .cv-text-block .cv-fontpick-trigger {
        height: 36px;
    }

    /* Font picker — bottom panel on mobile, above nav bars */
    .cv-fontpick-dropdown {
        position: fixed !important;
        top: calc(var(--cv-fc-bottom, 25vh) + 8px) !important;
        left: 8px !important;
        right: 8px !important;
        bottom: 112px !important;
        width: auto !important;
        display: flex;
        flex-direction: column;
        background: #fff !important;
        border: none !important;
        border-radius: 8px 8px 0 0 !important;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.12) !important;
        z-index: 9999 !important;
    }

    .cv-fontpick-panel {
        display: flex;
        flex-direction: column;
        flex: 1 1 0%;
        min-height: 0;
        overflow: hidden;
    }

    .cv-fontpick-panel .cv-fontpick-list {
        flex: 1 1 0%;
        max-height: none;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .cv-text-block>.cv-fmt-row {
        flex: 0 0 auto;
        margin: 0;
        gap: 4px;
    }

    /* Hide "Couleur" label — icon only */
    .cv-text-block .cv-color-trigger span {
        display: none;
    }

    .cv-text-block .cv-color-trigger {
        gap: 0;
    }

    .cv-text-block .cv-edit-actions {
        flex: 0 0 auto;
        gap: 2px;
        margin: 0;
    }

    /* Icons only — hide text labels (Dupliquer, Supprimer) */
    .cv-text-block .cv-edit-action {
        font-size: 0;
        line-height: 0;
        padding: 6px;
        background: #F4F4F4;
        border-radius: 6px;
        height: 36px;
        width: 36px;
        justify-content: center;
        overflow: hidden;
    }

    .cv-text-block .cv-edit-action svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
    }

    /* Hide delete in edit-actions — already present as trash icon on the input line */
    .cv-text-block .cv-edit-actions .cv-edit-action:last-child {
        display: none;
    }
}

/* =========================
   IRO.JS COLOR PICKER
   ========================= */
.cv-cpicker {
    position: absolute;
    z-index: 100;
    background: #fff;
    border: 1px solid #D3D2D0;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
    padding: 16px;
    width: 252px;
}

/* Override iro.js internal styles for tighter integration */
.cv-cpicker .IroColorPicker {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 10px !important;
}

.cv-cpicker .IroWheel {
    cursor: crosshair;
}

.cv-cpicker .IroSlider {
    border-radius: 6px !important;
    overflow: hidden;
    margin-top: 2px !important;
}

.cv-cpicker .IroHandle circle:first-child {
    stroke-width: 2px;
    stroke: #fff;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.25));
}

/* Swatches grid */
.cv-cpicker-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #EBEBEB;
    justify-content: center;
}

.cv-cpicker-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #E5E5E5;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    padding: 0;
}

.cv-cpicker-swatch:hover {
    transform: scale(1.15);
    border-color: #1E1E1E;
}

.cv-cpicker-swatch.active {
    border-color: #1E1E1E;
    box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #1E1E1E;
}

/* White swatch needs visible border */
.cv-cpicker-swatch[style*="#FFFFFF"],
.cv-cpicker-swatch[style*="#fff"],
.cv-cpicker-swatch[style*="rgb(255"] {
    border-color: #D3D2D0;
}

/* ── Mobile: color picker overlay — centered card ── */
@media (max-width: 768px) {
    .cv-cpicker {
        position: fixed !important;
        inset: 0 !important;
        width: auto !important;
        height: auto !important;
        display: grid;
        place-items: center;
        background: rgba(0, 0, 0, 0.35) !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        z-index: 9999 !important;
    }

    .cv-cpicker-panel {
        background: #fff;
        border-radius: 14px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
        padding: 20px;
        width: 280px;
        max-width: 90vw;
    }
}

/* =========================
   ADD-TO-CART LOADER STATE
   ========================= */

/* Freeze + blur all UI except 3D and recap while cart is pending */
.cv-configurator.cv-cart-freeze .cv-sidebar-left,
.cv-configurator.cv-cart-freeze .cv-bottom-sheet,
.cv-configurator.cv-cart-freeze .cv-mobile-tab-bar,
.cv-configurator.cv-cart-freeze .cv-mobile-nav,
.cv-configurator.cv-cart-freeze .cv-mobile-view-toggle,
.cv-configurator.cv-cart-freeze #fabric_container,
.cv-configurator.cv-cart-freeze #fabric_toggle {
    pointer-events: none;
    opacity: 0.5;
    filter: blur(2px);
    transition: opacity 0.2s ease, filter 0.2s ease;
}

/* Sidebar right: freeze interactions, blur non-recap panels only */
.cv-configurator.cv-cart-freeze .cv-sidebar-right {
    pointer-events: none;
}

.cv-configurator.cv-cart-freeze .cv-sidebar-right .cv-panel:not(.cv-panel-recap) {
    opacity: 0.5;
    filter: blur(2px);
    transition: opacity 0.2s ease, filter 0.2s ease;
}

.cv-btn-valider.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
    color: transparent !important;
}

.cv-btn-valider.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cv-spin 0.6s linear infinite;
}

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

/* =========================
   CART RESULT MODAL
   ========================= */
.cv-cart-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cv-fadeIn 0.25s ease;
}

@keyframes cv-fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.cv-cart-modal {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: cv-slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Bricolage Grotesque', sans-serif;
}

@keyframes cv-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cv-cart-modal-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.cv-cart-modal-icon.success {
    background: #E8F5E9;
    color: #2E7D32;
}

.cv-cart-modal-icon.error {
    background: #FFEBEE;
    color: #C62828;
}

.cv-cart-modal h3 {
    font-size: 20px;
    font-weight: 600;
    color: #1E1E1E;
    margin: 0 0 8px;
}

.cv-cart-modal p {
    font-size: 14px;
    color: #666;
    margin: 0 0 20px;
    line-height: 1.5;
}

.cv-cart-modal-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.cv-cart-modal-btn {
    width: 100%;
    padding: 14px;
    background: #1E1E1E;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Bricolage Grotesque', sans-serif;
    transition: background 0.2s;
}

.cv-cart-modal-btn:hover {
    background: #000;
}

.cv-cart-modal-btn.secondary {
    background: transparent;
    color: #1E1E1E;
    margin-top: 8px;
    border: 1px solid #E0E0E0;
}

.cv-cart-modal-btn.secondary:hover {
    background: #f5f5f5;
}