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

/* ------------------- Images Column ------------------- */
.product-img-wrapper {
    display: grid;
    grid-template-rows: auto auto; /* main image + thumbnails */
    gap: 1rem;
    position: relative;
    min-width: 250px;
    max-width: 100%;
}

#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-btn {
    border: 1px solid #ccc;
    background-color: #fff;
    padding: 0.5rem 1rem;
    margin: 0.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

/* Hover effect */
.variant-btn:hover {
    border-color: #888;
    background-color: #f9f9f9;
}

/* Selected / active variant */
.variant-btn.selected {
    border-color: #007bff;         /* blue border */
    background-color: #e6f0ff;     /* light blue background */
    font-weight: bold;
}

/* Optional: checkmark indicator */
.variant-btn.selected::after {
    content: "✓";
    margin-left: 0.3em;
    color: #007bff;
    font-weight: bold;
}

/* Thumbnails */
.thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.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);
    border-color: #000;
}

.thumbnails .thumbnail.selected {
    border-color: #000;
    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: 0.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 */
    position: absolute;
    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;
}

.product-info h1 {
    margin: 0;
    font-size: 1.75rem;
}

.product-info .price {
    font-size: 1.375rem;
    font-weight: bold;
    color: var(--textColor);
}

button.add-to-cart {
    width: fit-content;
    background-color: var(--btnBgColor);
    color: var(--btnTextColor);
    border: solid 2px var(--btnBgColor);
    outline: none;
    padding: 0.25rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    font-size: 0.9rem;
    line-height: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s 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);
}


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

    .product-img-wrapper {
        width: 100%;
        max-width: 400px;
    }

    #zoom-result {
        display: none;          /* hide magnifier on mobile */
    }

    /* Mobile full-screen zoom modal */
    /* 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: var(--btnBgColor);
        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;
        font-size: 3rem;
    }

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

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

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

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

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