/**
 * Lagniappe Frontend Styles
 */

/* Prevent scrolling when modal is open */
body.lagniappe-modal-open {
    overflow: hidden;
}

/* Modal Container */
.lagniappe-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal Overlay */
.lagniappe-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
}

/* Modal Content */
.lagniappe-modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: lagniappeModalSlideIn 0.3s ease-out;
}

@keyframes lagniappeModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Close Button */
.lagniappe-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 5px 10px;
    z-index: 10;
    transition: all 0.2s;
}

.lagniappe-modal-close:hover {
    color: #000;
    transform: rotate(90deg);
}

/* Modal Header */
.lagniappe-modal-header {
    padding: 30px 30px 20px;
    border-bottom: 2px solid #f0f0f0;
    background: linear-gradient(135deg, #FA4D8D 0%, #D4147F 100%);
    color: #fff;
}

.lagniappe-modal-title {
    margin: 0 0 10px;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
}

.lagniappe-modal-description {
    margin: 0;
    font-size: 16px;
    opacity: 0.95;
    line-height: 1.5;
}

/* Modal Body */
.lagniappe-modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

/* Budget Display */
.lagniappe-budget-info {
    background: #f0f9ff;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
    text-align: center;
}

.lagniappe-budget-display {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.lagniappe-budget-label {
    color: #667eea;
    margin-right: 8px;
}

.lagniappe-budget-used {
    color: #27ae60;
    font-weight: 700;
}

.lagniappe-budget-separator {
    margin: 0 8px;
    color: #999;
}

.lagniappe-budget-limit {
    color: #667eea;
    font-weight: 700;
}

.lagniappe-budget-remaining {
    color: #666;
    font-size: 14px;
    margin-left: 8px;
    font-weight: normal;
}

/* Next Tier Notice */
.lagniappe-next-tier-notice {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    padding: 15px 20px;
    border-radius: 6px;
    margin-top: 20px;
    text-align: center;
    font-size: 14px;
    animation: fadeIn 0.5s;
}

.lagniappe-next-tier-highlight {
    font-weight: 700;
}

/* Loading State */
.lagniappe-loading {
    text-align: center;
    padding: 40px 20px;
}

.lagniappe-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f0f0f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: lagniappeSpin 1s linear infinite;
}

@keyframes lagniappeSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.lagniappe-loading p {
    color: #666;
    font-size: 16px;
}

/* Products Grid */
.lagniappe-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin: 0;
}

@media (max-width: 768px) {
    .lagniappe-products-grid {
        grid-template-columns: 1fr;
    }
}

/* Product Card */
.lagniappe-product-card {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s;
    cursor: pointer;
    max-height: 280px;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.lagniappe-product-card:hover {
    border-color: #667eea;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.15);
    transform: translateY(-3px);
}

.lagniappe-product-card.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.lagniappe-product-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.lagniappe-product-card.disabled .lagniappe-product-select-btn {
    background: #ccc;
    cursor: not-allowed;
}

/* Product Image */
.lagniappe-product-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lagniappe-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lagniappe-no-image {
    color: #999;
    font-size: 14px;
}

/* Product Details */
.lagniappe-product-details {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.lagniappe-product-name {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.lagniappe-product-description {
    margin: 0 0 12px;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    flex: 1;
}

/* Product Pricing */
.lagniappe-product-pricing {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.lagniappe-product-price-regular {
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

.lagniappe-product-price-free {
    font-size: 18px;
    font-weight: 700;
    color: #27ae60;
    letter-spacing: 0.5px;
    font-style: italic;
}

/* Select Button */
.lagniappe-product-select-btn {
    width: 100%;
    padding: 10px 20px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.lagniappe-product-select-btn:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.lagniappe-product-select-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.lagniappe-product-select-btn.success {
    background: #27ae60;
}

/* Modal Footer */
.lagniappe-modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    text-align: right;
    background: #f9f9f9;
}

.lagniappe-modal-cancel {
    background: #fff;
    border: 1px solid #ddd;
    color: #666;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.lagniappe-modal-cancel:hover {
    background: #f5f5f5;
    border-color: #999;
    color: #333;
}

/* Error State */
.lagniappe-error {
    text-align: center;
    padding: 40px 20px;
}

.lagniappe-error-message {
    color: #e74c3c;
    font-size: 16px;
    margin: 0;
}

/* Success Notice */
.lagniappe-success-notice {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.lagniappe-success-notice p {
    margin: 0;
}

/* Cart Badge */
.lagniappe-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 8px;
    box-shadow: 0 2px 5px rgba(102, 126, 234, 0.3);
}

/* Cart Free Text */
.lagniappe-free-text {
    display: inline-block;
    color: #27ae60;
    font-weight: 700;
    font-size: 13px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Cart Item Customizations */
.lagniappe-quantity-fixed {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.lagniappe-quantity-fixed input[type="number"] {
    width: 50px !important;
    text-align: center;
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    cursor: not-allowed !important;
    opacity: 0.7;
}

/* Aggressive quantity field locking for lagniappe items */
.lagniappe-cart-item input.qty,
.lagniappe-cart-item input[type="number"],
.lagniappe-cart-item .quantity input {
    pointer-events: none !important;
    background: #f5f5f5 !important;
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    user-select: none !important;
}

/* Hide ALL quantity controls for lagniappe */
.lagniappe-cart-item .quantity .plus,
.lagniappe-cart-item .quantity .minus,
.lagniappe-cart-item .quantity button,
.lagniappe-cart-item .quantity .qty-btn,
.lagniappe-cart-item .plus,
.lagniappe-cart-item .minus,
.lagniappe-cart-item button.plus,
.lagniappe-cart-item button.minus,
.lagniappe-cart-item a.plus,
.lagniappe-cart-item a.minus {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* Style the quantity badge */
.lagniappe-qty-badge {
    display: inline-block !important;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Style the FREE badge in price columns */
.lagniappe-free-badge {
    display: inline-block !important;
    padding: 6px 14px;
    background: #27ae60;
    color: white;
    border-radius: 4px;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.lagniappe-qty-note {
    color: #667eea;
    font-size: 12px;
    font-weight: 600;
}

.lagniappe-permanent {
    color: #27ae60;
    font-weight: 600;
    font-size: 12px;
}

/* Hide WooCommerce sale/discount badges and text for lagniappe items */
.lagniappe-cart-item .woocommerce-Price-amount,
.lagniappe-cart-item ins,
.lagniappe-cart-item del,
.lagniappe-cart-item .woocommerce-Price-currencySymbol {
    display: none !important;
}

/* Ensure FREE text is visible */
.lagniappe-cart-item .lagniappe-free-price {
    display: inline-block !important;
    font-size: 16px !important;
}

/* Open Modal Button */
.lagniappe-open-modal {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.lagniappe-open-modal:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Highlight lagniappe cart row */
.woocommerce-cart-form__cart-item.lagniappe-cart-item,
.cart_item.lagniappe-cart-item {
    background-color: #f0f9ff !important;
    border-left: 4px solid #667eea !important;
}

.woocommerce table.shop_table tbody tr.lagniappe-cart-item td {
    background-color: #f0f9ff !important;
}

/* Additional styling for lagniappe items in cart */
.woocommerce .cart_item.lagniappe-cart-item .product-name,
.woocommerce-cart .cart_item.lagniappe-cart-item td.product-name {
    font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .lagniappe-modal-content {
        width: 95%;
        max-height: 90vh;
        border-radius: 8px;
    }

    .lagniappe-modal-header {
        padding: 20px;
    }

    .lagniappe-modal-title {
        font-size: 22px;
    }

    .lagniappe-modal-description {
        font-size: 14px;
    }

    .lagniappe-modal-body {
        padding: 20px;
    }

    .lagniappe-product-image {
        height: 150px;
    }

    .lagniappe-badge {
        font-size: 10px;
        padding: 3px 8px;
    }

    .lagniappe-free-text {
        font-size: 11px;
    }
}