/**
 * ANSA FunnelKit Cart Enhancer - Frontend Styles
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    --ansa-primary: #2563eb;
    --ansa-success: #10b981;
    --ansa-gold: #FFB800;
    --ansa-text: #1a1a1a;
    --ansa-text-muted: #666;
    --ansa-border: #e5e5e5;
    --ansa-bg-light: #f9fafb;
}

/* ========================================
   Loading Overlay
   ======================================== */
.ansa-fkcart-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.fkcart-slider-body.ansa-loading .ansa-fkcart-loading {
    opacity: 1;
    visibility: visible;
}

.ansa-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--ansa-border);
    border-top-color: var(--ansa-primary);
    border-radius: 50%;
    animation: ansa-spin 0.7s linear infinite;
}

@keyframes ansa-spin {
    to { transform: rotate(360deg); }
}

.fkcart-slider-body {
    position: relative;
}

/* ========================================
   "Just Added" Highlight
   ======================================== */
.fkcart--item.ansa-just-added {
    animation: ansa-highlight 2.5s ease-out;
    position: relative;
}

@keyframes ansa-highlight {
    0%, 10% {
        background: linear-gradient(90deg, rgba(16, 185, 129, 0.12) 0%, transparent 100%);
    }
    100% {
        background: transparent;
    }
}

.fkcart--item.ansa-just-added::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--ansa-success);
    animation: ansa-bar-fade 2.5s ease-out forwards;
}

@keyframes ansa-bar-fade {
    0%, 60% { opacity: 1; }
    100% { opacity: 0; }
}

/* ========================================
   Reviews Section - CRITICAL STYLES
   ======================================== */
.ansa-reviews-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    padding: 20px 16px 24px !important;
    background: var(--ansa-bg-light) !important;
    border-top: 1px solid var(--ansa-border) !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    min-height: 200px !important;
}

/* Stars */
.ansa-stars-wrap {
    text-align: center;
    margin-bottom: 10px;
}

.ansa-stars {
    width: 120px;
    height: 24px;
    display: inline-block;
}

/* Title */
.ansa-reviews-title {
    text-align: center;
    font-size: 14px;
    color: var(--ansa-text-muted);
    margin-bottom: 16px;
    line-height: 1.4;
}

.ansa-reviews-title strong {
    color: var(--ansa-text);
    font-weight: 600;
}

/* Carousel Container */
.ansa-reviews-carousel {
    overflow: hidden;
    margin: 0 -16px;
    padding: 0 16px;
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, black 5%, black 95%, transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0%, black 5%, black 95%, transparent 100%);
}

/* Carousel Track - Infinite Scroll */
.ansa-reviews-track {
    display: flex;
    gap: 12px;
    animation: ansa-scroll 25s linear infinite;
    width: max-content;
}

.ansa-reviews-track:hover {
    animation-play-state: paused;
}

@keyframes ansa-scroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* Review Item Card */
.ansa-review-item {
    flex-shrink: 0;
    width: 120px;
    height: 155px;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.25s ease;
}

.ansa-review-item:hover {
    transform: scale(1.04);
}

.ansa-review-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ========================================
   Add to Cart Button States
   ======================================== */
.add_to_cart_button.ansa-adding,
.single_add_to_cart_button.ansa-adding {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.add_to_cart_button.ansa-adding::after,
.single_add_to_cart_button.ansa-adding::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 14px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ansa-spin 0.6s linear infinite;
}

.add_to_cart_button.ansa-added,
.single_add_to_cart_button.ansa-added {
    background: var(--ansa-success) !important;
    border-color: var(--ansa-success) !important;
}

/* ========================================
   FunnelKit Cart Layout Overrides
   ======================================== */

/* Make sure the cart panel can contain our section */
.fkcart-preview-ui {
    display: flex !important;
    flex-direction: column !important;
}

/* Ensure body scrolls properly */
.fkcart-slider-body {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

/* Footer stays at bottom */
.fkcart-slider-footer {
    flex-shrink: 0;
}

/* Reviews after footer */
.fkcart-preview-ui > .ansa-reviews-section {
    flex-shrink: 0;
    order: 999; /* Ensure it's last */
}

/* Hide empty state while loading */
.fkcart-slider-body.ansa-loading .fkcart-zero-state {
    opacity: 0.3;
}

/* ========================================
   Mobile Responsive
   ======================================== */
@media (max-width: 480px) {
    .ansa-reviews-section {
        padding: 16px 12px 20px !important;
    }
    
    .ansa-review-item {
        width: 100px;
        height: 130px;
    }
    
    .ansa-reviews-title {
        font-size: 13px;
    }
    
    .ansa-stars {
        width: 100px;
        height: 20px;
    }
}

/* ========================================
   Debug - Remove in production
   ======================================== */
.ansa-reviews-section[style*="display: none"] {
    display: block !important;
}
