/* =========================================================
   Product Detail Page (Grid Layout)
========================================================= */
.product-detail {
    display: grid;
    grid-template-columns: 2fr 1fr; /* left: images, right: info */
    gap: 1rem;
    align-items: start;
    padding: 1.25rem;
    box-sizing: border-box;
}

/* ------------------- Images Column ------------------- */
.product-img-wrapper {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 0.5rem;
    position: relative;
    min-width: 250px;
    max-width: 100%;
    margin-left: -1rem;
}

.image-zoom-container {
    grid-column: 2;
    grid-row: 1;
}

#thumbnails {
    grid-column: 1;
    grid-row: 1;
}

.out-of-stock-badge {
    position: absolute;
    top: 50px;
    left: -50px;
    background: #d32f2f;
    color: #fff;
    padding: 8px 60px;
    font-weight: bold;
    font-size: 14px;
    transform: rotate(-45deg);
    letter-spacing: 1px;
    text-align: center;
    pointer-events: none;
}

#main-product-image {
    width: 100%;            /* full width of column */
    height: auto;           /* fixed height */
    object-fit: cover;      /* scale image without cropping */
    cursor: zoom-in;        /* Cursor hint */
    transition: transform 0.3s ease;
}

/* ------------------- Zoom Result / Magnifier ------------------- */
#main-product-image.zoomed {
    transform: scale(2); /* adjust zoom level */
    cursor: grab;
    z-index: 10;
}

.image-zoom-container {
    overflow: hidden;          /* hide magnifier overflow on desktop */
    touch-action: none;        /* desktop */
    position: relative;
}

#zoom-result {
    display: none;               /* hidden by default */
    position: absolute;
    border: 1px solid #ccc;
    width: 100%;                /* size of magnifier window */
    height: 100%;
    right: -100%;               /* position next to main image */
    top: 0;
    background-repeat: no-repeat;
    background-size: cover;      /* this will handle the zoom */
    z-index: 10;
    overflow: hidden;
    cursor: none;                /* hide default cursor inside zoom */
}

/* ------------------- Variant Buttons ------------------- */
.variant-selectors {
    display: flex;
    flex-direction: row;
    gap: 1rem;
}

.variant-btn {
    border: var(--btnBorder);
    background-color: var(--btnBgColor);
    color: var(--btnTextColor);
    padding: 0.4rem 0.8rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: normal;
}

/* Hover effect */
.variant-btn:hover {
    background-color: var(--btnTextColor);
    color: var(--btnBgColor);
}

/* Selected / active variant */
.variant-btn.selected {
    background-color: var(--btnTextColor);
    color: var(--btnBgColor);
}

/* Thumbnails */
.thumbnails {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    justify-content: flex-start; 
    align-items: center;
}

.thumbnails .thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid #ccc;
    transition: transform 0.2s, border-color 0.2s;
}

.thumbnails .thumbnail:hover {
    transform: scale(1.1);
}

.thumbnails .thumbnail.selected {
    transform: scale(1.1);
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
}

/* Wishlist heart */
.wishlist-heart {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
}

/* ------------------- Share section ------------------- */
.share-wrapper {
    position: absolute;
    top: 0.5rem;      /* top-left corner */
    left: 6.5rem;
    z-index: 15;
}

.share-wrapper .share-btn {
    border: none;
    background: transparent;
    cursor: pointer;
}

.share-wrapper .share-btn img {
    width: 32px;
    height: 32px;
}

.share-menu {
    display: none;     /* hidden by default */
    top: 110%;         /* below the button */
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    flex-direction: column;
    min-width: 80px;
    cursor: pointer;
    z-index: 20;
}

.share-menu.open {
    display: flex;     /* show menu when .open is toggled */
}

.share-menu button {
    background: none;
    border: none;
    padding: 0.6rem;
    text-align: left;
    cursor: pointer;
    font-size: 0.85rem;
}

.share-menu button:hover {
    cursor: pointer;
    background-color: #e1e1e1;
}

/* ------------------- Info Column ------------------- */
.product-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-sizing: border-box;
    min-width: 200px;

    position: sticky;
    top: 8rem;
    align-self: start;
}

.product-info .name {
    margin: 1rem 0rem;
    text-align: left;
    font-size: 1.5rem;
    font-weight: bold;
}

.product-info .desc {
    text-align: left;
    margin-bottom: 1rem;
}

.product-info #price {
    font-size: 1.25rem;
    font-weight: bold;
    text-align: left;
    color: var(--textColor);
    margin-bottom: 1rem;
}

button.add-to-cart {
    background-color: var(--btnBgColor);
    color: var(--btnTextColor);
    border: var(--btnBorder);
    outline: none;
    padding: 0.5rem 1rem;
    font-weight: normal;
    font-size: 1.2rem;
    line-height: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

/* Apply hover ONLY on hover-capable devices */
@media (hover: hover) and (pointer: fine) {
    button.add-to-cart:hover {
        background-color: var(--btnTextColor);
        color: var(--btnBgColor);
    }
}

button.add-to-cart.loading {
    background-color: var(--btnBgColor); /* keep black */
    color: var(--btnTextColor);
    cursor: not-allowed;
    opacity: 0.8;
}

button.add-to-cart.loading:hover {
    background-color: var(--btnBgColor);
    color: var(--btnTextColor);
}

/* ---------------------------------------------------------------------- */
/* ------------------- make zoom on pc same as mobile ------------------- */
/* ---------------------------------------------------------------------- */
#main-product-image {
    cursor: pointer;
}

#zoom-result {
    display: none;
}

/* Mobile full-screen zoom modal */
.mobile-zoom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    overflow: hidden;       /* prevent scroll */
}

.mobile-zoom-modal img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    margin: auto;
    user-select: none;
    pointer-events: auto;   /* allow swipe detection */
    transition: transform 0.35s ease, opacity 0.35s ease;
}

/* slide directions */
.mobile-zoom-modal img.slide-out-left {
    transform: translateX(-100%);
    opacity: 0;
}

.mobile-zoom-modal img.slide-out-right {
    transform: translateX(100%);
    opacity: 0;
}

.mobile-zoom-modal img.slide-in {
    transform: translateX(0);
    opacity: 1;
}

.mobile-zoom-modal .close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 3rem;
    background-color: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    border-radius: 10%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    z-index: 9999;
}

.img-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    font-size: 2.5rem;
    width: 50px;
    height: 60px;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.img-nav-btn.prev-btn {
    left: 1rem;
}

.img-nav-btn.next-btn {
    right: 1rem;
}

.img-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}


/* ------------------- Mobile Responsive ------------------- */
@media (max-width: 700px) {
    .product-detail {
        grid-template-columns: 1fr; /* single column */
        padding: 0.625rem;
        align-items: center;
    }

    .product-img-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        width: 100%;
        margin: 0 auto;
    }

    #thumbnails {
        grid-column: 1;
        grid-row: 2;
        flex-direction: row; /* horizontal again */
        justify-content: center;
    }

    .image-zoom-container {
        grid-column: 1;
        grid-row: 1;
    }

    .product-info {
        width: 100%;
        text-align: center;
        gap: 0.5rem;
    }

    .product-info .name {
        font-size: 1.5rem;
    }

    .product-info #price {
        font-size: 1.25rem;
    }

    .product-info .name,
    .product-info .desc,
    .product-info #price,
    .product-info .variant-selectors {
        margin-left: 0;
    }

    button.add-to-cart {
        width: 100%;
    }

    .wishlist-heart {
        font-size: 1.8rem;
    }

    .share-wrapper {
        top: 0.5rem;
        left: 0.5rem;
    }
}
