/**
 * Enhanced Variable Products - Custom Styles
 */

/* Main container */
.enhanced-variable-product-container {
    margin: 20px 0;
    padding: 10px 0;
    clear: both;
    position: relative;
    z-index: 1;
    overflow: visible;
    width: 100%;
    clear: none !important;
}

/* Color swatches section */
.evp-colors-container {
    margin-bottom: 20px;
}

.evp-colors-container h4 {
    margin-bottom: 10px;
display:flex;
justify-content:space-between;
align-items: center;
}

.evp-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.evp-color-swatch-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.evp-color-swatch-wrapper:hover {
    transform: translateY(-2px);
}

/* Swatch size variations */
.enhanced-variable-product-container.swatch-small .evp-color-swatch {
    width: 30px;
    height: 30px;
}

.enhanced-variable-product-container.swatch-medium .evp-color-swatch {
    width: 40px;
    height: 40px;
}

.enhanced-variable-product-container.swatch-large .evp-color-swatch {
    width: 50px;
    height: 50px;
}

.evp-color-swatch {
    border-radius: 50%;
    border: 2px solid #e0e0e0;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: pointer;
    position: relative;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 0;
    margin: 0 auto;
    background-color: transparent;
    outline: none;
    display: block;
}

/* Image-based swatches */
.evp-color-swatch.has-image {
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}

.evp-color-swatch.has-image::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    box-sizing: border-box;
    border: 1px solid rgba(0,0,0,0.1);
}

.evp-color-swatch:hover {
    transform: scale(1.1);
    border-color: #aaa;
}

.evp-color-swatch.active {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.3);
}

.evp-color-swatch.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    text-shadow: 0 0 2px rgba(0,0,0,0.8);
    font-size: 16px;
    font-weight: bold;
    z-index: 2;
}

/* Special handling for active image swatches */
.evp-color-swatch.has-image.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.2);
    z-index: 1;
}

.evp-color-name {
    font-size: 12px;
    margin-top: 5px;
    text-align: center;
    color: #333;
}

.evp-selected-color {
    margin-top: 10px;
    font-size: 14px;
    font-weight: 500;
    padding: 5px 10px;
    background-color: #f7f7f7;
    border-radius: 3px;
    display: inline-block;
}

.evp-selected-color-label {
    font-weight: bold;
    margin-right: 5px;
}

/* Size table */
.evp-sizes-container {
    margin-bottom: 20px;
    background-color: #fff;
    border-radius: 4px;
    border: 1px solid #e9e9e9;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    min-height: 100px; /* Ensure container has height even when empty */
    position: relative; /* For loading spinner positioning */
}

/* Loading indicator for size table */
.evp-sizes-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background-color: rgba(255, 255, 255, 0.8);
}

.evp-sizes-loading p {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
}

/* No sizes message */
.evp-no-sizes {
    text-align: center;
    padding: 20px 0 !important;
    color: #666;
    font-style: italic;
}

.evp-sizes-container h4 {
    margin: 0;
    padding: 12px 15px;
    background-color: #f7f7f7;
    border-bottom: 1px solid #e9e9e9;
}

.evp-size-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
}

.evp-size-table th {
    padding: 10px 15px;
    font-weight: 600;
    text-align: left;
    background-color: #f7f7f7;
    border-bottom: 1px solid #ddd;
}

.evp-size-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.evp-size-table tr:last-child td {
    border-bottom: none;
}

.evp-size-row {
    transition: background-color 0.2s ease;
}

.evp-size-row:hover {
    background-color: #f9f9f9;
}

.evp-size-row.unavailable {
    display: none;
}

.evp-size-name {
    font-weight: 500;
}

.evp-size-price {
    font-weight: 500;
    color: #0073aa;
}

/* Stock quantity display */
.evp-size-stock {
    font-weight: 500;
    font-size: 14px;
}

/* High stock (default) */
.evp-size-stock {
    color: #0f834d;
}

/* Low stock */
.evp-size-stock.low-stock {
    color: #e67e22;
}

/* Out of stock */
.evp-size-stock.out-of-stock {
    color: #e2401c;
}

.evp-stock-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: 500;
}

.evp-stock-status.in-stock {
    background-color: #e6f7e9;
    color: #0f834d;
}

.evp-stock-status.low-stock {
    background-color: #fff5e6;
    color: #e67e22;
}

.evp-stock-status.out-of-stock {
    background-color: #fff6f6;
    color: #e2401c;
}

/* Quantity controls */
.evp-quantity-wrapper {
    display: flex;
    align-items: center;
    max-width: 120px;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.evp-qty-btn {
    width: 30px;
    height: 30px;
    border: none;
    background-color: #f7f7f7;
    font-size: 16px;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    padding: 0;
    margin: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.evp-qty-btn:hover {
    background-color: #e9e9e9;
}

.evp-qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.evp-qty-input {
    width: 40px;
    height: 30px;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    text-align: center;
    font-size: 14px;
    padding: 0 5px;
    margin: 0;
    -moz-appearance: textfield; /* Hide number input arrows in Firefox */
}

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

/* Add to cart button */
.evp-add-to-cart-container {
    margin-top: 20px;
    position: relative;
}

.evp-add-to-cart-button {
    display: inline-block;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    background-color: #0073aa;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.evp-add-to-cart-button:hover {
    background-color: #005f8b;
}

.evp-add-to-cart-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.evp-add-to-cart-message {
    margin: 10px 0;
    padding: 10px;
    border-radius: 4px;
}

.evp-add-to-cart-message.success {
    background-color: #e6f7e9;
    color: #0f834d;
    display: block;
}

.evp-add-to-cart-message.error {
    background-color: #dc3545;
    border: 1px solid #dc3232;
    color: #ffffff;
    display: block;
}

.evp-add-to-cart-message.notice {
    background-color: transparent;
    border: 1px solid #dc3545;
    color: #dc3545;
    display: block;
    font-style: italic;
}

/* Login required notice */
.evp-login-required-notice {
    padding: 10px 15px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 15px;
    text-align: center;
}

.evp-login-required-notice p {
    margin: 0;
    font-size: 14px;
    color: #495057;
}

.evp-login-required-notice a {
    font-weight: bold;
    text-decoration: underline;
}

/* Loading animation */
.evp-loading-overlay {
    pointer-events: all !important; /* Block clicks while loading */
    z-index: 1000 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(255, 255, 255, 0.8) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.evp-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 115, 170, 0.2);
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: evp-spin 1s linear infinite;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

@keyframes evp-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Special case for white color swatch */
.evp-color-swatch.white {
    background-color: #ffffff;
    border: 2px solid #cccccc;
}

.evp-color-swatch.white.active::after {
    color: #000;
    text-shadow: none;
}

/* Debug info */
.evp-debug-info {
    margin-top: 20px;
    padding: 8px 12px;
    background-color: #f7f7f7;
    border-left: 4px solid #0073aa;
    font-size: 12px;
    opacity: 0.7;
}

/* Animations */
@keyframes evp-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes evp-slide-down {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.evp-sizes-container:not([style*="display: none"]) {
    animation: evp-slide-down 0.3s ease;
}

.evp-add-to-cart-message.success,
.evp-add-to-cart-message.error {
    animation: evp-fade-in 0.3s ease;
}

/* Cart notification */
.evp-cart-notification {
    position: fixed;
    z-index: 100;
    max-width: 300px;
    top: 80px;
    right: 20px;
    background-color: #fff;
    border-radius: 4px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    transform: translateY(-100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.evp-cart-notification.active {
    transform: translateY(0);
    opacity: 1;
}

.evp-cart-notification-icon {
    margin-right: 12px;
    color: #0f834d;
    font-size: 20px;
}

.evp-cart-notification-text {
    flex-grow: 1;
}

.evp-cart-notification-close {
    margin-left: 10px;
    cursor: pointer;
    color: #999;
    font-size: 18px;
}

/* Responsive styles */
@media (max-width: 768px) {
    .evp-color-swatches {
        justify-content: flex-start;
        gap: 8px;
    }
    
    .evp-color-swatch-wrapper {
        width: 50px;
    }
    
    .evp-color-name {
        font-size: 11px;
    }
    
    .evp-size-table th,
    .evp-size-table td {
        padding: 8px 10px;
    }
    
    .evp-qty-input {
        width: 30px;
    }
}

@media (max-width: 480px) {
    .evp-size-table th,
    .evp-size-table td {
        padding: 6px 8px;
        font-size: 13px;
    }
    
    .evp-qty-btn {
        width: 26px;
        height: 26px;
    }
    
    .evp-qty-input {
        width: 26px;
        height: 26px;
    }
    
    .evp-add-to-cart-button {
        width: 100%;
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .evp-cart-notification {
        max-width: calc(100% - 40px);
    }
}

/* LAYOUT FIXES - Added to fix elements disappearing on variable product pages */
/* =========================================================================== */

/* Ensure the main product container doesn't affect other page elements */
.enhanced-variable-product-container {
    position: relative; /* Keep relative positioning */
    z-index: 1; /* Lower z-index to not interfere with other elements */
    overflow: visible; /* Ensure content isn't cut off */
    margin: 20px 0; /* Maintain spacing */
    width: 100%; /* Set explicit width */
    clear: none !important; /* Don't clear other elements */
}

/* Fix cart notification to prevent it from covering key elements */
.evp-cart-notification {
    position: fixed;
    z-index: 100; /* Lower z-index from 9999 */
    max-width: 300px;
    top: 80px; /* Position it below header/navbar */
    right: 20px;
}

/* Ensure forms and add-to-cart elements don't break layout */
.single-product div.product form.cart {
    overflow: visible !important;
    clear: both !important;
    margin-bottom: 30px !important;
}

/* Make sure modals and overlays only cover product area */
.evp-loading-overlay {
    position: absolute;
    z-index: 50; /* Lower from 100 */
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    right: auto;
    bottom: auto;
    background-color: rgba(255, 255, 255, 0.98);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.evp-loading-overlay p {
    margin-top: 15px;
    font-size: 14px;
    color: #666;
    text-align: center;
    max-width: 250px;
}

/* Fix for footer, related products and sidebar */
.site-footer,
.related.products,
.sidebar,
#secondary,
.site-header {
    position: relative;
    z-index: 5;
    display: block !important;
    visibility: visible !important;
}

/* Fix for WooCommerce tabs */
.woocommerce-tabs {
    clear: both !important;
    display: block !important;
    visibility: visible !important;
    margin-top: 20px !important;
}

/* Keep product content contained */
.single-product div.product {
    overflow: visible;
}

/* WooCommerce Message Styling */
.woocommerce-message {
    border-top-color: #8fae1b;
    background-color: #f7f6f7;
    padding: 1em 1.5em 1em 3.5em;
    margin: 0 0 2em;
    position: relative;
    color: #515151;
    list-style: none outside;
    width: auto;
    word-wrap: break-word;
    border-top: 3px solid #8fae1b;
    line-height: 1.5;
}

.woocommerce-message::before {
    content: "\e015";
    color: #8fae1b;
    font-family: WooCommerce;
    display: inline-block;
    position: absolute;
    top: 1em;
    left: 1.5em;
}

.woocommerce-message .button {
    float: right;
    padding: 0.5em 1em;
    margin-top: -0.3em;
    margin-bottom: -0.3em;
    margin-left: 0.5em;
    background-color: #8fae1b;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: 3px;
}

.woocommerce-message .button:hover {
    background-color: #7e9b19;
    color: #fff;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .woocommerce-message {
        padding: 1em 1em 1em 3em;
    }
    
    .woocommerce-message .button {
        float: none;
        display: block;
        margin: 0.5em 0 0;
        text-align: center;
    }
}

/* Multi-color pie chart swatches */
.evp-color-swatch[style*="conic-gradient"],
.evp-color-swatch[style*="linear-gradient"] {
    overflow: hidden;
    position: relative;
}

/* Fix for Safari which has issues with border-radius and conic-gradient */
@supports (-webkit-hyphens:none) {
    .evp-color-swatch[style*="conic-gradient"],
    .evp-color-swatch[style*="linear-gradient"] {
        -webkit-mask-image: -webkit-radial-gradient(white, black);
    }
}

/* Fix checkmark visibility on multi-color swatches */
.evp-color-swatch[style*="conic-gradient"].active::after,
.evp-color-swatch[style*="linear-gradient"].active::after {
    color: #fff;
    text-shadow: 
        0 0 3px rgba(0,0,0,0.9),
        0 0 2px rgba(0,0,0,0.9),
        0 0 1px rgba(0,0,0,0.9);
    font-size: 16px;
    z-index: 3;
} 