/**
 * Frontend Styles for WC Promotions Manager
 * Modern UI with animations and transitions
 */

/* CSS Custom Properties for easy theming */
:root {
    --wcpm-badge-size: 70px;
    --wcpm-badge-size-lg: 90px;
    --wcpm-transition-fast: 0.2s;
    --wcpm-transition-normal: 0.3s;
    --wcpm-transition-slow: 0.5s;
    --wcpm-shadow-soft: 0 4px 15px rgba(0, 0, 0, 0.15);
    --wcpm-shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.2);
    --wcpm-shadow-glow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* Product Badges - Enhanced with modern effects */
.wcpm-product-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--wcpm-badge-size);
    min-height: var(--wcpm-badge-size);
    padding: 10px;
    border-radius: 50%;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #fff;
    text-align: center;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    line-height: 1.1;
    box-shadow: var(--wcpm-shadow-medium),
                0 0 0 3px rgba(255, 255, 255, 0.15) inset,
                0 -2px 6px rgba(0, 0, 0, 0.1) inset;
    transition: all var(--wcpm-transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    backface-visibility: hidden;
    will-change: transform, box-shadow;
    
    /* Entrance animation */
    animation: wcpm-badge-entrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Entrance Animation */
@keyframes wcpm-badge-entrance {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-20deg);
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* Hover Effects */
.wcpm-product-badge:hover {
    transform: scale(1.12) translateY(-3px);
    box-shadow: var(--wcpm-shadow-medium),
                0 12px 35px rgba(0, 0, 0, 0.25),
                0 0 0 3px rgba(255, 255, 255, 0.2) inset,
                var(--wcpm-shadow-glow);
}

/* Shimmer Effect Overlay */
.wcpm-product-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    border-radius: inherit;
    transition: left 0.6s ease;
}

.wcpm-product-badge:hover::before {
    left: 100%;
}

/* Subtle floating animation for all badges */
@keyframes wcpm-float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

.wcpm-product-badge {
    animation: wcpm-badge-entrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               wcpm-float 3s ease-in-out 0.6s infinite;
}

/* Badge Types with enhanced gradients and effects */
.wcpm-badge-percentage {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 50%, #dc3545 100%);
    font-size: 17px;
    box-shadow: var(--wcpm-shadow-medium),
                0 0 30px rgba(238, 90, 82, 0.4),
                0 0 0 3px rgba(255, 255, 255, 0.15) inset;
}

.wcpm-badge-percentage:hover {
    box-shadow: var(--wcpm-shadow-medium),
                0 0 40px rgba(238, 90, 82, 0.6),
                0 0 0 3px rgba(255, 255, 255, 0.2) inset;
}

.wcpm-badge-n-plus-m {
    background: linear-gradient(135deg, #51cf66 0%, #40c057 50%, #2f9e44 100%);
    box-shadow: var(--wcpm-shadow-medium),
                0 0 30px rgba(81, 207, 102, 0.4),
                0 0 0 3px rgba(255, 255, 255, 0.15) inset;
}

.wcpm-badge-n-plus-m:hover {
    box-shadow: var(--wcpm-shadow-medium),
                0 0 40px rgba(81, 207, 102, 0.6),
                0 0 0 3px rgba(255, 255, 255, 0.2) inset;
}

.wcpm-badge-n-for-m {
    background: linear-gradient(135deg, #4dabf7 0%, #339af0 50%, #228be6 100%);
    box-shadow: var(--wcpm-shadow-medium),
                0 0 30px rgba(51, 154, 240, 0.4),
                0 0 0 3px rgba(255, 255, 255, 0.15) inset;
}

.wcpm-badge-n-for-m:hover {
    box-shadow: var(--wcpm-shadow-medium),
                0 0 40px rgba(51, 154, 240, 0.6),
                0 0 0 3px rgba(255, 255, 255, 0.2) inset;
}

.wcpm-badge-buy-x-get-y {
    background: linear-gradient(135deg, #ffa94d 0%, #ff922b 50%, #f76707 100%);
    box-shadow: var(--wcpm-shadow-medium),
                0 0 30px rgba(255, 146, 43, 0.4),
                0 0 0 3px rgba(255, 255, 255, 0.15) inset;
}

.wcpm-badge-buy-x-get-y:hover {
    box-shadow: var(--wcpm-shadow-medium),
                0 0 40px rgba(255, 146, 43, 0.6),
                0 0 0 3px rgba(255, 255, 255, 0.2) inset;
}

.wcpm-badge-custom {
    background: linear-gradient(135deg, #b197fc 0%, #9775fa 50%, #7950f2 100%);
    box-shadow: var(--wcpm-shadow-medium),
                0 0 30px rgba(151, 117, 250, 0.4),
                0 0 0 3px rgba(255, 255, 255, 0.15) inset;
}

.wcpm-badge-custom:hover {
    box-shadow: var(--wcpm-shadow-medium),
                0 0 40px rgba(151, 117, 250, 0.6),
                0 0 0 3px rgba(255, 255, 255, 0.2) inset;
}

/* Single Product Badge Wrapper - Positioned inside product gallery */
.wcpm-single-product-badge-wrapper {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

/* For themes where the gallery doesn't have position relative */
.single-product .woocommerce-product-gallery {
    position: relative;
}

/* Single Product Badge - Larger with enhanced effects */
.single-product .wcpm-product-badge {
    position: relative;
    top: auto;
    left: auto;
    min-width: var(--wcpm-badge-size-lg);
    min-height: var(--wcpm-badge-size-lg);
    font-size: 20px;
    letter-spacing: 1px;
    animation: wcpm-badge-entrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               wcpm-float 3s ease-in-out 0.6s infinite,
               wcpm-glow 2s ease-in-out infinite;
}

/* Glow animation for single product badge */
@keyframes wcpm-glow {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.1);
    }
}

/* Promotion description below badge on single product - Glass morphism style */
.wcpm-single-product-badge-wrapper .wcpm-promotion-description {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 16px;
    border-radius: 12px;
    margin-top: 0;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    max-width: 220px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1),
                0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transform: translateY(0);
    transition: all var(--wcpm-transition-normal) ease;
    animation: wcpm-description-slide 0.5s ease 0.3s forwards;
    opacity: 0;
}

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

.wcpm-single-product-badge-wrapper .wcpm-promotion-description:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15),
                0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}

.wcpm-single-product-badge-wrapper .wcpm-promotion-description strong {
    color: #2f9e44;
    font-weight: 700;
}

/* Promotion label prefix */
.wcpm-single-product-badge-wrapper .wcpm-promotion-description::before {
    content: '✨ ';
}

/* Cart Promotion Labels - Enhanced with modern styling */
.wcpm-cart-promo-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin-left: 8px;
    background: linear-gradient(135deg, #51cf66 0%, #40c057 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    border-radius: 20px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(64, 192, 87, 0.3);
    transition: all var(--wcpm-transition-fast) ease;
    animation: wcpm-label-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes wcpm-label-pop {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.wcpm-cart-promo-label:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(64, 192, 87, 0.4);
}

/* Cart Item Price Styling */
.woocommerce-cart .wcpm-cart-promo-label {
    margin-left: 0;
    margin-top: 6px;
    display: inline-flex;
}

/* Mini Cart */
.widget_shopping_cart .wcpm-cart-promo-label {
    font-size: 9px;
    padding: 2px 8px;
    margin-left: 4px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    :root {
        --wcpm-badge-size: 55px;
        --wcpm-badge-size-lg: 70px;
    }

    .wcpm-product-badge {
        min-width: var(--wcpm-badge-size);
        min-height: var(--wcpm-badge-size);
        font-size: 12px;
        top: 8px;
        left: 8px;
        padding: 8px;
    }

    .wcpm-single-product-badge-wrapper {
        top: 8px;
        left: 8px;
        gap: 8px;
    }

    .single-product .wcpm-product-badge {
        min-width: var(--wcpm-badge-size-lg);
        min-height: var(--wcpm-badge-size-lg);
        font-size: 16px;
    }

    .wcpm-single-product-badge-wrapper .wcpm-promotion-description {
        max-width: 160px;
        font-size: 11px;
        padding: 8px 12px;
        border-radius: 10px;
    }

    .wcpm-cart-promo-label {
        font-size: 9px;
        padding: 3px 8px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    :root {
        --wcpm-badge-size: 50px;
        --wcpm-badge-size-lg: 60px;
    }

    .wcpm-product-badge {
        font-size: 11px;
        top: 5px;
        left: 5px;
    }

    .single-product .wcpm-product-badge {
        font-size: 14px;
    }

    .wcpm-single-product-badge-wrapper .wcpm-promotion-description {
        max-width: 140px;
        font-size: 10px;
    }
}

/* High Discount Emphasis - Enhanced with attention-grabbing animation */
.wcpm-badge-percentage[data-discount-high="true"] {
    background: linear-gradient(135deg, #ff4757 0%, #d63031 50%, #c0392b 100%);
    animation: wcpm-badge-entrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               wcpm-attention 1.5s ease-in-out 0.6s infinite;
    box-shadow: var(--wcpm-shadow-medium),
                0 0 40px rgba(214, 48, 49, 0.5),
                0 0 0 3px rgba(255, 255, 255, 0.15) inset;
}

@keyframes wcpm-attention {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    25% {
        transform: scale(1.08);
        filter: brightness(1.15);
    }
    50% {
        transform: scale(1);
        filter: brightness(1);
    }
    75% {
        transform: scale(1.05);
        filter: brightness(1.1);
    }
}

/* Accessibility */
.wcpm-product-badge .screen-reader-text {
    position: absolute;
    left: -9999px;
}

/* Cart Price Display - Enhanced */
.wcpm-original-price {
    color: #adb5bd;
    font-size: 0.9em;
    text-decoration: line-through;
    opacity: 0.8;
}

.wcpm-promo-price {
    color: #2f9e44;
    font-weight: 700;
    font-size: 1.05em;
    position: relative;
}

/* Cart Savings Display - Enhanced with animation */
.wcpm-savings {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #2f9e44;
    font-weight: 600;
    margin-top: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(47, 158, 68, 0.1), rgba(47, 158, 68, 0.05));
    border-radius: 16px;
    font-size: 12px;
    animation: wcpm-savings-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes wcpm-savings-pop {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.wcpm-savings::before {
    content: '💰';
    font-size: 11px;
}

.wcpm-savings .woocommerce-Price-amount {
    color: #2f9e44;
    font-weight: 700;
}

/* Active Promotions Notice in Cart - Enhanced */
.wcpm-cart-promotions-notice td {
    background: linear-gradient(135deg, rgba(47, 158, 68, 0.08), rgba(47, 158, 68, 0.03));
    border-bottom: 1px solid rgba(47, 158, 68, 0.15);
    border-left: 3px solid #2f9e44;
}

.wcpm-active-promotions {
    padding: 14px 18px;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wcpm-active-promotions::before {
    content: '🎉';
}

.wcpm-active-promotions strong {
    color: #2f9e44;
    font-weight: 700;
}

/* Cart Item Row with Promotion - Enhanced */
.woocommerce-cart-form__cart-item.has-wcpm-promotion {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.06), rgba(76, 175, 80, 0.02));
    position: relative;
}

.woocommerce-cart-form__cart-item.has-wcpm-promotion::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, #51cf66, #2f9e44);
    border-radius: 0 2px 2px 0;
}

/* Checkout Page Promo Labels */
.woocommerce-checkout .wcpm-cart-promo-label {
    margin-left: 8px;
    font-size: 10px;
}

/* Order Review Table */
.woocommerce-checkout-review-order .wcpm-original-price,
.woocommerce-checkout-review-order .wcpm-promo-price {
    font-size: 0.85em;
}

/* FREE Gift Label - Enhanced */
.wcpm-cart-promo-label.wcpm-free-gift {
    background: linear-gradient(135deg, #ffa94d 0%, #ff922b 50%, #f76707 100%);
    box-shadow: 0 2px 8px rgba(255, 146, 43, 0.3);
}

.wcpm-cart-promo-label.wcpm-free-gift::before {
    content: '🎁 ';
    font-size: 10px;
}

/* Promo Badge Colors in Cart - Enhanced with matching shadows */
.wcpm-cart-promo-label.wcpm-label-n_plus_m {
    background: linear-gradient(135deg, #51cf66 0%, #40c057 100%);
    box-shadow: 0 2px 8px rgba(81, 207, 102, 0.3);
}

.wcpm-cart-promo-label.wcpm-label-n_for_m {
    background: linear-gradient(135deg, #4dabf7 0%, #339af0 100%);
    box-shadow: 0 2px 8px rgba(51, 154, 240, 0.3);
}

.wcpm-cart-promo-label.wcpm-label-percentage {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    box-shadow: 0 2px 8px rgba(238, 90, 82, 0.3);
}

.wcpm-cart-promo-label.wcpm-label-buy_x_get_y {
    background: linear-gradient(135deg, #ffa94d 0%, #ff922b 100%);
    box-shadow: 0 2px 8px rgba(255, 146, 43, 0.3);
}

/* Mini Cart Savings - Enhanced */
.widget_shopping_cart .wcpm-savings {
    font-size: 10px;
    margin-top: 4px;
    padding: 2px 8px;
}

.widget_shopping_cart .wcpm-savings::before {
    content: '✓ ';
    font-size: 9px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .wcpm-product-badge,
    .wcpm-cart-promo-label,
    .wcpm-savings,
    .wcpm-single-product-badge-wrapper .wcpm-promotion-description {
        animation: none !important;
        transition: none !important;
    }
}

/* Dark mode support (for themes with dark mode) */
@media (prefers-color-scheme: dark) {
    .wcpm-single-product-badge-wrapper .wcpm-promotion-description {
        background: rgba(30, 30, 30, 0.9);
        color: #f1f3f5;
        border-color: rgba(255, 255, 255, 0.1);
    }

    .wcpm-single-product-badge-wrapper .wcpm-promotion-description strong {
        color: #69db7c;
    }

    .wcpm-savings {
        background: linear-gradient(135deg, rgba(105, 219, 124, 0.15), rgba(105, 219, 124, 0.08));
        color: #69db7c;
    }
}

/* Print Styles - Enhanced */
@media print {
    .wcpm-product-badge {
        box-shadow: none !important;
        border: 2px solid currentColor;
        animation: none !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .wcpm-cart-promo-label {
        background: transparent !important;
        color: #333;
        border: 1px solid #333;
        box-shadow: none !important;
        animation: none !important;
    }

    .wcpm-savings {
        background: transparent !important;
        border: 1px solid #2f9e44;
    }

    .wcpm-savings::before,
    .wcpm-active-promotions::before,
    .wcpm-single-product-badge-wrapper .wcpm-promotion-description::before,
    .wcpm-cart-promo-label.wcpm-free-gift::before {
        content: '' !important;
    }
}
