/* =====================================================
   PRODUCT PAGE — Variant Selector Styles
   ===================================================== */

/* Variant container */
.pd-variants {
    margin: 18px 0;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.pd-variant-group {
    margin-bottom: 16px;
}

.pd-variant-group:last-of-type {
    margin-bottom: 12px;
}

/* Label row */
.pd-variant-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.pd-variant-label > span:first-child {
    color: #64748b;
    font-weight: 500;
}

.pd-variant-label > strong {
    color: #0f172a;
    font-weight: 700;
    padding: 3px 10px;
    background: #eef2ff;
    color: #4f46e5;
    border-radius: 6px;
    font-size: 13.5px;
}

.pd-variant-hint {
    color: #94a3b8;
    font-size: 12px;
}

/* Chip container */
.pd-variant-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------- Color chips ---------- */
.pd-color-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 52px;
    padding: 4px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fff;
    font-family: inherit;
    outline: none;
    overflow: hidden;
}

/* Colored swatch inside */
.pd-color-chip::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 8px;
    background: inherit;
    /* Uses inline style background from PHP */
}

/* Fallback: show color name if no background */
.pd-color-chip:not([style*="background"])::before {
    background: linear-gradient(135deg, #a855f7, #ec4899);
}

/* Border for white/light colors */
.pd-color-chip[style*="ffffff"]::after,
.pd-color-chip[style*="white"]::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    pointer-events: none;
}

/* Color name label */
.pd-color-name {
    position: relative;
    z-index: 2;
    font-size: 10.5px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
    opacity: 0;
    transition: opacity 0.2s;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

.pd-color-chip:hover .pd-color-name,
.pd-color-chip.is-active .pd-color-name {
    opacity: 1;
}

.pd-color-chip:hover {
    transform: translateY(-3px) scale(1.03);
    border-color: #a855f7;
    box-shadow: 0 8px 20px rgba(168, 85, 247, 0.25);
}

.pd-color-chip.is-active {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15), 0 8px 24px rgba(79, 70, 229, 0.3);
    transform: scale(1.05);
}

/* Checkmark on active */
.pd-color-chip.is-active::after {
    content: '✓';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    background: #4f46e5;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    z-index: 3;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ---------- Size chips ---------- */
.pd-size-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 48px;
    padding: 0 16px;
    border: 2px solid #e2e8f0;
    background: #fff;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    outline: none;
    position: relative;
}

.pd-size-chip:hover {
    border-color: #4f46e5;
    background: #eef2ff;
    color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.15);
}

.pd-size-chip.is-active {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 22px rgba(79, 70, 229, 0.4);
    transform: scale(1.05);
}

.pd-size-chip.is-active::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #10b981;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

/* Micro-pop animation */
.pd-color-chip.pd-pop,
.pd-size-chip.pd-pop {
    animation: pdPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pdPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1.05); }
}

/* ---------- Summary bar ---------- */
.pd-variant-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    font-size: 13px;
    color: #64748b;
    margin-top: 12px;
    transition: all 0.2s;
}

.pd-variant-summary svg {
    color: #94a3b8;
    transition: color 0.2s;
    flex-shrink: 0;
}

.pd-variant-summary strong {
    color: #0f172a;
    font-weight: 700;
}

.pd-variant-summary.is-active {
    border-style: solid;
    border-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
}

.pd-variant-summary.is-active svg {
    color: #10b981;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .pd-variants {
        padding: 14px;
        border-radius: 12px;
    }

    .pd-color-chip {
        min-width: 46px;
        height: 46px;
    }

    .pd-size-chip {
        min-width: 46px;
        height: 44px;
        padding: 0 14px;
        font-size: 14px;
    }

    .pd-variant-label {
        font-size: 13.5px;
    }

    .pd-variant-label > strong {
        font-size: 13px;
        padding: 2px 8px;
    }

    .pd-variant-summary {
        font-size: 12.5px;
        padding: 9px 12px;
    }
}

/* Focus state for accessibility */
.pd-color-chip:focus-visible,
.pd-size-chip:focus-visible {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

/* Dark mode support (if body has .dark) */
body.dark .pd-variants {
    background: rgba(15, 15, 35, 0.6);
    border-color: rgba(139, 92, 246, 0.2);
}

body.dark .pd-color-chip,
body.dark .pd-size-chip {
    background: rgba(10, 10, 30, 0.7);
    border-color: rgba(139, 92, 246, 0.3);
    color: #e5e7eb;
}

body.dark .pd-variant-label > strong {
    background: rgba(99, 102, 241, 0.2);
    color: #c084fc;
}

body.dark .pd-variant-summary {
    background: rgba(10, 10, 30, 0.6);
    border-color: rgba(139, 92, 246, 0.3);
    color: #94a3b8;
}

body.dark .pd-variant-summary strong {
    color: #fff;
}