/**
 * 4Pixel - Quantity Discount Module
 * Clean & minimal frontend styles
 *
 * @author    4Pixel <kontakt@4pixel.pl>
 * @copyright 2026 4Pixel
 */

/* ========================================
   Base Component - Clean, no background
   ======================================== */

.fp-qty-discount {
    font-size: 12px;
    margin: 8px 0;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
}

/* Cart page - extra spacing */
.fp-qty-discount--cart {
    margin-bottom: 30px !important;
    padding-bottom: 20px;
}

/* Override theme card styles */
.card-body .fp-qty-discount,
.cart-summary .fp-qty-discount {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

/* ========================================
   Header - Minimal
   ======================================== */

.fp-qty-discount__header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.fp-qty-discount__icon {
    font-size: 14px;
    line-height: 1;
}

.fp-qty-discount__title {
    font-weight: 600;
    font-size: 12px;
    color: #444;
    flex-grow: 1;
}

.fp-qty-discount__badge {
    background: #22c55e;
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}

.fp-qty-discount__badge--new {
    animation: pop 0.3s ease-out;
}

@keyframes pop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ========================================
   Info Tooltip
   ======================================== */

.fp-qty-discount__info {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: #e5e7eb;
    border-radius: 50%;
    font-size: 10px;
    color: #6b7280;
    cursor: help;
    margin-left: 4px;
}

.fp-qty-discount__info:hover .fp-qty-discount__tooltip {
    opacity: 1;
    visibility: visible;
}

.fp-qty-discount__tooltip {
    position: absolute;
    top: 50%;
    right: calc(100% + 10px);
    transform: translateY(-50%);
    background: #1f2937;
    color: #fff;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.5;
    width: 220px;
    text-align: left;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.fp-qty-discount__tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #1f2937;
}

/* ========================================
   Progress Bar - Thin
   ======================================== */

.fp-qty-discount__bar-wrap {
    position: relative;
    margin-bottom: 6px;
}

.fp-qty-discount__bar {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.fp-qty-discount__fill {
    height: 100%;
    background: linear-gradient(90deg, #fbbf24, #22c55e);
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* ========================================
   Tier Markers - Small
   ======================================== */

.fp-qty-discount__tiers {
    position: relative;
    height: 20px;
    margin-top: 2px;
}

.fp-qty-discount__tier {
    position: absolute;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fp-qty-discount__tier-dot {
    width: 8px;
    height: 8px;
    background: #d1d5db;
    border-radius: 50%;
    transition: all 0.2s;
}

.fp-qty-discount__tier--active .fp-qty-discount__tier-dot {
    background: #22c55e;
}

.fp-qty-discount__tier-label {
    font-size: 9px;
    font-weight: 600;
    color: #9ca3af;
    margin-top: 2px;
}

.fp-qty-discount__tier--active .fp-qty-discount__tier-label {
    color: #22c55e;
}

/* ========================================
   Message - Clean
   ======================================== */

.fp-qty-discount__message {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.4;
}

.fp-qty-discount__message strong {
    color: #16a34a;
    font-weight: 600;
}

/* ========================================
   Mini-cart - Clean without borders
   ======================================== */

/* Adjust cart products height when discount block is present (PC) */
@media (min-width: 992px) {
    .header-top__block--cart .blockcart .blockcart__dropdown .cart-dropdown__products {
        height: calc(100dvh - 270px);
        margin-top: .9375rem;
        max-height: unset;
    }
}

.cart-dropdown .fp-qty-discount,
.fp-qty-discount--minicart {
    margin: 12px 0;
    padding: 10px 12px;
    background: #f9fafb;
    border-radius: 6px;
}

.cart-dropdown .fp-qty-discount__title,
.fp-qty-discount--minicart .fp-qty-discount__title {
    font-size: 11px;
}

.cart-dropdown .fp-qty-discount__header,
.fp-qty-discount--minicart .fp-qty-discount__header {
    margin-bottom: 8px;
}

.cart-dropdown .fp-qty-discount__bar,
.fp-qty-discount--minicart .fp-qty-discount__bar {
    height: 4px;
}

.cart-dropdown .fp-qty-discount__message,
.fp-qty-discount--minicart .fp-qty-discount__message {
    font-size: 11px;
    margin-top: 8px;
}

.cart-dropdown .fp-qty-discount__tier-dot,
.fp-qty-discount--minicart .fp-qty-discount__tier-dot {
    width: 7px;
    height: 7px;
}

.cart-dropdown .fp-qty-discount__tier-label,
.fp-qty-discount--minicart .fp-qty-discount__tier-label {
    font-size: 9px;
}

.cart-dropdown .fp-qty-discount__tiers,
.fp-qty-discount--minicart .fp-qty-discount__tiers {
    height: 18px;
    margin-top: 4px;
}

/* Cart summary alignment - better spacing */
.cart-summary .fp-qty-discount {
    margin: 0 0 12px 0;
}

.cart-summary .fp-qty-discount__header {
    justify-content: space-between;
    align-items: center;
}

.cart-summary .fp-qty-discount__title {
    flex: 1;
}

/* ========================================
   Modal - Clean message (full width)
   ======================================== */

.fp-qty-discount-inject,
.fp-discount-mini {
    background: #f0fdf4;
    padding: 12px 16px;
    font-size: 13px;
    color: #166534;
    margin: 0 0 16px 0;
    width: 100%;
    box-sizing: border-box;
}

/* Modal full width fix - remove modal padding for this element */
#blockcart-modal .fp-discount-mini,
.modal .fp-discount-mini {
    margin: 0 -15px 16px -15px; /* Negative margin to extend to modal edges */
    width: calc(100% + 30px); /* Compensate for negative margins */
    border-radius: 0; /* No border radius for full width */
}

.fp-discount-mini__content {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.fp-discount-mini__icon {
    font-size: 16px;
}

.fp-discount-mini__text {
    flex: 1;
}

.fp-discount-mini__text strong {
    font-weight: 600;
}

/* Tooltip in modal */
.fp-discount-mini .fp-discount-tooltip {
    position: relative;
    display: inline-block;
    margin-left: 6px;
}

.fp-discount-mini .fp-discount-tooltip__icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    background: rgba(22, 101, 52, 0.1);
    color: #166534;
    border-radius: 50%;
    font-size: 11px;
    cursor: pointer;
    font-weight: bold;
}

.fp-discount-mini .fp-discount-tooltip__content {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #1f2937;
    color: #fff;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.5;
    width: 240px;
    max-width: calc(100vw - 40px);
    text-align: left;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.fp-discount-mini .fp-discount-tooltip__content::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 10px;
    border: 6px solid transparent;
    border-top-color: #1f2937;
}

.fp-discount-mini .fp-discount-tooltip:hover .fp-discount-tooltip__content {
    opacity: 1;
    visibility: visible;
}

.fp-discount-mini__progress {
    width: 100%;
    height: 6px;
    background: #d1fae5;
    border-radius: 3px;
    overflow: hidden;
}

.fp-discount-mini__progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    transition: width 0.3s ease;
}

/* ========================================
   Product Page - Info ABOVE add to cart (full width)
   ======================================== */

.fp-qty-discount--product {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 16px 0 12px 0;
    padding: 10px 14px;
    background: #f0fdf4;
    border-radius: 6px;
    font-size: 13px;
    color: #166534;
    width: 100%;
    box-sizing: border-box;
}

/* Product page - move wishlist/compare buttons to the right of add to cart */
.product-additional-info-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

@media (min-width: 576px) {
    /* Create a flex container that wraps both add-to-cart and additional-info */
    .product-add-to-cart + .product-additional-info {
        margin-top: 0;
    }
    
    /* Quantity row - flex container */
    .product-add-to-cart .product-quantity {
        display: flex;
        align-items: stretch;
        flex-wrap: nowrap !important;
        gap: 8px;
        margin: 0 !important;
    }
    
    /* Quantity selector - fixed width */
    .product-add-to-cart .product-quantity .qty {
        flex: 0 0 auto;
        width: auto;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Add to cart button - fill available space but reserve space for action buttons */
    .product-add-to-cart .product-quantity .add {
        flex: 1 1 auto;
        margin: 0 8px 0 0 !important; /* 8px gap between buttons */
        padding: 0 !important;
    }
    
    /* Position additional info buttons on the same line - use flexbox instead of absolute */
    .product-additional-info {
        display: flex;
        align-items: stretch;
        margin-top: -48px; /* Pull up to align with add to cart row */
        margin-left: auto;
        padding-left: 8px;
        z-index: 10;
        position: relative;
    }
    
    .product-additional-info-buttons {
        display: flex;
        gap: 8px;
        margin: 0;
        align-items: stretch;
    }
    
    .product-additional-info-buttons button {
        height: 100%; /* Match parent height (same as add to cart) */
        min-width: 48px;
        padding: 0 12px;
        margin: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .product-additional-info-buttons .cdpcp-compare-btn {
        margin: 0 !important;
    }
}

.fp-qty-discount--product .fp-qty-discount__icon {
    font-size: 16px;
    flex-shrink: 0;
}

.fp-qty-discount--product strong {
    font-weight: 600;
}

/* ========================================
   Cart page - Clean placement with separators
   ======================================== */

.cart-detailed-totals .fp-qty-discount,
.cart-summary .fp-qty-discount {
    margin: 12px 0;
    padding: 12px 0;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}

/* Hide duplicates - show only one instance */
.fp-qty-discount + .fp-qty-discount,
.checkout-step .fp-qty-discount ~ .fp-qty-discount,
.cart-grid-body .fp-qty-discount:not(:first-of-type) {
    display: none !important;
}

/* ========================================
   Cart Summary - Discount Line (with spacing)
   ======================================== */

.fp-discount-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0 20px 0;
    margin-bottom: 12px;
    font-size: 13px;
}

.fp-discount-line__label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #16a34a;
    font-weight: 500;
}

.fp-discount-line__label .fp-qty-discount__info {
    background: #dcfce7;
    color: #16a34a;
}

.fp-discount-line__value {
    color: #16a34a;
    font-weight: 600;
}

/* Spacing after discount amount in vouchers section */
.block-promo .value__inner + .value__inner,
.cart-voucher .value__inner {
    margin-bottom: 8px;
}

/* Hide duplicate "Rabat(y)" line when we have automatic discount displayed */
.fp-auto-discounts ~ .cart-summary-line#cart-subtotal-discount,
.block-promo:has(.fp-auto-discounts) ~ #cart-subtotal-discount {
    display: none;
}

/* Auto discount list style */
.fp-auto-discounts {
    margin: 0 0 20px 0;
    padding: 0;
    list-style: none;
}

.fp-auto-discounts .fp-discount-line {
    margin: 0;
    padding: 6px 0;
    border: none;
}

/* ========================================
   Checkout - Minimal (hide all progress bars and extra discount lines)
   ======================================== */

/* Hide progress bars on checkout page */
body.page-order .fp-qty-discount,
#checkout .fp-qty-discount {
    display: none !important;
}

/* Hide extra discount line with star icon on checkout */
body.page-order .fp-auto-discounts,
#checkout .fp-auto-discounts {
    display: none !important;
}

.fp-qty-discount--checkout {
    margin: 8px 0;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 767px) {
    .fp-qty-discount__message {
        font-size: 10px;
    }
    
    .fp-qty-discount__tooltip {
        width: 240px;
        max-width: calc(100vw - 40px);
        top: calc(100% + 8px);
        right: 0;
        left: auto;
        transform: none;
    }
    
    .fp-qty-discount__tooltip::after {
        top: auto;
        bottom: 100%;
        left: auto;
        right: 10px;
        transform: none;
        border-left-color: transparent;
        border-bottom-color: #1f2937;
    }
}

/* ========================================
   Discount Tooltip in Checkout Summary (Minimalist)
   ======================================== */

.fp-discount-tooltip {
    position: relative;
    display: inline-block;
    margin-left: 4px;
}

.fp-discount-tooltip__icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    font-size: 11px;
    color: #666;
    cursor: help;
    border-radius: 50%;
    background: #f0f0f0;
    transition: all 0.2s ease;
}

.fp-discount-tooltip__icon:hover {
    background: #e0e0e0;
    color: #333;
}

.fp-discount-tooltip__content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    padding: 8px 10px;
    background: #1f2937;
    color: #fff;
    font-size: 11px;
    line-height: 1.4;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.fp-discount-tooltip__content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
}

.fp-discount-tooltip:hover .fp-discount-tooltip__content {
    visibility: visible;
    opacity: 1;
}

@media (max-width: 767px) {
    .fp-discount-tooltip__content {
        width: 180px;
        font-size: 10px;
    }
}

/* ========================================
   Cart Summary - Adjust header spacing
   ======================================== */

#cart .cart-summary .card-header,
#checkout .cart-summary .card-header {
    margin-bottom: 20px !important;
}

/* ========================================
   Product Page - Reduce top margin
   ======================================== */

#product .product-add-to-cart {
    margin-top: 1rem !important;
}

/* ========================================
   Cart Dropdown - Adjust height
   ======================================== */

@media (min-width: 992px) {
    .header-top__block--cart .blockcart .blockcart__dropdown .cart-dropdown__products {
        height: calc(100dvh - 300px);
        margin-top: .9375rem;
        max-height: unset;
    }
}
