/* Custom Product UI - product-ui.css */

:root {
    --cpu-white:        #ffffff;
    --cpu-bg:           #f7f7f7;
    --cpu-border:       #e0e0e0;
    --cpu-text:         #1a1a1a;
    --cpu-text-muted:   #6b6b6b;
    --cpu-accent:       #1a1a1a;
    --cpu-swatch-size:  32px;
    --cpu-radius:       2px;
    --cpu-transition:   0.18s ease;
}

/* =========================================================
   WRAPPER
   ========================================================= */
.cpu-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 56px; /* wider gap between gallery and info panel — matches image2 */
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px;
    background: var(--cpu-white);
    font-family: inherit;
    color: var(--cpu-text);
    box-sizing: border-box;
}

.cpu-error {
    color: #c0392b;
    padding: 16px;
}

/* =========================================================
   GALLERY
   ========================================================= */
.cpu-gallery {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-direction: row-reverse; /* main image LEFT, thumbnails RIGHT */
}

.cpu-main-image-wrap {
    position: relative;
    flex: 1;
    background: #ffffff;
    border-radius: var(--cpu-radius);
    overflow: hidden;
    aspect-ratio: 3 / 4;
}

/* Pointer cursor only when popup is enabled */
.cpu-main-image-wrap.cpu-has-popup {
    cursor: pointer;
}

.cpu-main-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.cpu-main-image-wrap.cpu-has-popup:hover .cpu-main-img {
    transform: scale(1.03);
}

.cpu-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 72px;
    flex-shrink: 0;
    align-self: center; /* center the thumb strip against the main image height */
}

.cpu-thumb {
    width: 72px;
    height: 90px;
    background: var(--cpu-bg);
    border-radius: var(--cpu-radius);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--cpu-transition);
    flex-shrink: 0;
}

.cpu-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cpu-thumb:hover {
    border-color: var(--cpu-border);
}

.cpu-thumb-active {
    border-color: var(--cpu-accent) !important;
}

/* =========================================================
   PRODUCT INFO
   ========================================================= */
.cpu-info {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}

/* Bordered variant — matches design image */
.cpu-info-bordered {
    border: 2px solid #e5e5e5;
    border-radius: var(--cpu-radius);
}

.cpu-product-name {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin: 0;
    line-height: 1.3;
}

.cpu-price {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    line-height: 1;
}

.cpu-price .woocommerce-Price-amount {
    font-size: inherit;
}

.cpu-tax-note {
    font-size: 0.72rem;
    color: var(--cpu-text-muted);
    margin: -10px 0 0;
    letter-spacing: 0.01em;
}

.cpu-description {
    font-size: 0.875rem;
    color: var(--cpu-text);
    line-height: 1.6;
    border-top: 1px solid var(--cpu-border);
    padding-top: 14px;
}

.cpu-description p:first-child { margin-top: 0; }
.cpu-description p:last-child  { margin-bottom: 0; }

/* =========================================================
   VARIATIONS
   ========================================================= */
.cpu-variations {
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-top: 1px solid var(--cpu-border);
    padding-top: 16px;
}

.cpu-attr-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cpu-attr-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cpu-text-muted);
}

.cpu-attr-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Color swatches */
.cpu-color-swatch {
    width: var(--cpu-swatch-size);
    height: var(--cpu-swatch-size);
    border-radius: 50%;
    border: 2px solid var(--cpu-border);
    cursor: pointer;
    padding: 0;
    transition: border-color var(--cpu-transition), transform var(--cpu-transition);
    position: relative;
    flex-shrink: 0;
}

.cpu-color-swatch:hover {
    border-color: #999;
    transform: scale(1.1);
}

.cpu-color-swatch.cpu-option-active {
    border-color: var(--cpu-accent);
    box-shadow: 0 0 0 2px var(--cpu-white), 0 0 0 4px var(--cpu-accent);
}

/* If no color code, render as text pill */
.cpu-color-swatch:not([style]) {
    border-radius: var(--cpu-radius);
    width: auto;
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    background: var(--cpu-white);
    color: var(--cpu-text);
    border: 1px solid var(--cpu-border);
}

.cpu-color-swatch:not([style]).cpu-option-active {
    border-color: var(--cpu-accent);
    background: var(--cpu-accent);
    color: var(--cpu-white);
    box-shadow: none;
}

/* Size buttons */
.cpu-size-btn {
    min-width: 42px;
    height: 38px;
    padding: 0 12px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--cpu-white);
    color: var(--cpu-text);
    border: 1px solid var(--cpu-border);
    border-radius: var(--cpu-radius);
    cursor: pointer;
    transition: background var(--cpu-transition), border-color var(--cpu-transition), color var(--cpu-transition);
}

.cpu-size-btn:hover {
    border-color: #999;
}

.cpu-size-btn.cpu-option-active {
    background: var(--cpu-accent);
    color: var(--cpu-white);
    border-color: var(--cpu-accent);
}

.cpu-size-btn[disabled],
.cpu-size-btn.cpu-option-unavailable {
    opacity: 0.35;
    cursor: not-allowed;
}

/* =========================================================
   GUIDES
   ========================================================= */
.cpu-guides {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: -4px;
}

.cpu-guide-link {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cpu-text-muted);
    text-decoration: underline;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: color var(--cpu-transition);
}

.cpu-guide-link:hover {
    color: var(--cpu-text);
}

.cpu-guide-sep {
    color: var(--cpu-border);
    font-size: 0.75rem;
}

/* =========================================================
   STOCK BADGE
   ========================================================= */
.cpu-stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: -6px;
}

.cpu-stock-badge.cpu-stock-hidden {
    display: none;
}

.cpu-stock-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.cpu-stock-in {
    color: #1a7a3e;
}
.cpu-stock-in .cpu-stock-dot {
    background: #1a7a3e;
}

.cpu-stock-low {
    color: #b45309;
}
.cpu-stock-low .cpu-stock-dot {
    background: #b45309;
}

.cpu-stock-out {
    color: #c0392b;
}
.cpu-stock-out .cpu-stock-dot {
    background: #c0392b;
}

/* =========================================================
   VALIDATION / STATUS MESSAGES
   ========================================================= */
.cpu-validation-msg {
    font-size: 0.78rem;
    font-weight: 500;
    min-height: 20px;
    transition: opacity var(--cpu-transition);
    padding: 0 2px;
}

.cpu-msg-error {
    color: #c0392b;
}

.cpu-msg-info {
    color: #646970;
}

.cpu-msg-success {
    color: #1a7a3e;
}

/* Out of stock button state */
.cpu-add-btn.cpu-btn-out-of-stock {
    background: #f0f0f0;
    color: #999;
    border-color: #ddd;
    cursor: not-allowed;
    opacity: 1;
}
.cpu-add-cart {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.cpu-add-btn {
    width: 100%;
    height: 50px;
    background: var(--cpu-bg);
    color: var(--cpu-text);
    border: 1px solid var(--cpu-border);
    border-radius: var(--cpu-radius);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background var(--cpu-transition), border-color var(--cpu-transition), color var(--cpu-transition);
    position: relative;
    overflow: hidden;
}

.cpu-add-btn:not([disabled]):hover {
    background: var(--cpu-accent);
    color: var(--cpu-white);
    border-color: var(--cpu-accent);
}

.cpu-add-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.cpu-add-btn.cpu-loading {
    pointer-events: none;
    opacity: 0.7;
}

.cpu-add-btn.cpu-success {
    background: #27ae60;
    color: var(--cpu-white);
    border-color: #27ae60;
}

/* Spinner inside button */
.cpu-add-btn .cpu-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: cpu-spin 0.7s linear infinite;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.cpu-add-btn.cpu-loading .cpu-spinner {
    display: block;
}

@keyframes cpu-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* =========================================================
   LIGHTBOX
   ========================================================= */
.cpu-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0,0,0,0.88);
    align-items: center;
    justify-content: center;
}

.cpu-lightbox.cpu-open {
    display: flex;
}

.cpu-lightbox-inner {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    gap: 16px;
}

.cpu-lightbox-img {
    max-width: 80vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 2px;
    display: block;
    user-select: none;
}

.cpu-lightbox-close,
.cpu-lightbox-prev,
.cpu-lightbox-next {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--cpu-transition);
    flex-shrink: 0;
}

.cpu-lightbox-close:hover,
.cpu-lightbox-prev:hover,
.cpu-lightbox-next:hover {
    background: rgba(255,255,255,0.25);
}

.cpu-lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    border-radius: 50%;
}

/* =========================================================
   GUIDE POPUP
   ========================================================= */
.cpu-guide-popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999998;
    background: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cpu-guide-popup.cpu-open {
    display: flex;
}

.cpu-guide-popup-inner {
    background: var(--cpu-white);
    border-radius: 4px;
    max-width: 560px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
}

.cpu-guide-popup-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--cpu-text-muted);
    line-height: 1;
    padding: 4px;
}

.cpu-guide-popup-close:hover {
    color: var(--cpu-text);
}

.cpu-guide-popup-content {
    font-size: 0.875rem;
    line-height: 1.7;
}

/* =========================================================
   RESPONSIVE — 768px (tablet)
   ========================================================= */
@media ( max-width: 768px ) {
    .cpu-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 16px;
    }

    /* column-reverse: in source order thumbnails come first in HTML,
       so column-reverse makes the main image render on top visually */
    .cpu-gallery {
        flex-direction: column-reverse;
    }

    .cpu-thumbnails {
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        align-self: auto;
    }

    .cpu-thumbnails::-webkit-scrollbar {
        display: none;
    }

    .cpu-thumb {
        width: 64px;
        height: 80px;
        flex-shrink: 0;
    }

    .cpu-main-image-wrap {
        aspect-ratio: 4 / 5;
        width: 100%;
    }

    .cpu-info {
        padding: 16px;
    }

    .cpu-add-btn {
        height: 52px;
        font-size: 0.85rem;
    }

    /* Lightbox — full screen on mobile */
    .cpu-lightbox {
        background: rgba(0,0,0,0.95);
    }

    .cpu-lightbox-inner {
        width: 100vw;
        height: 100dvh;
        max-width: 100vw;
        max-height: 100dvh;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 0;
        padding: 0;
        position: relative;
        border-radius: 0;
    }

    .cpu-lightbox-img {
        max-width: 100vw;
        max-height: calc( 100dvh - 80px );
        width: 100%;
        object-fit: contain;
        border-radius: 0;
    }

    /* Close: top-right corner, fixed */
    .cpu-lightbox-close {
        position: fixed;
        top: 14px;
        right: 14px;
        left: auto;
        bottom: auto;
        width: 40px;
        height: 40px;
        font-size: 1.4rem;
        background: rgba(255,255,255,0.18);
        border: 1px solid rgba(255,255,255,0.3);
        z-index: 10;
    }

    /* Prev / Next: fixed to sides, vertically centered */
    .cpu-lightbox-prev,
    .cpu-lightbox-next {
        position: fixed;
        top: 50%;
        transform: translateY(-50%);
        z-index: 10;
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,0.15);
        border: 1px solid rgba(255,255,255,0.25);
        font-size: 1.1rem;
    }

    .cpu-lightbox-prev { left: 10px; }
    .cpu-lightbox-next { right: 10px; }
}

/* =========================================================
   RESPONSIVE — 650px
   ========================================================= */
@media ( max-width: 650px ) {
    .cpu-wrapper {
        padding: 12px;
        gap: 16px;
    }

    .cpu-product-name {
        font-size: 1.05rem;
    }

    .cpu-thumb {
        width: 56px;
        height: 70px;
    }

    .cpu-main-image-wrap {
        aspect-ratio: 1 / 1;
    }
}

/* =========================================================
   RESPONSIVE — 450px
   ========================================================= */
@media ( max-width: 450px ) {
    .cpu-wrapper {
        padding: 10px;
        gap: 14px;
    }

    .cpu-product-name {
        font-size: 0.95rem;
    }

    .cpu-price {
        font-size: 1rem;
    }

    .cpu-size-btn {
        flex: 1;
        min-width: 0;
        padding: 0 8px;
        height: 36px;
    }

    .cpu-attr-options.cpu-attr-sizes {
        width: 100%;
    }

    .cpu-thumb {
        width: 50px;
        height: 62px;
    }

    .cpu-add-btn {
        height: 48px;
    }
}

/* =========================================================
   RESPONSIVE — 320px
   ========================================================= */
@media ( max-width: 320px ) {
    .cpu-wrapper {
        padding: 8px;
        gap: 12px;
    }

    .cpu-product-name {
        font-size: 0.875rem;
        letter-spacing: 0;
    }

    .cpu-price {
        font-size: 0.9rem;
    }

    .cpu-size-btn {
        height: 32px;
        font-size: 0.65rem;
    }

    .cpu-thumb {
        width: 44px;
        height: 54px;
    }

    .cpu-info {
        padding: 10px;
        gap: 10px;
    }

    .cpu-add-btn {
        height: 44px;
        font-size: 0.75rem;
    }
}
