/* ===================================================================
   PRODUCT CUSTOMIZER — Premium Swatch Selector Styling
   Wood / Color / Fabric interactive selector with instant preview
   =================================================================== */

/* ── Container ────────────────────────────────────────────────────── */
.product-customizer {
    margin: 24px 0;
    padding: 20px;
    background: linear-gradient(145deg, #faf8f5, #f5f1ec);
    border-radius: 14px;
    border: 1px solid rgba(201, 169, 110, 0.12);
    position: relative;
}

.customizer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    font-weight: 600;
    color: #2a2520;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(201, 169, 110, 0.15);
}
.customizer-header i {
    color: var(--gold, #c9a96e);
    font-size: 18px;
}

/* ── Group (each option type) ─────────────────────────────────────── */
.customizer-group {
    margin-bottom: 18px;
}
.customizer-group:last-of-type {
    margin-bottom: 12px;
}

.customizer-group-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 12.5px;
    font-weight: 600;
    color: #5a5048;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
.customizer-group-label i {
    color: var(--gold, #c9a96e);
    font-size: 13px;
    width: 18px;
    text-align: center;
}
.customizer-selected-name {
    margin-left: auto;
    font-weight: 500;
    color: var(--gold, #c9a96e);
    text-transform: none;
    letter-spacing: 0;
    font-size: 12px;
}

/* ── Swatches container ───────────────────────────────────────────── */
.customizer-swatches {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Individual swatch button ─────────────────────────────────────── */
.customizer-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 6px;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.23, 1, 0.32, 1);
    position: relative;
    min-width: 56px;
}
.customizer-swatch:hover {
    border-color: rgba(201, 169, 110, 0.3);
    background: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
}
.customizer-swatch.active {
    border-color: var(--gold, #c9a96e);
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 12px rgba(201, 169, 110, 0.2);
}

/* Check mark on active swatch */
.customizer-swatch.active .swatch-circle::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    animation: customizerCheckIn 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}
/* For light swatches, use dark check */
.customizer-swatch.active .swatch-circle[style*="FFFFF"],
.customizer-swatch.active .swatch-circle[style*="F5F0"],
.customizer-swatch.active .swatch-circle[style*="F5F5"],
.customizer-swatch.active .swatch-circle[style*="E8D"],
.customizer-swatch.active .swatch-circle[style*="E8E0"] {
    color: #2a2520;
    text-shadow: none;
}

@keyframes customizerCheckIn {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Selection pulse animation */
.customizer-swatch.just-selected .swatch-circle {
    animation: swatchPulse 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}
@keyframes swatchPulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ── Swatch circle ────────────────────────────────────────────────── */
.swatch-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: all 0.25s cubic-bezier(0.23, 1, 0.32, 1);
    flex-shrink: 0;
}

/* Wood swatches — slightly larger with grain hint */
.swatch-wood .swatch-circle {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Fabric swatches — rounded square */
.swatch-fabric .swatch-circle {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* ── Swatch name ──────────────────────────────────────────────────── */
.swatch-name {
    font-size: 9.5px;
    color: #8a7e74;
    text-align: center;
    line-height: 1.2;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.2s;
}
.customizer-swatch.active .swatch-name {
    color: #2a2520;
    font-weight: 600;
}
.customizer-swatch:hover .swatch-name {
    color: #5a5048;
}

/* ── Note at bottom ───────────────────────────────────────────────── */
.customizer-note {
    font-size: 10.5px;
    color: #a09488;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(201, 169, 110, 0.1);
}
.customizer-note i {
    color: var(--gold, #c9a96e);
    font-size: 11px;
    flex-shrink: 0;
}

/* ── Hide old overlay — canvas handles the image now ──────────────── */
#customizerOverlay,
.variant-tint-overlay {
    display: none !important;
}

/* Active preview label on gallery */
.gallery-main {
    position: relative;
}
.gallery-preview-badge {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(42, 37, 32, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--gold-light, #e8d5a3);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 5;
    opacity: 0;
    transform: translateY(6px);
    transition: all 0.3s ease;
    pointer-events: none;
}
.gallery-preview-badge.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Tooltip for fabric texture ───────────────────────────────────── */
.customizer-swatch[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #2a2520;
    color: #fff;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 10px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.customizer-swatch[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #2a2520;
    z-index: 10;
    pointer-events: none;
}

/* ── Reset button ─────────────────────────────────────────────────── */
.customizer-reset-btn {
    background: none;
    border: 1px solid rgba(201, 169, 110, 0.3);
    color: #8a7e74;
    font-size: 11px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    font-family: 'Poppins', sans-serif;
}
.customizer-reset-btn:hover {
    border-color: var(--gold, #c9a96e);
    color: var(--gold, #c9a96e);
    background: rgba(201, 169, 110, 0.06);
}
.customizer-reset-btn i {
    font-size: 10px;
}

/* ── Image transition for canvas swap ─────────────────────────────── */
#mainImage {
    transition: opacity 0.2s ease;
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .product-customizer {
        padding: 16px;
        margin: 18px 0;
    }

    .customizer-header {
        font-size: 15px;
        margin-bottom: 16px;
    }

    .customizer-swatches {
        gap: 6px;
    }

    .customizer-swatch {
        min-width: 48px;
        padding: 4px;
    }

    .swatch-circle {
        width: 36px;
        height: 36px;
    }
    .swatch-wood .swatch-circle,
    .swatch-fabric .swatch-circle {
        width: 38px;
        height: 38px;
    }

    .swatch-name {
        font-size: 8.5px;
        max-width: 48px;
    }

    /* Tooltip not practical on mobile — disable */
    .customizer-swatch[data-tooltip]:hover::after,
    .customizer-swatch[data-tooltip]:hover::before {
        display: none;
    }
}

@media (max-width: 480px) {
    .customizer-swatches {
        gap: 4px;
    }

    .customizer-swatch {
        min-width: 42px;
        padding: 3px;
    }

    .swatch-circle {
        width: 32px;
        height: 32px;
    }
    .swatch-wood .swatch-circle,
    .swatch-fabric .swatch-circle {
        width: 34px;
        height: 34px;
    }
}

/* ── Reduced motion ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .customizer-swatch,
    .swatch-circle,
    #customizerOverlay,
    .gallery-preview-badge {
        transition: none;
    }
    .customizer-swatch.just-selected .swatch-circle {
        animation: none;
    }
    .customizer-swatch.active .swatch-circle::after {
        animation: none;
    }
}

/* FIX: Processing state indicator during pixel recoloring */
.customizer-processing {
    position: relative;
    pointer-events: none;
}
.customizer-processing::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.4);
    z-index: 2;
    animation: customizer-pulse 1s ease-in-out infinite;
}
@keyframes customizer-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* FIX: Disabled swatch state during processing */
.customizer-swatch[disabled] {
    opacity: 0.5;
    cursor: wait;
    pointer-events: none;
}
