/* Custom Product Page Styles */

.custom-product-page {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* WooCommerce Notices */
.custom-product-page .woocommerce-message,
.custom-product-page .woocommerce-info,
.custom-product-page .woocommerce-error {
    padding: 16px 20px;
    margin-bottom: 24px;
    border-radius: 6px;
    border-left: 4px solid;
    background: #f9f9f9;
}

.custom-product-page .woocommerce-message {
    border-left-color: #28a745;
    background: #d4edda;
    color: #155724;
}

.custom-product-page .woocommerce-info {
    border-left-color: #17a2b8;
    background: #d1ecf1;
    color: #0c5460;
}

.custom-product-page .woocommerce-error {
    border-left-color: #dc3545;
    background: #f8d7da;
    color: #721c24;
}

.custom-product-page .woocommerce-message a,
.custom-product-page .woocommerce-info a,
.custom-product-page .woocommerce-error a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.custom-product-page .woocommerce-message a:hover,
.custom-product-page .woocommerce-info a:hover,
.custom-product-page .woocommerce-error a:hover {
    opacity: 0.8;
}

/* Main Product Content - Two Column Layout */
.product-main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    margin-bottom: 60px;
}

/* Product Gallery Section */
.product-gallery-section {
    position: sticky;
    top: 20px;
    align-self: start;
}

.woocommerce-product-gallery {
    margin-bottom: 20px;
}

.woocommerce-product-gallery__wrapper {
    position: relative;
    margin: 0;
}

.woocommerce-product-gallery__image {
    display: none;
    position: relative;
}

.woocommerce-product-gallery__image.active-image {
    display: block;
}

.woocommerce-product-gallery__image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.woocommerce-main-image {
    display: block;
    text-decoration: none;
    cursor: zoom-in;
    position: relative;
}

.woocommerce-main-image::after {
    content: '🔍';
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.woocommerce-main-image:hover::after {
    opacity: 1;
}

/* Product Thumbnails */
.product-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.thumbnail-item {
    cursor: pointer;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.2s ease;
    aspect-ratio: 1;
}

.thumbnail-item:hover {
    border-color: #2c5aa0;
}

.thumbnail-item.active {
    border-color: #2c5aa0;
    box-shadow: 0 0 0 2px rgba(44, 90, 160, 0.2);
}

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

/* Product Images Placeholder */
.product-images-placeholder {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
}

.product-images-placeholder img {
    max-width: 300px;
    opacity: 0.5;
}

/* Product Info Section */
.product-info-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.product-summary {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.product-title {
    font-size: 32px;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a;
    line-height: 1.2;
}

/* Product Parameters */
.product-parameters {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 24px;
    border: 1px solid #e0e0e0;
}

.parameters-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: #333;
}

.parameters-table {
    width: 100%;
    border-collapse: collapse;
}

.parameters-table tr {
    border-bottom: 1px solid #e0e0e0;
}

.parameters-table tr:last-child {
    border-bottom: none;
}

.parameters-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: #666;
    width: 40%;
    font-size: 14px;
}

.parameters-table td {
    padding: 10px 12px;
    color: #333;
    font-size: 14px;
}

.parameters-table td ul,
.parameters-table td ol {
    margin: 0;
    padding-left: 20px;
}

.parameters-table td li {
    margin: 4px 0;
    line-height: 1.4;
}

.parameters-table td p {
    margin: 0;
    line-height: 1.5;
}

.parameters-table td p + p {
    margin-top: 8px;
}

/* Product Price */
.product-price-section {
    padding: 20px;
    background: #f0f7ff;
    border-radius: 8px;
    border: 2px solid #2c5aa0;
}

.product-price-section .price {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 700;
    color: #2c5aa0;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.product-price-section .price-with-tax {
    font-weight: 700;
}

.product-price-section .price-tax-label {
    font-size: 14px;
    font-weight: 400;
    color: #666;
}

.product-price-section .price-without-tax {
    margin: 0;
    font-size: 16px;
    font-weight: 400;
    color: #666;
}

.product-price-section .price del {
    opacity: 0.6;
    font-size: 20px;
    margin-right: 10px;
}

.product-price-section .price ins {
    text-decoration: none;
}

/* Add to Cart Section */
.product-add-to-cart {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.product-add-to-cart .cart {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.quantity-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quantity-wrapper label {
    font-weight: 600;
    font-size: 15px;
    color: #333;
}

.quantity-wrapper input.qty {
    width: 80px;
    padding: 10px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 16px;
    text-align: center;
}

.single_add_to_cart_button {
    background: #2c5aa0;
    color: #fff;
    border: none;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.single_add_to_cart_button:hover {
    background: #1e3d6f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 90, 160, 0.3);
}

/* Master Product Notice */
.master-product-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 16px 20px;
}

.master-product-notice p {
    margin: 0;
    color: #856404;
    font-size: 15px;
}

/* Children Products Table Section */
.product-children-section {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 2px solid #e0e0e0;
}

.children-table-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 24px 0;
    color: #1a1a1a;
}

.children-products-table-wrapper {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

/* Table Responsive Wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Children Products Table */
.children-products-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.children-products-table thead {
    background: #f5f5f5;
    border-bottom: 2px solid #d0d0d0;
}

.children-products-table th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.children-products-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s ease;
}

.children-products-table tbody tr:hover {
    background-color: #f9f9f9;
}

.children-products-table tbody tr:last-child {
    border-bottom: none;
}

.children-products-table td {
    padding: 12px;
    vertical-align: middle;
}

/* Column: Product */
.col-product {
    min-width: 280px;
}

.child-product-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.child-product-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.child-thumbnail {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.child-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.child-info {
    flex: 1;
    min-width: 0;
}

.child-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    transition: color 0.2s ease;
    line-height: 1.3;
}

.child-product-link:hover .child-title {
    color: #2c5aa0;
}

.child-item-number {
    font-size: 12px;
    color: #666;
    font-family: monospace;
}

/* Column: Cart */
.col-cart {
    width: 80px;
    text-align: center;
}

.add-to-cart-form {
    margin: 0;
}

.button-cart {
    background: #2c5aa0;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    line-height: 1;
}

.button-cart:hover {
    background: #1e3d6f;
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(44, 90, 160, 0.3);
}

.cart-icon {
    display: inline-block;
}

/* Column: Price */
.col-price {
    width: 140px;
    text-align: right;
    white-space: nowrap;
}

.table-price-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.table-price-main {
    font-weight: 700;
    color: #2c5aa0;
    font-size: 15px;
}

.table-price-secondary {
    font-weight: 400;
    color: #666;
    font-size: 12px;
}

.price-na {
    color: #999;
    font-style: italic;
}

/* Column: Parameters */
.col-param {
    min-width: 100px;
    text-align: center;
}

.children-products-table tbody .col-param {
    color: #555;
}

/* HTML content in parameter cells */
.col-param ul,
.col-param ol {
    text-align: left;
    margin: 0;
    padding-left: 20px;
    list-style-position: outside;
}

.col-param li {
    margin: 3px 0;
    line-height: 1.4;
}

.col-param span {
    display: inline;
}

/* Table Pagination */
.children-table-pagination {
    padding: 20px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
}

.pagination-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.pagination-info {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.pagination-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-item {
    margin: 0;
}

.pagination-link {
    display: inline-block;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    font-weight: 500;
    min-width: 40px;
    text-align: center;
}

.pagination-link:hover:not(.current) {
    background: #2c5aa0;
    color: #fff;
    border-color: #2c5aa0;
    transform: translateY(-1px);
}

.pagination-link.current {
    background: #2c5aa0;
    color: #fff;
    border-color: #2c5aa0;
    font-weight: 700;
    cursor: default;
}

/* Product Not Found */
.product-not-found {
    text-align: center;
    padding: 80px 20px;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 40px auto;
    max-width: 600px;
}

.product-not-found h1 {
    font-size: 28px;
    color: #333;
    margin: 0 0 16px 0;
}

.product-not-found p {
    font-size: 16px;
    color: #666;
    margin: 0;
}

.woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image img {
    width: auto;           /* Allows width to scale based on height */
    max-width: 100%;       /* Ensures it doesn't overflow horizontally */
    max-height: 1200px;     /* Change this value to your preferred max height */
    height: auto;          /* Maintains the original aspect ratio */
    display: block;        /* Removes bottom whitespace/line-height issues */
    margin: 0 auto;        /* Centers the image if the container is wider */
    object-fit: contain;   /* Ensures the image fits within the bounds without cropping */
}

/* Responsive Design */
@media (max-width: 1024px) {
    .product-main-content {
        grid-template-columns: 1fr;
        gap: 40px;
    }
    
    .product-gallery-section {
        position: static;
    }
    
    .children-products-table {
        font-size: 13px;
    }
    
    .col-product {
        min-width: 240px;
    }
    
    .child-thumbnail {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 768px) {
    .custom-product-page {
        padding: 20px 10px;
    }
    
    .product-title {
        font-size: 24px;
    }
    
    .product-parameters {
        padding: 16px;
    }
    
    .parameters-table th,
    .parameters-table td {
        padding: 8px;
        font-size: 13px;
    }
    
    .product-price-section .price {
        font-size: 24px;
    }
    
    .product-add-to-cart {
        padding: 16px;
    }
    
    .product-thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
    }
    
    .children-table-title {
        font-size: 20px;
    }
    
    .children-products-table {
        font-size: 12px;
    }
    
    .children-products-table th,
    .children-products-table td {
        padding: 10px 8px;
    }
    
    .col-product {
        min-width: 200px;
    }
    
    .child-thumbnail {
        width: 45px;
        height: 45px;
    }
    
    .child-title {
        font-size: 13px;
    }
    
    .child-item-number {
        font-size: 11px;
    }
    
    .button-cart {
        padding: 8px 12px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .custom-product-page {
        padding: 16px 8px;
    }
    
    .product-title {
        font-size: 20px;
    }
    
    .product-main-content {
        gap: 24px;
    }
    
    .product-info-section {
        gap: 16px;
    }
    
    .product-summary {
        gap: 16px;
    }
    
    .parameters-table th {
        width: 45%;
    }
    
    .product-price-section {
        padding: 16px;
    }
    
    .product-price-section .price {
        font-size: 20px;
    }
    
    .single_add_to_cart_button {
        padding: 12px 20px;
        font-size: 15px;
    }
    
    .children-products-table th,
    .children-products-table td {
        padding: 8px 6px;
    }
    
    .col-product {
        min-width: 180px;
    }
    
    .child-thumbnail {
        width: 40px;
        height: 40px;
    }
    
    .child-info {
        font-size: 12px;
    }
}

/* ============================================================================
   PHOTOSWIPE LIGHTBOX Z-INDEX FIX
   ============================================================================ */

/* Ensure PhotoSwipe appears above everything with maximum z-index */
.pswp {
    z-index: 2147483647 !important;
}

.pswp__bg {
    z-index: 2147483647 !important;
}

.pswp__scroll-wrap {
    z-index: 2147483647 !important;
}

.pswp__ui {
    z-index: 2147483647 !important;
}

/* Force all potentially high z-index elements below PhotoSwipe */
/* Target search bar */
.meilisearch-container {
    z-index: 100 !important;
}

.meilisearch-results {
    z-index: 1000 !important;
}

/* Target header and navigation */
header,
.site-header,
#masthead,
nav,
.wp-block-navigation {
    z-index: 100 !important;
}

/* Target footer elements */
footer,
.wp-block-template-part footer,
footer.wp-block-template-part,
.wp-block-template-part[data-area="footer"],
footer .wp-block-group,
footer.wp-block-group {
    z-index: 100 !important;
}

/* Target breadcrumb */
.breadcrumb-navigation {
    z-index: 100 !important;
}

/* Target cart elements */
.cart-contents,
.woocommerce-mini-cart,
.widget_shopping_cart,
.cart-count,
.mini-cart-count {
    z-index: 100 !important;
}

/* WordPress admin bar should stay on top only when not viewing PhotoSwipe */
#wpadminbar {
    z-index: 99999 !important;
}

/* When PhotoSwipe is open, hide problematic elements or force them lower */
body.pswp-open .meilisearch-container,
body.pswp-open header,
body.pswp-open .site-header,
body.pswp-open #masthead,
body.pswp-open nav,
body.pswp-open .wp-block-navigation,
body.pswp-open .breadcrumb-navigation,
body.pswp-open .cart-contents,
body.pswp-open .woocommerce-mini-cart,
body.pswp-open .widget_shopping_cart,
body.pswp-open #wpadminbar,
body.pswp-open footer,
body.pswp-open .wp-block-template-part footer,
body.pswp-open footer.wp-block-template-part,
body.pswp-open .wp-block-template-part[data-area="footer"],
body.pswp-open footer .wp-block-group,
body.pswp-open footer.wp-block-group {
    z-index: 1 !important;
}

/* Alternative approach: hide elements during PhotoSwipe */
body.pswp-open .meilisearch-container,
body.pswp-open .breadcrumb-navigation,
body.pswp-open .wc-block-mini-cart__badge,
body.pswp-open .cart-count,
body.pswp-open .mini-cart-count,
body.pswp-open footer,
body.pswp-open .wp-block-template-part footer,
body.pswp-open footer.wp-block-template-part,
body.pswp-open .wp-block-template-part[data-area="footer"] {
    visibility: hidden !important;
}

/* 1. Style for the "Skladem" Tag */
.product-stock-status.stock-in-stock {
    display: inline-block;
    color: #28a745;
    background: #eafaf1;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: -10px; /* Pulls the price section closer */
    width: fit-content;
}

/* 2. Make Add to Cart horizontal */
.product-add-to-cart .cart {
    flex-direction: row !important; /* Overrides the previous column layout */
    align-items: center;
    gap: 20px;
    flex-wrap: wrap; /* Ensures it looks okay on very small mobile screens */
}

/* 3. Optional: Make the button fill remaining space or stay compact */
.single_add_to_cart_button {
    flex-grow: 1; 
    white-space: nowrap;
}

/* Price Section Flex Alignment */
.price-and-stock-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Skladem Tag Styling */
.stock-status-badge {
    color: #28a745;
    background: #eafaf1;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    border: 1px solid #c3e6cb;
    text-transform: uppercase;
}

/* Single Line Cart Form */
.product-add-to-cart .cart {
    flex-direction: row !important;
    align-items: center;
    gap: 20px;
    flex-wrap: nowrap; /* Forces everything on one line */
}

.product-add-to-cart .quantity-wrapper {
    flex-shrink: 0;
}

.product-add-to-cart .single_add_to_cart_button {
    margin-top: 0;
    flex-grow: 1; /* Makes button fill the remaining width */
}

/* Mobile Adjustment: allow wrapping on very small screens if necessary */
@media (max-width: 480px) {
    .product-add-to-cart .cart {
        gap: 10px;
    }
}