/**
 * [IPRO] Smart Wholesale Engine v8.2 - 2026
 * СТИЛІ: Фікс перекриття тултипів іншими барами (z-index stacking context).
 */

:root {
    --ipro-main-color: #33d257;
    --ipro-bg-white: #ffffff;
    --ipro-border-light: #eeeeee;
    --ipro-text-main: #333333;
    --ipro-text-muted: #55667f;
    --ipro-tooltip-bg: #ffffff;
    --ipro-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* 1. ОСНОВНИЙ КОНТЕЙНЕР */
.ipro-wholesale-main-container {
    background: var(--ipro-bg-white);
    border-radius: 10px;
    width: 100%;
    margin-bottom: 15px;
    font-family: inherit;
}

.ipro-ajax-progress-container {
    width: 100%;
}

/* 2. КНОПКИ ШВИДКОГО ОПТУ (Quick Buy) */
.ipro-quick-buy-grid {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 0px;
}

.ipro-quick-btn {
    background: var(--ipro-bg-white);
    border: 1px solid var(--ipro-border-light);
    border-radius: 10px;
    padding: 8px 10px;
    gap: 5px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.ipro-quick-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.ipro-quick-btn.ipro-active {
    border-color: var(--ipro-main-color);
    box-shadow: 0 0 0 1px var(--ipro-main-color);
    border-width: 1px;
}

.ipro-quick-btn .btn-price {
    font-size: 16px;
    line-height: 1.2;
    font-weight: 500;
    color: var(--ipro-text-main);
}

.ipro-quick-btn .btn-label {
    font-size: 11px;
    font-weight: 500;
    color: #555;
}

/* 3. ПРОГРЕС-БАРИ */
.ipro-progress-row, .ipro-wholesale-row {
    width: 100%;
    margin-bottom: 10px;
    position: relative; /* ВАЖЛИВО для z-index */
}

/* 🔥 ФІКС: Піднімаємо весь рядок над сусідніми при наведенні, щоб тултип не ховався */
.ipro-wholesale-row:hover {
    z-index: 99999;
}

.ipro-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    position: relative;
    z-index: 10;
}

/* 🔥 ФІКС: Також піднімаємо хедер */
.ipro-bar-header:hover {
    z-index: 99999;
}

.ipro-bar-title {
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    font-size: 12px;
    gap: 3px;
    color: var(--ipro-text-main);
}

.ipro-bar-stats {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
}

.ipro-bar-container, .ipro-bar-background {
    width: 100%;
    height: 6px;
    background: #eeeeee;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

.ipro-bar-fill, .ipro-cart-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #a0e3af 0%, #7ae291 50%, var(--ipro-main-color) 100%);
    border-radius: 20px;
    width: 0%; 
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1); 
}

/* 4. ТУЛТИПИ (Центрування по всій ширині кошика) */

/* Робимо весь хедер бару точкою відліку для тултипа */
.ipro-bar-header {
    position: relative !important;
}

/* ВАЖЛИВО: забираємо position: relative з іконки, щоб вона більше не тримала тултип */
.ipro-info-icon, .ipro-info-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
    color: var(--ipro-text-muted);
    position: static !important; 
}

.ipro-info-tooltip {
    display: none; 
    position: absolute;
    z-index: 999999; 
    background: var(--ipro-tooltip-bg);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    
    /* Ідеальне центрування по ширині всього бару */
    top: calc(100% + 5px); 
    left: 0;
    right: 0;
    margin: 0 auto; /* Автоматично вирівнює по центру */
    width: 95%; /* Займає майже всю ширину кошика */
    max-width: 320px; /* Але не розтягується надто сильно на ПК */
    
    white-space: normal;
    word-wrap: break-word;
    cursor: default;
    transform: none !important;
}

/* Ховаємо стрілочки, бо тултип тепер по центру бару, а не під іконкою */
.ipro-info-tooltip::before,
.ipro-info-tooltip::after {
    display: none !important;
}

/* --- Внутрішні стилі тексту тултипа --- */
.ipro-tooltip-header, .ipro-tooltip-title {
    font-weight: 700;
    font-size: 12px !important;
    color: #1e293b;
    margin-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 6px;
    line-height: 1.2;
}

.ipro-aggregator-info {
    font-size: 12px;
    font-weight: normal;
    color: var(--ipro-text-muted);
    margin-bottom: 8px;
    line-height: 1.3;
}

.ipro-info-tooltip ul, .ipro-tiers-list {
    list-style: none !important;
    padding: 0 !important;
    font-weight: 500;
    margin: 0 !important;
}

.ipro-info-tooltip li, .ipro-tiers-list li {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 6px !important;
    padding: 0 !important;
    background: none !important;
}

.ipro-info-tooltip li span, 
.ipro-info-tooltip li strong,
.ipro-tiers-list li span {
    font-size: 12px !important;
    line-height: 1.1 !important;
    margin: 0 !important;
}

.ipro-info-tooltip li strong, .tier-discount strong {
    font-weight: 700;
    color: #1e293b;
    margin-left: 10px !important;
}

.ipro-tooltip-footer {
    font-size: 11px;
    color: var(--ipro-text-muted);
    margin-top: 8px;
    border-top: 1px solid #f1f5f9;
    padding-top: 6px;
    text-align: center;
}

.active-tier, .tier-reached, .tier-reached .ipro-badge-discount {
    color: var(--ipro-main-color) !important;
}

.tier-reached strong {
    color: var(--ipro-main-color) !important;
}

/* 5. ФІКС КОШИКА FUNNELKIT (Marketplace Fix) */
.fkcart-slider-body:has(#ipro-cart-progress-container) {
    position: relative !important;
}

#ipro-cart-progress-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    background: var(--ipro-bg-white) !important;
    z-index: 10020 !important;
    padding: 7px 15px 5px 15px !important;
    border-bottom: 1px solid #eeeeee !important;
    height: auto !important;
}

/* 6. КАРТКА ТОВАРУ ТА АПСЕЛЛ */
.ipro-cart-upsell {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    margin-top: 5px;
    position: relative;
}

.ipro-upsell-orange { background: #fff7ed; color: #9a3412; border: 1px solid #ffedd5; }
.ipro-upsell-green { background: #f0fdf4; color: #166534; border: 1px solid #dcfce7; }

/* 7. АНІМАЦІЇ */
@keyframes iproPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.is-completed .ipro-bar-fill {
    background: var(--ipro-main-color);
    box-shadow: 0 0 8px var(--ipro-main-color);
}

/* RESPONSIVE */
@media (max-width: 480px) {
    .ipro-quick-buy-grid {
        display: inline-flex;
        grid-template-columns: 1fr 1fr;
    }
}

/* =======================================================
   [IPRO] ОПТОВА СТИЛІЗАЦІЯ v5.1 (РОЗДІЛЕНО КАТАЛОГ І КАРТКУ)
   ======================================================= */

/* --- 1. ТІЛЬКИ КАТАЛОГ (Абсолютний бейдж і рамка) --- */
/* Використовуємо селектор ul.products li.product, щоб НЕ чіпати головну сторінку товару */
ul.products li.product.ipro-wholesale-active-card {
    border: 1px solid #d1eddc !important;
    border-radius: 8px;
    position: relative;
    transition: border 0.3s ease;
}

ul.products li.product.ipro-wholesale-active-card::before {
    content: '📦 Опт активовано';
    position: absolute;
    top: -1px;
    width: 100%;
    line-height: 1;
    text-align: center;
    right: 0px;
    background: #ffffff40;
    color: #27ae60;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 10px 10px 0px 0px;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(39, 174, 96, 0.3);
    animation: iproPricePop 0.3s ease;
}

/* --- 2. ГОЛОВНА СТОРІНКА ТОВАРУ (Акуратний бейдж біля ціни) --- */
/* Повертаємо старий inline-бейдж ТІЛЬКИ для головної ціни під заголовком */
.summary .price .ipro-global-price.ipro-wholesale-applied::after {
    content: '📦 опт';
    display: inline-flex;
    align-items: center;
    padding: 2px 5px 2px 2px;
    border: 1px solid #27ae60;
    color: #27ae60;
    font-size: 10px;
    font-weight: 500;
    border-radius: 10px;
    background: #ffffff;
    white-space: nowrap;
    margin-left: 8px;
    animation: iproPricePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- 3. ЗАГАЛЬНА СТИЛІЗАЦІЯ ЦІНИ (Зелений колір) --- */
.ipro-global-price.ipro-wholesale-applied {
    display: inline-flex !important;
    align-items: center;
}

/* Ховаємо оригінальні ціни */
.ipro-global-price.ipro-wholesale-applied > *:not(.ipro-injected-price) {
    display: none !important;
}

/* Наша нова оптова ціна */
.ipro-injected-price {
    color: #27ae60 !important;
    font-size: 20px;
    font-weight: 500 !important;
    line-height: 1;
}

/* Примусово вимикаємо inline-бейдж у каталозі (бо там є абсолютний) */
ul.products li.product .ipro-global-price.ipro-wholesale-applied::after {
    display: none !important;
}

/* --- 4. ФІКСИ КОШИКА ТА ТУЛТИПА --- */
#ipro-cart-progress-container {
    position: relative;
    z-index: 999;
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.ipro-info-tooltip {
    max-width: 280px !important;
    width: max-content;
    white-space: normal;
    right: auto;
    left: 20px;
    word-wrap: break-word;
}

@media (max-width: 360px) {
    .ipro-info-tooltip {
        max-width: 240px !important;
        right: -20px;
    }
}

@keyframes iproPricePop {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* --- Захист від налізання FunnelKit --- */
.fkcart-slider-body, 
.fkcart-items, 
.widget_shopping_cart_content {
    padding-top: var(--ipro-cart-bar-height, 50px) !important;
}