/**
 * Product Gallery Fixes
 * Fixes issues with slider navigation and thumbnail sizes
 */

/* Fix for slider navigation position */
.woocommerce-product-gallery .flex-direction-nav {
    position: absolute;
    top: 50%;
    width: 100%;
    z-index: 10;
    margin-top: -20px;
    padding: 0;
    list-style: none;
}

.woocommerce-product-gallery .flex-direction-nav a {
    text-decoration: none;
    display: block;
    width: 40px;
    height: 40px;
    margin: 0;
    position: absolute;
    top: 0;
    z-index: 10;
    overflow: hidden;
    opacity: 0;
    cursor: pointer;
    color: var(--color-accent, #c9a74d);
    text-shadow: none;
    transition: all 0.3s ease-in-out;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    text-align: center;
    line-height: 40px;
}

.woocommerce-product-gallery .flex-direction-nav .flex-prev {
    left: 10px;
}

.woocommerce-product-gallery .flex-direction-nav .flex-next {
    right: 10px;
}

.woocommerce-product-gallery:hover .flex-direction-nav a {
    opacity: 1;
}

/* Fix navigation icons */
.woocommerce-product-gallery .flex-direction-nav a:before {
    font-family: "FontAwesome";
    font-size: 24px;
    display: inline-block;
    content: '\f104';
    color: var(--color-accent, #c9a74d);
    text-shadow: none;
    line-height: 40px;
    width: 100%;
    text-align: center;
}

.woocommerce-product-gallery .flex-direction-nav a.flex-next:before {
    content: '\f105';
}

/* Fix for thumbnail sizes */
@media (min-width: 768px) {
    .woocommerce-product-gallery {
        display: flex;
        flex-direction: row-reverse;
        gap: 20px;
        max-height: 600px;
        overflow: visible;
    }
    
    .woocommerce-product-gallery .flex-control-thumbs {
        display: flex !important;
        flex-direction: column !important;
        margin: 0 !important;
        width: 120px !important; /* Increased from 100px */
        max-height: 600px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding-right: 10px !important;
        flex-shrink: 0 !important;
        gap: 10px !important;
        opacity: 1 !important;
        visibility: visible !important;
        z-index: 5 !important; /* Ensure thumbnails are above images */
    }
    
    .woocommerce-product-gallery .flex-control-thumbs li {
        width: 100% !important;
        padding: 0 !important;
        margin-bottom: 10px !important;
        flex: 0 0 100px !important; /* Increased from 80px */
        height: 100px !important; /* Increased from 80px */
        border-radius: 4px !important;
        overflow: hidden !important;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        cursor: pointer !important; /* Ensure cursor shows it's clickable */
    }
    
    .woocommerce-product-gallery .flex-control-thumbs img {
        height: 100% !important;
        object-fit: cover !important;
        opacity: 1 !important;
        visibility: visible !important;
        cursor: pointer !important; /* Ensure cursor shows it's clickable */
    }
    
    .woocommerce-product-gallery .flex-viewport {
        flex: 1;
        border-radius: 8px;
        overflow: hidden;
        height: 600px !important;
    }
}

/* Mobile thumbnail fixes */
@media (max-width: 767px) {
    .woocommerce-product-gallery .flex-control-thumbs {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        margin-top: 10px !important;
        z-index: 5 !important; /* Ensure thumbnails are above images */
    }
    
    .woocommerce-product-gallery .flex-control-thumbs li {
        margin: 0 !important;
        height: 70px !important;
        cursor: pointer !important; /* Ensure cursor shows it's clickable */
    }
    
    .woocommerce-product-gallery .flex-control-thumbs img {
        height: 100% !important;
        object-fit: cover !important;
        cursor: pointer !important; /* Ensure cursor shows it's clickable */
    }
}

/* Fix for FlexSlider initialization */
.woocommerce div.product div.images .flex-control-nav-container {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Base gallery styles */
.woocommerce-product-gallery {
    position: relative !important;
    margin-bottom: 2em !important;
    opacity: 1 !important;
    visibility: visible !important;
    width: 100% !important;
    background: transparent !important;
}

.woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
    position: relative !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    min-height: 300px !important;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: none !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease-in-out !important;
    background: transparent !important;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image.flex-active-slide {
    display: block !important;
    opacity: 1 !important;
    z-index: 2 !important;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    display: block !important;
    margin: 0 auto !important;
}

/* Desktop styles */
@media (min-width: 768px) {
    .woocommerce-product-gallery {
        display: flex !important;
        flex-direction: row-reverse !important;
        gap: 20px !important;
    }

    .woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
        flex: 1 !important;
        min-height: 500px !important;
    }

    .woocommerce-product-gallery .flex-control-thumbs {
        width: 120px !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        margin: 0 !important;
        padding: 0 !important;
        max-height: 500px !important;
        overflow-y: auto !important;
        scrollbar-width: thin !important;
    }

    .woocommerce-product-gallery .flex-control-thumbs li {
        width: 100% !important;
        height: 100px !important;
        margin: 0 !important;
        padding: 0 !important;
        cursor: pointer !important;
    }

    .woocommerce-product-gallery .flex-control-thumbs img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        border: 2px solid transparent !important;
        transition: all 0.3s ease !important;
        opacity: 0.7 !important;
    }

    .woocommerce-product-gallery .flex-control-thumbs img.flex-active,
    .woocommerce-product-gallery .flex-control-thumbs img:hover {
        opacity: 1 !important;
        border-color: var(--color-accent, #c9a74d) !important;
    }
}

/* Mobile styles */
@media (max-width: 767px) {
    .woocommerce-product-gallery {
        flex-direction: column !important;
    }

    .woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
        min-height: 300px !important;
        margin-bottom: 10px !important;
    }

    .woocommerce-product-gallery .flex-control-thumbs {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        margin: 10px 0 0 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .woocommerce-product-gallery .flex-control-thumbs li {
        width: 100% !important;
        height: 70px !important;
        margin: 0 !important;
        padding: 0 !important;
        cursor: pointer !important;
    }

    .woocommerce-product-gallery .flex-control-thumbs img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        border: 2px solid transparent !important;
        transition: all 0.3s ease !important;
        opacity: 0.7 !important;
    }

    .woocommerce-product-gallery .flex-control-thumbs img.flex-active,
    .woocommerce-product-gallery .flex-control-thumbs img:hover {
        opacity: 1 !important;
        border-color: var(--color-accent, #c9a74d) !important;
    }
}

/* Navigation styles */
.woocommerce-product-gallery .flex-direction-nav {
    position: absolute !important;
    top: 50% !important;
    left: 0 !important;
    right: 0 !important;
    transform: translateY(-50%) !important;
    display: flex !important;
    justify-content: space-between !important;
    padding: 0 20px !important;
    pointer-events: none !important;
    z-index: 3 !important;
}

.woocommerce-product-gallery .flex-direction-nav a {
    width: 40px !important;
    height: 40px !important;
    background: rgba(255, 255, 255, 0.8) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    color: #333 !important;
    pointer-events: auto !important;
    transition: all 0.3s ease !important;
}

.woocommerce-product-gallery .flex-direction-nav a:hover {
    background: #fff !important;
    color: var(--color-accent, #c9a74d) !important;
}

/* Hide unnecessary elements */
.woocommerce-product-gallery .woocommerce-product-gallery__trigger,
.woocommerce-product-gallery .zoomImg {
    display: none !important;
}

/* Ensure proper stacking */
.woocommerce-product-gallery {
    z-index: 1 !important;
}

.woocommerce-product-gallery .flex-viewport {
    display: none !important;
}

/* Force visibility of active elements */
.woocommerce-product-gallery__image.flex-active-slide,
.woocommerce-product-gallery__image.flex-active-slide img,
.woocommerce-product-gallery__image.flex-active-slide a {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Fix for FontAwesome icon loading */
.flex-direction-nav a:before {
    font-family: "FontAwesome" !important;
}

/* Fix for broken outlines */
.woocommerce div.product div.images img {
    border: 1px solid rgba(201, 167, 77, 0.2);
    background-color: transparent !important;
}

/* Ensure proper container styling */
.woocommerce-product-gallery {
    background-color: transparent !important;
}

/* Ensure thumbnails have proper styling */
.woocommerce div.product div.images .flex-control-thumbs li img {
    border: 2px solid rgba(201, 167, 77, 0.2);
    transition: all 0.3s ease;
    pointer-events: auto !important; /* Ensure clicks register */
}

.woocommerce div.product div.images .flex-control-thumbs li img.flex-active,
.woocommerce div.product div.images .flex-control-thumbs li img:hover {
    border-color: var(--color-accent, #c9a74d);
}

/* Fix for FontAwesome icons */
@font-face {
    font-family: 'FontAwesome';
    src: url('../../../fonts/fontawesome-webfont.woff2') format('woff2'),
         url('../../../fonts/fontawesome-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

/* Fix for flex-control-paging */
.woocommerce-product-gallery .flex-control-paging {
    display: none !important;
}

/* Fix for thumbnail click issues */
.woocommerce-product-gallery .flex-control-thumbs {
    pointer-events: auto !important;
}

.woocommerce-product-gallery .flex-control-thumbs li {
    pointer-events: auto !important;
}

.woocommerce-product-gallery .flex-control-thumbs li img {
    pointer-events: auto !important;
} 