/**
 * WooCommerce 3D Configurator - Main Styles
 */
:root {
    --w3dc-primary: #2563eb;
    --w3dc-primary-hover: #1d4ed8;
    --w3dc-secondary: #64748b;
    --w3dc-success: #22c55e;
    --w3dc-danger: #ef4444;
    --w3dc-bg: #1a1a1a;
    --w3dc-surface: #ffffff;
    --w3dc-border: #e2e8f0;
    --w3dc-text: #1e293b;
    --w3dc-text-muted: #64748b;
    --w3dc-panel-width: 380px;
    --w3dc-header-height: 60px;
    --w3dc-radius: 8px;
    --w3dc-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

body.w3dc-configurator-page {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--w3dc-text);
    background: var(--w3dc-bg);
    overflow: hidden;
}

#w3dc-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Header */
.w3dc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--w3dc-header-height);
    padding: 0 16px;
    background: var(--w3dc-surface);
    border-bottom: 1px solid var(--w3dc-border);
    z-index: 100;
}

.w3dc-header-left,
.w3dc-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.w3dc-header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.w3dc-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--w3dc-radius);
    color: var(--w3dc-text);
    text-decoration: none;
    transition: background 0.2s;
}

.w3dc-back-btn:hover {
    background: #f1f5f9;
}

.w3dc-product-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

/* View Controls */
.w3dc-view-controls {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--w3dc-radius);
}

.w3dc-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: var(--w3dc-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.w3dc-view-btn:hover {
    color: var(--w3dc-text);
}

.w3dc-view-btn.active {
    background: var(--w3dc-surface);
    color: var(--w3dc-primary);
    box-shadow: var(--w3dc-shadow);
}

/* Buttons */
.w3dc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--w3dc-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.w3dc-btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    color: var(--w3dc-text-muted);
}

.w3dc-btn-icon:hover {
    background: #f1f5f9;
    color: var(--w3dc-text);
}

.w3dc-btn-primary {
    background: var(--w3dc-primary);
    color: white;
}

.w3dc-btn-primary:hover {
    background: var(--w3dc-primary-hover);
}

.w3dc-btn-large {
    padding: 14px 24px;
    font-size: 15px;
    width: 100%;
}

/* Main Layout */
.w3dc-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Canvas Container */
.w3dc-canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#w3dc-canvas {
    width: 100%;
    height: 100%;
}

#w3dc-canvas canvas {
    display: block;
}

/* Loading */
.w3dc-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(26, 26, 26, 0.9);
    color: white;
    z-index: 50;
}

.w3dc-loading.hidden {
    display: none;
}

.w3dc-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: var(--w3dc-primary);
    border-radius: 50%;
    animation: w3dc-spin 0.8s linear infinite;
}

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

.w3dc-loading p {
    margin-top: 16px;
    font-size: 14px;
    color: rgba(255,255,255,0.7);
}

/* Controls Hint */
.w3dc-controls-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 24px;
    padding: 10px 20px;
    background: rgba(0,0,0,0.6);
    border-radius: 20px;
    color: white;
    font-size: 12px;
}

.w3dc-controls-hint span {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.8;
}

/* Panel */
.w3dc-panel {
    width: var(--w3dc-panel-width);
    background: var(--w3dc-surface);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--w3dc-border);
    z-index: 50;
}

.w3dc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--w3dc-border);
}

.w3dc-panel-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.w3dc-panel-toggle {
    display: none;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
}

.w3dc-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Parts Accordion */
.w3dc-part-section {
    border-bottom: 1px solid var(--w3dc-border);
}

.w3dc-part-header {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 16px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.w3dc-part-header:hover {
    background: #f8fafc;
}

.w3dc-part-name {
    flex: 1;
    font-weight: 500;
}

.w3dc-part-selection {
    font-size: 12px;
    color: var(--w3dc-text-muted);
    margin-right: 8px;
}

.w3dc-part-arrow {
    transition: transform 0.2s;
}

.w3dc-part-section.active .w3dc-part-arrow {
    transform: rotate(180deg);
}

.w3dc-part-content {
    display: none;
    padding: 0 20px 20px;
}

.w3dc-part-section.active .w3dc-part-content {
    display: block;
}

/* Option Groups */
.w3dc-option-group {
    margin-bottom: 20px;
}

.w3dc-option-group:last-child {
    margin-bottom: 0;
}

.w3dc-option-group h4 {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--w3dc-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Texture Grid */
.w3dc-texture-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.w3dc-texture-btn {
    position: relative;
    aspect-ratio: 1;
    border: 2px solid var(--w3dc-border);
    border-radius: var(--w3dc-radius);
    background: #f8fafc;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s;
    padding: 0;
}

.w3dc-texture-btn:hover {
    border-color: var(--w3dc-primary);
}

.w3dc-texture-btn.active {
    border-color: var(--w3dc-primary);
    box-shadow: 0 0 0 2px var(--w3dc-primary);
}

.w3dc-texture-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.w3dc-texture-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 10px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.w3dc-texture-placeholder {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e2e8f0 25%, #cbd5e1 50%, #e2e8f0 75%);
}

.w3dc-option-price {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 2px 6px;
    background: var(--w3dc-primary);
    color: white;
    font-size: 10px;
    border-radius: 4px;
}

/* Color Grid */
.w3dc-color-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.w3dc-color-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border: 2px solid var(--w3dc-border);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.w3dc-color-btn:hover {
    transform: scale(1.1);
}

.w3dc-color-btn.active {
    border-color: var(--w3dc-text);
    box-shadow: 0 0 0 2px var(--w3dc-text);
}

.w3dc-custom-color {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--w3dc-border);
}

.w3dc-custom-color label {
    font-size: 12px;
    color: var(--w3dc-text-muted);
}

.w3dc-color-picker {
    width: 60px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--w3dc-border);
    border-radius: 4px;
    cursor: pointer;
}

/* Upload Zone */
.w3dc-upload-zone {
    border: 2px dashed var(--w3dc-border);
    border-radius: var(--w3dc-radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.w3dc-upload-zone:hover,
.w3dc-upload-zone.dragover {
    border-color: var(--w3dc-primary);
    background: rgba(37, 99, 235, 0.05);
}

.w3dc-upload-zone svg {
    color: var(--w3dc-text-muted);
    margin-bottom: 8px;
}

.w3dc-upload-zone p {
    margin: 0;
    font-size: 12px;
    color: var(--w3dc-text-muted);
}

.w3dc-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.w3dc-upload-price {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    background: var(--w3dc-primary);
    color: white;
    font-size: 12px;
    border-radius: 12px;
}

.w3dc-upload-preview {
    position: relative;
    margin-top: 12px;
}

.w3dc-upload-preview img {
    max-width: 100%;
    border-radius: var(--w3dc-radius);
    border: 1px solid var(--w3dc-border);
}

.w3dc-remove-upload {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: var(--w3dc-danger);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

/* Panel Footer */
.w3dc-panel-footer {
    padding: 20px;
    border-top: 1px solid var(--w3dc-border);
    background: #f8fafc;
}

.w3dc-price-breakdown {
    margin-bottom: 16px;
}

.w3dc-price-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.w3dc-config-price {
    color: var(--w3dc-primary);
}

.w3dc-total {
    padding-top: 12px;
    margin-top: 6px;
    border-top: 1px solid var(--w3dc-border);
    font-size: 16px;
    font-weight: 600;
}

.w3dc-quantity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.w3dc-quantity label {
    font-size: 13px;
    color: var(--w3dc-text-muted);
}

.w3dc-qty-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--w3dc-border);
    border-radius: var(--w3dc-radius);
    overflow: hidden;
}

.w3dc-qty-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
}

.w3dc-qty-btn:hover {
    background: #f1f5f9;
}

.w3dc-qty-control input {
    width: 50px;
    height: 36px;
    border: none;
    border-left: 1px solid var(--w3dc-border);
    border-right: 1px solid var(--w3dc-border);
    text-align: center;
    font-size: 14px;
    -moz-appearance: textfield;
}

.w3dc-qty-control input::-webkit-outer-spin-button,
.w3dc-qty-control input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

/* Toast */
.w3dc-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 28px;
    background: var(--w3dc-text);
    color: white;
    border-radius: var(--w3dc-radius);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.w3dc-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.w3dc-toast.success {
    background: var(--w3dc-success);
}

.w3dc-toast.error {
    background: var(--w3dc-danger);
}

/* Product Page Button */
.w3dc-configure-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    background: var(--w3dc-primary) !important;
    color: white !important;
    margin-left: 10px;
}

.w3dc-configure-btn:hover {
    background: var(--w3dc-primary-hover) !important;
}

/* Cart Badge */
.w3dc-config-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--w3dc-primary);
    color: white;
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
}

.w3dc-color-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
    margin-right: 6px;
    vertical-align: middle;
}

/* Mobile Responsive */
@media (max-width: 900px) {
    .w3dc-header-center {
        display: none;
    }
    
    .w3dc-panel {
        position: fixed;
        right: 0;
        top: var(--w3dc-header-height);
        bottom: 0;
        width: 100%;
        max-width: 380px;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 200;
    }
    
    .w3dc-panel.open {
        transform: translateX(0);
    }
    
    .w3dc-panel-toggle {
        display: block;
    }
    
    .w3dc-controls-hint {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 500px) {
    .w3dc-product-title {
        display: none;
    }
    
    .w3dc-texture-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
