/**
 * WooCommerce Single Product Page Styles
 * Handles single product layout, gallery, and product details
 */

@import '../variables.css';

/* === SINGLE PRODUCT PAGE === */

.single-product-container {
    padding: var(--spacing-8);
    background-color: var(--color-white);
    margin-top: 50px;
    margin-bottom: 40px;
}

.single-product-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-8);
    align-items: start;
}

/* Product Gallery Section */

.product-gallery-section {
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    height: auto;
    position: relative;
}

.product-gallery-section .onsale {
    display: none;
}

.woocommerce div.product div.images {
    margin-bottom: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
}

/* Main gallery wrapper */

.woocommerce div.product .woocommerce-product-gallery {
    width: 100%;
    max-width: 100%;
    position: relative;
    overflow: hidden !important;
}

.woocommerce div.product .woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
    width: 100%;
    max-width: 100%;
    position: relative;
}

/* Main product images */

.woocommerce div.product .woocommerce-product-gallery__image img {
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    max-height: 60vh;
    display: block;
}

/* Ensure flexslider works properly */

.woocommerce div.product .flex-viewport {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
    position: relative;
    height: auto !important;
    min-height: 400px;
}

/* Force FlexSlider to recalculate dimensions */

.woocommerce div.product .flexslider:not(.flexslider-fade) .slides > li {
    width: 100% !important;
    height: auto !important;
    display: block !important;
}

.woocommerce div.product .flexslider:not(.flexslider-fade) .slides {
    width: 100% !important;
    height: auto !important;
}

/* Legacy image support */

.woocommerce div.product div.images img {
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    max-height: 60vh;
}

.woocommerce-product-gallery__trigger {
    display: none !important;
}

/* Ensure gallery JavaScript works properly */

.woocommerce div.product .woocommerce-product-gallery {
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
    visibility: visible !important;
}

.woocommerce div.product .woocommerce-product-gallery.woocommerce-product-gallery--loaded {
    opacity: 1 !important;
}

.woocommerce div.product .woocommerce-product-gallery__wrapper {
    transition: opacity 0.25s ease-in-out;
    position: relative;
}

/* Ensure all gallery images are properly contained but let WooCommerce handle visibility */

.woocommerce div.product .woocommerce-product-gallery__image {
    width: 100%;
    max-width: 100%;
    position: relative;
}

/* Don't interfere with FlexSlider's default behavior */

.woocommerce div.product .flexslider {
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* Ensure slides container is properly sized */

.woocommerce div.product .flexslider .slides {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* FlexSlider gallery wrapper positioning */

.woocommerce div.product .woocommerce-product-gallery__wrapper {
    width: auto !important;
    height: auto !important;
    display: flex;
}

.woocommerce div.product .woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image {
    width: 100% !important;
    height: auto !important;
    flex-shrink: 0;
    position: relative !important;
    overflow: visible !important;
    display: block !important;
}

.woocommerce div.product .woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image img {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    object-fit: contain !important;
    display: block !important;
}

/* Product Image Badges */

.product-badges {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-badges span {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.onsale-badge {
    background: #e74c3c;
    color: white;
}

.out-of-stock-badge {
    background: #95a5a6;
    color: white;
}

.new-product-badge {
    background: #27ae60;
    color: white;
}

/* Product Image Navigation */

.product-image-nav {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 15px;
    pointer-events: none;
    transform: translateY(-50%);
}

.product-image-nav button {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: auto;
}

.woocommerce-product-gallery:hover .product-image-nav button {
    opacity: 1;
}

.product-image-nav button:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Zoom Hint */

.zoom-hint {
    position: absolute;
    bottom: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s;
}

.woocommerce-product-gallery:hover .zoom-hint {
    opacity: 1;
}

/* Product Gallery Thumbnails */

.woocommerce div.product .flex-control-nav.flex-control-thumbs {
    margin-top: var(--spacing-4);
    padding: var(--spacing-3);
    background: var(--color-white);
    border-radius: var(--border-radius-lg);
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.woocommerce div.product .flex-control-nav.flex-control-thumbs::-webkit-scrollbar {
    height: 6px;
}

.woocommerce div.product .flex-control-nav.flex-control-thumbs::-webkit-scrollbar-track {
    background: transparent;
}

.woocommerce div.product .flex-control-nav.flex-control-thumbs::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.woocommerce div.product .flex-control-nav.flex-control-thumbs li {
    display: inline-block;
    margin: 0 var(--spacing-2) 0 0;
    list-style: none;
    cursor: pointer;
    position: relative;
    white-space: normal;
    flex-shrink: 0;
}

.woocommerce div.product .flex-control-nav.flex-control-thumbs li a {
    display: block;
    width: 80px;
    height: 80px;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    border: 2px solid transparent;
}

.woocommerce div.product .flex-control-nav.flex-control-thumbs li img {
    width: 80px;
    object-fit: contain;
    height: auto;
    border-radius: var(--border-radius-md);
}

.woocommerce div.product .flex-control-nav.flex-control-thumbs li a:hover {
    border-color: var(--color-primary-light);
}

.woocommerce div.product .flex-control-nav.flex-control-thumbs li.flex-active-slide a {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-lighter);
}

/* Ensure thumbnails are clickable */

.woocommerce div.product .flex-control-nav.flex-control-thumbs li a {
    pointer-events: all;
    cursor: pointer;
}

/* Product Info Section */

.product-info-section {
    background: var(--color-white);
}

.product-info-section .product-summary {
    position: relative;
}

.product-categories, .product-categories a{
    font-size: var(--font-size-xs);
    color: var(--color-primary-lighter);
}

.woocommerce div.product .product_title {
    font-family: var(--font-primary);
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
    margin-bottom: var(--spacing-4);
    line-height: var(--line-height-tight);
}

.woocommerce div.product .price {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
    margin-bottom: var(--spacing-6);
}

.woocommerce div.product .woocommerce-product-details__short-description {
    font-family: var(--font-tertiary);
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    color: var(--color-primary-lighter);
    margin-bottom: var(--spacing-6);
}

/* Add to Cart Form - Inline Layout */

.woocommerce div.product form.cart {
    display: flex;
    align-items: center;
    gap: var(--spacing-4);
    margin-bottom: var(--spacing-6);
    flex-wrap: nowrap;
}

.woocommerce div.product form.cart div.quantity {
    margin: 0;
    flex-shrink: 0;
}

/* Quantity Wrapper with Plus/Minus Buttons */

.quantity-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    width: fit-content;
    height: 48px;
}

.quantity-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 48px;
    background: var(--color-white);
    color: var(--color-primary);
    text-decoration: none !important;
    font-family: var(--font-tertiary);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    border: none;
    cursor: pointer;
    user-select: none;
}

.quantity-btn:hover,
.quantity-btn:focus,
.quantity-btn:active {
    background: var(--color-primary-alt);
    color: var(--color-white);
    text-decoration: none !important;
    outline: none;
}

.quantity-wrapper input.qty {
    width: 60px;
    height: 48px;
    padding: 0;
    border: none;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    border-radius: 0;
    text-align: center;
    font-family: var(--font-tertiary);
    font-size: var(--font-size-sm);
    background: var(--color-white);
    -moz-appearance: textfield;
}

/* Hide number input arrows */

.quantity-wrapper input.qty::-webkit-outer-spin-button,
.quantity-wrapper input.qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.quantity-wrapper input.qty:focus {
    outline: none;
    box-shadow: none;
}

/* Legacy quantity input styling (fallback) */

.woocommerce div.product form.cart div.quantity input.qty {
    width: 60px;
    padding: var(--spacing-3);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    text-align: center;
    font-family: var(--font-tertiary);
    font-size: var(--font-size-base);
}

.woocommerce div.product form.cart .single_add_to_cart_button {
    padding: var(--spacing-4) var(--spacing-6);
    background: var(--color-primary-alt);
    color: var(--color-white);
    border: none;
    border-radius: var(--border-radius-md);
    font-family: var(--font-primary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-bold);
    cursor: pointer;
    min-width: 200px;
    height: 48px;
    text-decoration: none !important;
    flex-grow: 1;
    white-space: nowrap;
}

.woocommerce div.product form.cart .single_add_to_cart_button:hover,
.woocommerce div.product form.cart .single_add_to_cart_button:focus {
    text-decoration: none !important;
}

.woocommerce div.product form.cart .single_add_to_cart_button:hover {
    background: var(--color-primary-alt-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Hide the "View cart" link that appears after AJAX add to cart */
.added_to_cart {
    display: none !important;
}

/* Low Stock Warning */

.woocommerce div.product .stock.low-stock {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: var(--spacing-3);
    border-radius: var(--border-radius-md);
    margin-bottom: var(--spacing-4);
    font-family: var(--font-tertiary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

/* === RESPONSIVE MEDIA (IFRAMES, VIDEOS) === */

/* General iframe responsiveness */

.woocommerce div.product iframe {
    max-width: 100%;
    height: auto;
}

/* YouTube embed container for better responsiveness */

.woocommerce div.product .video-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    margin: var(--spacing-4) 0;
}

.woocommerce div.product .video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Direct YouTube iframe styling */

.woocommerce div.product iframe[src*="youtube.com"],
.woocommerce div.product iframe[src*="youtu.be"] {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--border-radius);
    margin: var(--spacing-4) 0;
}

/* === PRODUCT ATTRIBUTES TABLE === */

.woocommerce-product-attributes.shop_attributes {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-4) 0;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.woocommerce-product-attributes.shop_attributes th {
    background: var(--color-white);
    color: var(--color-primary);
    font-family: var(--font-tertiary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    padding: var(--spacing-3) var(--spacing-4);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.woocommerce-product-attributes.shop_attributes td {
    color: var(--color-primary-lighter);
    font-family: var(--font-tertiary);
    font-size: var(--font-size-sm);
    padding: var(--spacing-3) var(--spacing-4);
    border-bottom: 1px solid var(--color-border);
    line-height: var(--line-height-relaxed);
}

.woocommerce-product-attributes.shop_attributes tr:last-child th,
.woocommerce-product-attributes.shop_attributes tr:last-child td {
    border-bottom: none;
}

.woocommerce-product-attributes.shop_attributes tr:nth-child(even) {
    background-color: var(--color-white);
}

.woocommerce-product-attributes.shop_attributes td p {
    margin: 0;
}

.woocommerce-product-attributes.shop_attributes td a {
    color: var(--color-primary);
    text-decoration: none;
}

.woocommerce-product-attributes.shop_attributes td a:hover {
    text-decoration: underline;
}

/* === CUSTOM PRODUCT INFO DISPLAY === */
.product-info-grid {
    display: flex;
    justify-content: space-between;
    text-align: center;
    gap: var(--spacing-3);
    flex-wrap: nowrap;
}

.product-info-grid > div {
    max-width: 25%;
    min-width: 0;
    padding: var(--spacing-2);
}

.product-info-grid > div > div:first-child {
    font-size: var(--font-size-xs);
    color: var(--color-primary-lighter);
    margin-bottom: var(--spacing-1);
}

.product-info-grid > div > div:last-child {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
}

/* === CUSTOM PRODUCT LINKS DISPLAY === */

.product-links-heading {
    padding-bottom: 10px;
}

.product-info-separator {
    margin-top: 1.5em;
}

.product-links-grid {
    display: flex !important;
    gap: var(--spacing-4) !important;
    align-items: center !important;
}

.product-links-grid a {
    display: inline-block !important;
}

.product-link-logo {
    height: 50px !important;
}

.product-link-logo--arena {
    margin-left: 20px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .product-info-grid {
        gap: unset;
    }

    .product-info-grid > div {
        margin-bottom: var(--spacing-2);
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 0;
    }
}

/* Small mobile devices - force 2 columns under 425px */
@media (max-width: 425px) {
    .product-info-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: var(--spacing-2);
        text-align: center;
    }

    .product-info-grid > div {
        flex: none;
        min-width: 0;
        max-width: none;
        margin-bottom: 0;
        padding: var(--spacing-2);
        overflow: hidden;
        word-wrap: break-word;
        hyphens: auto;
    }

    .product-info-grid > div > div:first-child {
        font-size: var(--font-size-2xs) !important;
        line-height: 1.2;
        margin-bottom: var(--spacing-1);
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: break-word;
        hyphens: auto;
    }

    .product-info-grid > div > div:last-child {
        font-size: var(--font-size-xs) !important;
        line-height: 1.3;
        font-weight: var(--font-weight-bold);
        word-break: break-word;
    }

    /* Single item: take full width */

    .product-info-grid > div:only-child {
        flex: 0 1 100%;
        min-width: 100%;
        max-width: 100%;
    }

    /* Two items: each takes close to 50% but stay on one line */

    .product-info-grid > div:nth-child(1):nth-last-child(2),
    .product-info-grid > div:nth-child(2):nth-last-child(1) {
        flex: 1 1 45%;
        min-width: 40%;
        max-width: 48%;
    }

    /* Smaller text on mobile */

    .product-info-grid > div > div:first-child {
        font-size: var(--font-size-2xs);
    }

    .product-info-grid > div > div:last-child {
        font-size: var(--font-size-xs);
    }

    /* Mobile links - stack vertically or wrap */

    .product-links-grid {
        justify-content: space-around;
        gap: var(--spacing-3);
    }

    .product-links-grid img {
        height: 40px;
    }
}

/* Laptop/Desktop adjustments */
@media (min-width: 1025px) {

    .single-product-layout {
        grid-template-columns: 1.2fr 1fr;
        gap: var(--spacing-10);
        max-width: 1400px;
        margin: 0 auto;
    }

    .product-gallery-section {
        max-height: calc(100vh - 140px);
    }

    .woocommerce div.product div.images img,
    .woocommerce div.product .woocommerce-product-gallery__image img {
        max-height: 70vh;
    }
}

/* Tablet Responsive */
@media (max-width: 1024px) and (min-width: 769px) {

    .single-product-container {
        max-width: 800px;
        margin-left: auto;
        margin-right: auto;
    }

    .single-product-layout {
        gap: var(--spacing-8);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .single-product-container {
        margin-top: 20px;
        margin-bottom: 20px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        padding: var(--spacing-4);
        box-sizing: border-box;
    }

    .single-product-layout {
        grid-template-columns: 1fr;
        gap: var(--spacing-4);
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .product-gallery-section {
        position: relative;
        order: 1;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        box-sizing: border-box;
    }

    /* Fix image overflow on mobile */

    .woocommerce div.product div.images {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .woocommerce div.product div.images img {
        max-width: 100%;
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    /* Mobile FlexSlider fixes */

    .woocommerce div.product .flex-viewport {
        height: auto !important;
        min-height: 250px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .woocommerce div.product .woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        display: flex !important;
        gap: 0;
    }

    .woocommerce div.product .woocommerce-product-gallery__image {
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
        height: auto !important;
        flex-shrink: 0 !important;
        position: relative !important;
        display: block !important;
    }

    .woocommerce div.product .woocommerce-product-gallery__image img {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
        display: block !important;
    }

    /* Mobile FlexSlider slide management */

    .woocommerce div.product .flexslider .slides {
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .woocommerce div.product .flexslider .slides > li {
        width: 100% !important;
        height: auto !important;
        display: block !important;
        position: relative !important;
    }

    /* Responsive iframes (YouTube, etc.) */

    iframe {
        width: 100%;
        aspect-ratio: 16/9;
        height: auto;
    }

    .product-info-section {
        order: 2;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .woocommerce div.product .product_title {
        font-size: var(--font-size-2xl);
    }

    .woocommerce div.product .price {
        font-size: var(--font-size-xl);
    }

    /* Mobile form layout - keep on same row */

    .woocommerce div.product form.cart {
        flex-direction: row;
        align-items: center;
        gap: var(--spacing-2);
        flex-wrap: nowrap;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .woocommerce div.product form.cart .single_add_to_cart_button {
        min-width: 120px;
        flex-grow: 1;
        font-size: var(--font-size-sm);
        padding: var(--spacing-3) var(--spacing-4);
    }
}

/* Out of Stock Styling */
.out-of-stock-notice {
    display: flex;
    align-items: center;
    margin-bottom: var(--spacing-6);
}

.out-of-stock-notice .stock.out-of-stock {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    background: #f8d7da;
    color: #721c24;
    padding: var(--spacing-3) var(--spacing-4);
    border-radius: var(--border-radius-md);
    border: 1px solid #f5c6cb;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-base);
    margin: 0;
}

.out-of-stock-notice .stock.out-of-stock i {
    color: #721c24;
    font-size: var(--font-size-lg);
}

/* Sticky Header Out of Stock */
.sticky-out-of-stock {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2) var(--spacing-4);
}

.sticky-out-of-stock .stock.out-of-stock {
    display: flex;
    align-items: center;
    gap: var(--spacing-1);
    background: #f8d7da;
    color: #721c24;
    padding: var(--spacing-2) var(--spacing-3);
    border-radius: var(--border-radius-sm);
    border: 1px solid #f5c6cb;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-sm);
    margin: 0;
    white-space: nowrap;
}

.sticky-out-of-stock .stock.out-of-stock i {
    color: #721c24;
    font-size: var(--font-size-base);
}

.product-brands-container {
    margin-top: var(--spacing-3);
}