/**
 * WooCommerce Seasonal Pricing - Optimized Styles
 * Performance-focused CSS with cross-browser compatibility
 */

/* Base Variables */
:root {
    --wcsp-primary: #E2A66E;
    --wcsp-dark: #323841;
    --wcsp-tooltip-bg: rgba(50,56,65,0.98);
}

/* Product Badges */
.wcsp-badges {
    position: absolute;
    bottom: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 90;
}

/* Force new stacking context and prevent clipping */
.product, 
.type-product, 
li.product,
.woocommerce-loop-product__link,
.woocommerce-product-gallery__image,
.woocommerce-LoopProduct-link,
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
    transform: translate3d(0,0,0);
    -webkit-transform: translate3d(0,0,0);
    position: relative !important;
    z-index: 1;
}

/* Ensure tooltips are always on top */
#wcsp-tooltip-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999999;
    overflow: hidden;
}

/* Ensure tooltip container exists outside flow */
#wcsp-tooltip-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 999999;
}

/* Tooltips */
.wcsp-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999999;
    transition: opacity 0.2s ease;
    background: var(--wcsp-tooltip-bg);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
    max-width: none;
    width: max-content;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    opacity: 1;
    visibility: visible;
    will-change: transform;    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.wcsp-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* Badge base */
.wcsp-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.85);
    color: inherit;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.2;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    border: 1px solid rgba(0,0,0,0.05);
    cursor: help;
    backface-visibility: hidden;
}

.wcsp-badge:hover {
    transform: translateY(-1px);
    background: rgba(255,255,255,0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

/* VAT icon */
.wcsp-badge .vat-icon {
    background: var(--wcsp-primary);
    color: #fff;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    margin-right: 4px;
    text-transform: uppercase;
}

/* Fixed tooltip positioning */
.wcsp-badge[data-tooltip],
.current-badge[data-tooltip] {
    position: relative;
}

.wcsp-badge[data-tooltip]:before,
.current-badge[data-tooltip]:before {
    content: attr(data-tooltip);
    position: fixed;
    background: var(--wcsp-tooltip-bg);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    z-index: 999999;
    transition: opacity 0.2s ease;
}

.wcsp-badge[data-tooltip]:before {
    top: var(--tooltip-y, 0);
    left: var(--tooltip-x, 0);
    transform: translate(-50%, -100%) translateY(-8px);
}

.current-badge[data-tooltip]:before {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
}

.wcsp-badge[data-tooltip]:hover:before,
.current-badge[data-tooltip]:hover:before {
    opacity: 1;
    visibility: visible;
}

/* Seasonal Info Card */
.seasonal-info-card {
    margin: 2em 0;
    padding: 1.5em;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.seasonal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5em;
    flex-wrap: wrap;
    gap: 1em;
}

.seasonal-title {
    display: flex;
    align-items: center;
    gap: 0.5em;
    font-size: 1.1em;
    font-weight: 400;
    color: #333;
    margin: 0;
}

.chart-icon {
    color: var(--wcsp-primary);
}

/* Current badges in product page */
.seasonal-current {
    display: flex;
    align-items: center;
    gap: 0.75em;
    margin: 0;
}

.current-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.4em 0.8em;
    background: rgba(255,255,255,0.95);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 4px;
    font-size: 0.9em;
    color: #666;
    cursor: help;
    transition: transform 0.2s ease;
}

.current-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.current-badge .badge-icon {
    color: var(--wcsp-primary);
}

.current-badge .badge-value {
    font-weight: 400;
    color: #333;
}

/* Chart container */
.seasonal-chart-container {
    position: relative;
    background: rgba(255,255,255,0.5);
    border-radius: 8px;
    padding: 1em;
    border: 1px solid rgba(0,0,0,0.05);
    min-height: 200px;
}

.seasonal-chart {
    width: 100% !important;
    height: 200px !important;
    display: block !important;
}

/* History table */
.coeff-history-table {
    width: 100%;
    margin-top: 1.5em;
    border-collapse: collapse;
    font-size: 0.9em;
}

.coeff-history-table th,
.coeff-history-table td {
    padding: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    text-align: left;
}

.coeff-history-table th {
    font-weight: 400;
    color: #666;
}

/* Responsive */
@media (max-width: 767px) {
    .wcsp-badges {
        bottom: 6px;
        left: 6px;
    }
    
    .wcsp-badge {
        font-size: 11px;
        padding: 3px 6px;
    }
    
    .seasonal-chart {
        height: 250px !important;
    }
    
    .seasonal-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* RTL Support */
[dir="rtl"] .wcsp-badges {
    left: auto;
    right: 8px;
}

[dir="rtl"] .wcsp-tooltip {
    direction: rtl;
    text-align: right;
}

/* Support for high contrast mode */
@media (forced-colors: active) {
    .wcsp-badge,
    .wcsp-tooltip {
        border: 1px solid CanvasText;
        background: Canvas;
        color: CanvasText;
    }
}