/* ══════════════════════════════════════════
   TRIGGER BUTTON — hiện trên product page
══════════════════════════════════════════ */
#wcbd-open-modal {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 13px 28px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin: 12px 0;
    letter-spacing: 0.3px;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    width: 100%;
    justify-content: center;
}
#wcbd-open-modal:hover {
    background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
#wcbd-open-modal svg { flex-shrink: 0; }

/* ══════════════════════════════════════════
   MODAL OVERLAY
══════════════════════════════════════════ */
#wcbd-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    animation: wcbdFadeIn 0.2s ease;
}
#wcbd-modal.active { display: flex; }

@keyframes wcbdFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ══════════════════════════════════════════
   MODAL INNER
══════════════════════════════════════════ */
#wcbd-modal-inner {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    animation: wcbdSlideUp 0.25s ease;
}

@keyframes wcbdSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Header bar ── */
#wcbd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a1a2e;
    color: #fff;
    padding: 0 20px;
    height: 56px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 10;
}
#wcbd-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
#wcbd-header-left span { opacity: 0.6; font-weight: 400; font-size: 13px; }
#wcbd-header-right { display: flex; align-items: center; gap: 8px; }

#wcbd-btn-close {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}
#wcbd-btn-close:hover { background: rgba(255,255,255,0.2); }

#wcbd-btn-save-order {
    background: linear-gradient(135deg, #e53e3e, #c53030);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
#wcbd-btn-save-order:hover { background: linear-gradient(135deg, #c53030, #9b2c2c); }
#wcbd-btn-save-order:disabled { background: #718096; cursor: not-allowed; }

/* ── Body: sidebar + canvas ── */
#wcbd-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── LEFT SIDEBAR — tools ── */
#wcbd-sidebar {
    width: 72px;
    background: #1e1e2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 4px;
    flex-shrink: 0;
    overflow-y: auto;
}

.wcbd-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #a0aec0;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 10px 6px;
    width: 60px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 10px;
    line-height: 1.2;
    text-align: center;
}
.wcbd-tool-btn:hover, .wcbd-tool-btn.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.wcbd-tool-btn svg { width: 22px; height: 22px; }

.wcbd-tool-divider {
    width: 40px;
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 4px 0;
}

/* ── RIGHT PANEL — properties ── */
#wcbd-panel {
    width: 280px;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.wcbd-panel-section {
    border-bottom: 1px solid #f0f0f0;
    padding: 16px;
}
.wcbd-panel-section h4 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #718096;
    margin: 0 0 12px;
}

/* Panel inputs */
.wcbd-panel-section input[type="text"],
.wcbd-panel-section textarea,
.wcbd-panel-section select {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    color: #2d3748;
    background: #f7fafc;
    box-sizing: border-box;
    transition: border 0.15s;
    margin-bottom: 8px;
}
.wcbd-panel-section input[type="text"]:focus,
.wcbd-panel-section textarea:focus,
.wcbd-panel-section select:focus {
    outline: none;
    border-color: #4299e1;
    background: #fff;
}

.wcbd-panel-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.wcbd-panel-row label {
    font-size: 12px;
    color: #718096;
    width: 80px;
    flex-shrink: 0;
}
.wcbd-panel-row input[type="color"] {
    width: 36px;
    height: 32px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 2px;
    cursor: pointer;
    background: #fff;
}
.wcbd-panel-row select {
    flex: 1;
    margin: 0;
}
.wcbd-panel-row input[type="range"] {
    flex: 1;
}

/* Color swatches */
.wcbd-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.wcbd-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
}
.wcbd-swatch:hover { transform: scale(1.15); }
.wcbd-swatch.selected { border-color: #4299e1; }

/* Upload area */
.wcbd-upload-area {
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #718096;
    font-size: 13px;
}
.wcbd-upload-area:hover {
    border-color: #4299e1;
    background: #ebf8ff;
    color: #2b6cb0;
}
.wcbd-upload-area input { display: none; }

/* Action buttons in panel */
.wcbd-panel-btn {
    width: 100%;
    border: none;
    border-radius: 6px;
    padding: 9px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 6px;
}
.wcbd-panel-btn.primary {
    background: #4299e1;
    color: #fff;
}
.wcbd-panel-btn.primary:hover { background: #3182ce; }
.wcbd-panel-btn.danger {
    background: #fff0f0;
    color: #e53e3e;
    border: 1px solid #fed7d7;
}
.wcbd-panel-btn.danger:hover { background: #fff5f5; }
.wcbd-panel-btn.ghost {
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}
.wcbd-panel-btn.ghost:hover { background: #edf2f7; }

/* ── CANVAS AREA ── */
#wcbd-canvas-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 50% 50%, #e8e8e8 0%, #d8d8d8 100%);
    background-size: 20px 20px;
    background-image:
        linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);
    overflow: hidden;
    position: relative;
}

#wcbd-canvas-wrap {
    position: relative;
    box-shadow: 0 8px 40px rgba(0,0,0,0.25);
    border-radius: 4px;
    overflow: hidden;
}

#wcbd-canvas-wrap canvas {
    display: block;
}

/* Zoom controls */
#wcbd-zoom-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 0;
    overflow: hidden;
}
.wcbd-zoom-btn {
    background: transparent;
    border: none;
    padding: 8px 14px;
    font-size: 16px;
    cursor: pointer;
    color: #4a5568;
    transition: background 0.15s;
}
.wcbd-zoom-btn:hover { background: #f0f0f0; }
#wcbd-zoom-label {
    font-size: 12px;
    font-weight: 600;
    color: #4a5568;
    padding: 0 10px;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    min-width: 48px;
    text-align: center;
}

/* ── STATUS bar ── */
#wcbd-status-bar {
    background: #1a1a2e;
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    padding: 4px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}
#wcbd-status-msg { color: #68d391; font-weight: 600; }

/* ── PANEL TABS ── */
.wcbd-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: #f7fafc;
}
.wcbd-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #718096;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.wcbd-tab.active {
    color: #4299e1;
    border-bottom-color: #4299e1;
    background: #fff;
}
.wcbd-tab-content { display: none; }
.wcbd-tab-content.active { display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    #wcbd-panel { display: none; }
    #wcbd-sidebar { width: 56px; }
    .wcbd-tool-btn { width: 48px; font-size: 9px; }
}