/* ═══════════════════════════════════════════════════════════
   WP 3D Configurateur — CSS v4
   ═══════════════════════════════════════════════════════════ */

/* Reset dans le scope */
.wp3dc, .wp3dc * { box-sizing: border-box; }
.wp3dc button { font-family: inherit; }

/* Conteneur principal */
.wp3dc {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    color: #1e293b;
    margin: 24px 0 32px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    clear: both;
    display: block;
    background: #fff;
}

/* Spinner */
.wp3dc-loading {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 60px; gap: 14px; color: #64748b;
}
.wp3dc-spinner {
    width: 40px; height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: wp3dc-spin .8s linear infinite;
}
@keyframes wp3dc-spin { to { transform: rotate(360deg); } }

/* Barre prix */
.wp3dc-price-bar {
    display: flex; align-items: center; gap: 16px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
    color: #fff;
    flex-wrap: wrap;
}
.wp3dc-price-base { font-size: 11px; opacity: .75; line-height: 1.4; }
.wp3dc-price-base strong { display: block; font-size: 14px; opacity: 1; }
.wp3dc-price-extras { flex: 1; display: flex; gap: 6px; flex-wrap: wrap; }
.wp3dc-price-extra-item {
    font-size: 10px; font-weight: 600;
    background: rgba(255,255,255,.18);
    padding: 2px 8px; border-radius: 20px;
}
.wp3dc-price-total { font-size: 11px; opacity: .75; line-height: 1.4; text-align: right; }
.wp3dc-price-total strong { display: block; font-size: 20px; font-weight: 800; opacity: 1; }

/* Layout */
.wp3dc-layout { display: flex; width: 100%; min-height: 520px; }

/* ═══ SIDEBAR ═══ */
.wp3dc-sidebar {
    width: 290px;
    min-width: 260px;
    max-width: 290px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    max-height: 700px;
    flex-shrink: 0;
}

/* Zone ciblée */
.wp3dc-zone-selector { display: flex; flex-wrap: wrap; gap: 5px; }
.wp3dc-zone-btn {
    padding: 4px 10px; font-size: 11px; font-weight: 600;
    border: 1.5px solid #dde3ed; border-radius: 20px;
    background: #fff; cursor: pointer; color: #64748b;
    transition: all .15s;
}
.wp3dc-zone-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }

/* ─── ACCORDÉONS ─── */
.wp3dc-acc { position: relative; }

.wp3dc .wp3dc-acc-header {
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    background: #f8fafc !important;
    border: none !important;
    border-top: 1px solid #e8edf5 !important;
    cursor: pointer !important;
    outline: none !important;
    text-align: left !important;
    transition: background .15s !important;
    position: relative !important;
    overflow: hidden !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
}
.wp3dc .wp3dc-acc:first-child .wp3dc-acc-header { border-top: none !important; }

/* Bande colorée par rubrique */
.wp3dc .wp3dc-acc-header::before {
    content: '' !important;
    position: absolute !important;
    left: 0 !important; top: 0 !important; bottom: 0 !important;
    width: 4px !important;
    background: #e2e8f0 !important;
    transition: background .2s !important;
}
#block-color   .wp3dc-acc-header::before { background: #f59e0b !important; }
#block-image   .wp3dc-acc-header::before { background: #8b5cf6 !important; }
#block-text    .wp3dc-acc-header::before { background: #10b981 !important; }
#block-library .wp3dc-acc-header::before { background: #f43f5e !important; }

.wp3dc-acc-header:hover { background: rgba(37,99,235,.04); }

/* Contenu interne du header */
.wp3dc .wp3dc-acc-inner {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 13px 14px 13px 18px !important;
    flex: 1 !important;
    min-width: 0 !important;
    width: 100% !important;
}

.wp3dc .wp3dc-acc-icon {
    font-size: 20px !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #fff !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 4px rgba(0,0,0,.12) !important;
    flex-shrink: 0 !important;
}
.wp3dc .wp3dc-acc-title {
    flex: 1 !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: .06em !important;
    color: #374151 !important;
    transition: color .15s !important;
    line-height: 1.2 !important;
}
.wp3dc .wp3dc-acc-arrow {
    font-size: 14px !important;
    color: #94a3b8 !important;
    transition: transform .25s ease, color .2s !important;
    margin-right: 4px !important;
    flex-shrink: 0 !important;
}

/* État ouvert */
.wp3dc-acc-header[data-open="1"] .wp3dc-acc-arrow {
    transform: rotate(180deg);
    color: #2563eb;
}
.wp3dc-acc-header[data-open="1"] .wp3dc-acc-title { color: #2563eb; }
.wp3dc-acc-header[data-open="1"] { background: rgba(37,99,235,.05); }
.wp3dc-acc-header[data-open="1"] .wp3dc-acc-icon {
    box-shadow: 0 0 0 2px rgba(37,99,235,.25);
}

/* Corps accordéon */
.wp3dc .wp3dc-acc-body {
    padding: 14px !important;
    background: #fff !important;
    border-top: 1px solid #e0f2fe !important;
}

/* Swatches */
.wp3dc-model-list { display: flex; flex-wrap: wrap; gap: 8px; }
.wp3dc-model-btn {
    width: 56px; height: 56px;
    border: 2px solid #e2e8f0; border-radius: 10px;
    background: #f8fafc; cursor: pointer; overflow: hidden;
    padding: 0; transition: all .15s;
    display: flex; align-items: center; justify-content: center;
}
.wp3dc-model-btn img { width: 100%; height: 100%; object-fit: cover; }
.wp3dc-model-btn span { font-size: 11px; font-weight: 700; color: #64748b; }
.wp3dc-model-btn.active {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.2);
}

/* Color swatches */
.wp3dc-swatches { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 4px; }
.wp3dc-swatch {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    outline: 2px solid rgba(0,0,0,.08);
    cursor: pointer; overflow: hidden; padding: 0;
    transition: transform .15s, box-shadow .15s;
    flex-shrink: 0;
}
.wp3dc-swatch:hover { transform: scale(1.15); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.wp3dc-swatch.active {
    outline: 2px solid #2563eb;
    box-shadow: 0 0 0 4px rgba(37,99,235,.2);
    transform: scale(1.1);
}
.wp3dc-swatch img { width: 100%; height: 100%; object-fit: cover; }

/* Dropzone */
.wp3dc-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    background: #f8fafc;
    transition: all .2s;
}
.wp3dc-dropzone:hover, .wp3dc-dropzone.over {
    border-color: #2563eb;
    background: #eff6ff;
    transform: scale(1.01);
}

/* Mode texte */
.wp3dc-mode-tabs {
    display: flex;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
    background: #f8fafc;
}
.wp3dc-mode-tab {
    flex: 1; padding: 6px; font-size: 11px; font-weight: 700;
    background: none; border: none; cursor: pointer;
    color: #64748b; transition: all .15s;
}
.wp3dc-mode-tab.active {
    background: #2563eb;
    color: #fff;
    border-radius: 6px;
    margin: 2px;
}

/* Position texte */
.wp3dc-pos-btn {
    width: 28px; height: 28px;
    border: 1.5px solid #e2e8f0; border-radius: 6px;
    background: #fff; cursor: pointer;
    transition: all .15s; font-size: 11px; padding: 0;
}
.wp3dc-pos-btn:hover { background: #eff6ff; border-color: #2563eb; }
.wp3dc-pos-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }

/* Extrude hint */
.wp3dc-extrude-hint {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 11px; color: #1e40af;
    margin-top: 8px; display: none;
}
.wp3dc-extrude-hint.visible { display: block; }

/* Bibliothèque */
.wp3dc-theme-tabs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.wp3dc-theme-btn {
    display: flex; align-items: center; gap: 4px;
    padding: 4px 10px; font-size: 11px; font-weight: 700;
    border: 1.5px solid #e2e8f0; border-radius: 20px;
    background: #fff; cursor: pointer; color: #64748b;
    transition: all .15s;
}
.wp3dc-theme-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.wp3dc-lib-search {
    width: 100%; border: 1.5px solid #e2e8f0; border-radius: 8px;
    padding: 6px 10px; font-size: 12px; margin: 4px 0 8px;
    transition: border-color .15s;
}
.wp3dc-lib-search:focus { outline: none; border-color: #2563eb; }
.wp3dc-lib-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 6px; max-height: 200px; overflow-y: auto;
}
.wp3dc-lib-item {
    border: 2px solid #f1f5f9; border-radius: 8px;
    background: #fff; cursor: pointer; overflow: hidden;
    padding: 0; display: flex; flex-direction: column;
    transition: all .15s;
}
.wp3dc-lib-item:hover { border-color: #2563eb; transform: scale(1.03); }
.wp3dc-lib-item img {
    width: 100%; aspect-ratio: 1; object-fit: contain;
    display: block; background: #f8fafc;
}
.wp3dc-lib-item span {
    font-size: 9px; color: #64748b; padding: 2px 4px;
    display: block; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; text-align: center;
}

/* Calques */
.wp3dc-layer-item {
    display: flex; align-items: center; gap: 7px;
    padding: 5px 7px; border: 1px solid #e2e8f0;
    border-radius: 7px; margin-bottom: 4px; background: #fff;
}
.wp3dc-layer-item img { width: 30px; height: 30px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.wp3dc-layer-name { flex: 1; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wp3dc-layer-del { background: none; border: none; cursor: pointer; color: #dc2626; font-size: 14px; padding: 0; }

/* UV Positioner section */
#wp3dc-uv-section {
    border-top: none;
    margin-top: 2px;
}
.wp3dc-uv-header-box {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: #fff;
}
.wp3dc-uv-header-box h4 { margin: 0; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.wp3dc-uv-header-box small { font-size: 10px; opacity: .75; display: block; margin-top: 1px; }
#wp3dc-uv-reset {
    background: rgba(255,255,255,.2); color: #fff; border: 1px solid rgba(255,255,255,.4);
    border-radius: 6px; padding: 4px 10px; font-size: 11px; cursor: pointer;
    font-weight: 700; transition: background .15s;
}
#wp3dc-uv-reset:hover { background: rgba(255,255,255,.35); }
.wp3dc-uv-canvas-wrap {
    padding: 10px 14px 12px; background: #f0f4f8;
}
#wp3dc-uv-canvas {
    display: block;
    width: 100% !important;
    max-width: 240px;
    height: auto;
    aspect-ratio: 1;
    margin: 0 auto;
    border: 2px solid #bfdbfe;
    border-radius: 8px;
    cursor: crosshair;
    touch-action: none;
    background: #e8edf5;
    box-shadow: 0 2px 8px rgba(37,99,235,.15);
}

/* ═══ VIEWER ═══ */
.wp3dc-viewer-area {
    flex: 1; display: flex; flex-direction: column; min-width: 0;
}
.wp3dc-canvas-wrap {
    /* Height fixe — PAS flex:1 qui cause scrollbar sur Edge/Firefox */
    position: relative;
    height: 460px;
    background: radial-gradient(ellipse at 55% 40%, #d8e8f8, #b8cce0);
    overflow: hidden;
    flex-shrink: 0;
}
#wp3dc-canvas {
    /* Canvas positionné en absolute pour ne pas influencer le layout */
    position: absolute;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
}
.wp3dc-canvas-wrap.loading::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    margin: -20px 0 0 -20px; width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wp3dc-spin .7s linear infinite; z-index: 11;
}
.wp3dc-toolbar {
    position: absolute; top: 12px; right: 12px;
    display: flex; flex-direction: column; gap: 6px; z-index: 5;
}
.wp3dc-tbtn {
    width: 36px; height: 36px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,.3);
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(4px);
    cursor: pointer; display: flex; align-items: center;
    justify-content: center; font-size: 14px;
    transition: all .15s; color: #374151;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
}
.wp3dc-tbtn:hover { background: #2563eb; color: #fff; border-color: #2563eb; transform: scale(1.05); }
.wp3dc-tbtn.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* Actions */
.wp3dc-actions {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; background: #fff;
    border-top: 1px solid #e2e8f0; gap: 8px; flex-wrap: wrap;
}
.wp3dc-saved-msg { font-size: 12px; font-weight: 600; color: #16a34a; }
.wp3dc-cart-wrap {
    padding: 12px 16px; background: #fff;
    border-top: 2px solid #e2e8f0;
}

/* Boutons */
.wp3dc-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 16px; border-radius: 8px; font-size: 12px; font-weight: 700;
    cursor: pointer; border: 1.5px solid transparent; transition: all .15s;
    font-family: inherit;
}
.wp3dc-btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.wp3dc-btn-primary:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.wp3dc-btn-primary:disabled { background: #94a3b8; border-color: #94a3b8; cursor: not-allowed; transform: none; box-shadow: none; }
.wp3dc-btn-outline { background: #fff; color: #374151; border-color: #e2e8f0; }
.wp3dc-btn-outline:hover { border-color: #2563eb; color: #2563eb; }
.wp3dc-btn-cart {
    width: 100%; padding: 14px; font-size: 15px; font-weight: 700;
    background: linear-gradient(135deg, #15803d, #16a34a);
    color: #fff; border: none; border-radius: 10px; cursor: pointer;
    font-family: inherit; transition: all .2s;
    box-shadow: 0 4px 14px rgba(22,163,74,.3);
}
.wp3dc-btn-cart:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(22,163,74,.4); }
.wp3dc-btn-cart:disabled { background: #94a3b8; cursor: not-allowed; transform: none; box-shadow: none; }
.wp3dc-btn-small {
    padding: 3px 8px; font-size: 11px; font-weight: 600;
    border: 1px solid #e2e8f0; border-radius: 5px;
    background: #fff; cursor: pointer; font-family: inherit;
    transition: all .15s;
}
.wp3dc-btn-small:hover { border-color: #dc2626; color: #dc2626; }
.wp3dc-btn-danger { color: #dc2626; border-color: #fca5a5; }
.wp3dc-btn-danger:hover { background: #fef2f2; }

/* Responsive */
@media (max-width: 680px) {
    .wp3dc-layout { flex-direction: column; }
    .wp3dc-sidebar { width: 100%; max-width: 100%; max-height: 45vh; border-right: none; border-bottom: 1px solid #e2e8f0; }
    .wp3dc-canvas-wrap { min-height: 280px; }
}
