/* ==========================================
   UI ENHANCEMENTS - Quick View, Toasts, Animations
   ========================================== */

/* ==========================================
   1. TOAST NOTIFICATIONS
   ========================================== */

.toast-stack {
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
}

.toast-notification {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 14px 18px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-width: 380px;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    border-left: 4px solid var(--toast-color, #3B82F6);
}

.toast-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-notification.hiding {
    transform: translateX(120%);
    opacity: 0;
}

.toast-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--toast-color, #3B82F6) 15%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-icon i {
    font-size: 1rem;
    color: var(--toast-color, #3B82F6);
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-message {
    font-size: 0.9rem;
    font-weight: 500;
    color: #1F2937;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #9CA3AF;
    transition: color 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    color: #374151;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--toast-color, #3B82F6);
    width: 100%;
    transform-origin: left;
    animation: toastProgress linear forwards;
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Toast types */
.toast-success { --toast-color: #059669; }
.toast-error { --toast-color: #DC2626; }
.toast-warning { --toast-color: #F59E0B; }
.toast-info { --toast-color: #3B82F6; }
.toast-cart { --toast-color: #0F4C81; }
.toast-wishlist { --toast-color: #DC2626; }

/* Mobile toast adjustments */
@media (max-width: 480px) {
    .toast-stack {
        left: 10px;
        right: 10px;
        bottom: 80px;
    }
    
    .toast-notification {
        min-width: auto;
        max-width: none;
        width: 100%;
    }
}

/* ==========================================
   2. QUICK VIEW MODAL
   ========================================== */

.quick-view-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.quick-view-modal.open {
    opacity: 1;
    visibility: visible;
}

.quick-view-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.quick-view-container {
    position: relative;
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.quick-view-modal.open .quick-view-container {
    transform: scale(1) translateY(0);
}

.quick-view-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #F3F4F6;
    border: none;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.quick-view-close:hover {
    background: #E5E7EB;
    transform: rotate(90deg);
}

.quick-view-close i {
    font-size: 1rem;
    color: #6B7280;
}

.quick-view-content {
    padding: 30px;
    max-height: 85vh;
    overflow-y: auto;
}

.quick-view-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

/* Gallery */
.quick-view-gallery {
    position: relative;
}

.quick-view-main-image {
    aspect-ratio: 1;
    border-radius: 16px;
    overflow: hidden;
    background: #F9FAFB;
}

.quick-view-main-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Info section */
.quick-view-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.quick-view-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
    line-height: 1.3;
}

.quick-view-rating {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-view-rating i {
    font-size: 0.9rem;
}

.quick-view-rating .rating-count {
    color: #6B7280;
    font-size: 0.85rem;
}

.quick-view-price {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.quick-view-price .current-price {
    font-size: 1.75rem;
    font-weight: 800;
    color: #0F4C81;
}

.quick-view-price .original-price {
    font-size: 1.1rem;
    color: #9CA3AF;
    text-decoration: line-through;
}

.quick-view-price .discount-badge {
    background: linear-gradient(135deg, #DC2626, #B91C1C);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

.quick-view-description {
    color: #6B7280;
    font-size: 0.95rem;
    line-height: 1.6;
}

.quick-view-description p {
    margin: 0;
}

.quick-view-stock {
    font-size: 0.9rem;
    font-weight: 600;
}

.quick-view-stock .in-stock {
    color: #059669;
}

.quick-view-stock .low-stock {
    color: #F59E0B;
}

.quick-view-stock .out-of-stock {
    color: #DC2626;
}

/* Quantity selector */
.quick-view-quantity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quick-view-quantity label {
    font-weight: 600;
    color: #374151;
}

.quantity-selector {
    display: flex;
    align-items: center;
    border: 2px solid #E5E7EB;
    border-radius: 10px;
    overflow: hidden;
}

.quantity-selector .qty-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: #F9FAFB;
    font-size: 1.2rem;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.quantity-selector .qty-btn:hover {
    background: #E5E7EB;
}

.quantity-selector input {
    width: 60px;
    height: 40px;
    border: none;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
}

.quantity-selector input:focus {
    outline: none;
}

/* Actions */
.quick-view-actions {
    display: flex;
    gap: 12px;
}

.quick-view-actions .btn-add-to-cart {
    flex: 1;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 12px;
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    border: none;
    color: white;
    transition: all 0.3s;
}

.quick-view-actions .btn-add-to-cart:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4);
}

.quick-view-actions .btn-add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.quick-view-actions .btn-wishlist {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.quick-view-actions .btn-wishlist.active {
    background: #DC2626;
    border-color: #DC2626;
    color: white;
}

.quick-view-details-link {
    display: inline-flex;
    align-items: center;
    color: #0F4C81;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.quick-view-details-link:hover {
    color: #1A6BB3;
}

.quick-view-details-link i {
    transition: transform 0.2s;
}

.quick-view-details-link:hover i {
    transform: translateX(4px);
}

/* Mobile quick view */
@media (max-width: 768px) {
    .quick-view-container {
        width: 95%;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        position: fixed;
        bottom: 0;
        transform: translateY(100%);
    }
    
    .quick-view-modal.open .quick-view-container {
        transform: translateY(0);
    }
    
    .quick-view-content {
        padding: 20px;
    }
    
    .quick-view-title {
        font-size: 1.25rem;
    }
    
    .quick-view-price .current-price {
        font-size: 1.5rem;
    }
    
    .quick-view-actions {
        flex-direction: column;
    }
    
    .quick-view-actions .btn-wishlist {
        width: 100%;
        height: 50px;
    }
}

/* ==========================================
   3. SMOOTH ANIMATIONS
   ========================================== */

/* Fade in animation */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease-out;
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger animation for grids */
.animate-stagger > * {
    opacity: 0;
    transform: translateY(20px);
    animation: staggerFadeIn 0.5s ease-out forwards;
}

.animate-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.animate-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.animate-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.animate-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.animate-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.animate-stagger > *:nth-child(6) { animation-delay: 0.3s; }
.animate-stagger > *:nth-child(7) { animation-delay: 0.35s; }
.animate-stagger > *:nth-child(8) { animation-delay: 0.4s; }

@keyframes staggerFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ripple effect */
.btn, .wishlist-btn {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    pointer-events: none;
    width: 100px;
    height: 100px;
    margin-left: -50px;
    margin-top: -50px;
}

.ripple.animate {
    animation: rippleEffect 0.6s ease-out;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Touch feedback */
.touch-active {
    transform: scale(0.97) !important;
    opacity: 0.9;
}

/* Image lazy loading */
.lazy-image {
    filter: blur(10px);
    transition: filter 0.5s ease;
}

.lazy-image.loaded {
    filter: blur(0);
}

/* ==========================================
   4. ENHANCED PRODUCT CARD TRANSITIONS
   ========================================== */

.product-card {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
}

.product-card .img-wrap {
    overflow: hidden;
}

.product-card .img-wrap img {
    transition: transform 0.5s ease;
}

.product-card:hover .img-wrap img {
    transform: scale(1.08);
}

/* Card content fade on hover */
.product-card .card-body {
    transition: all 0.3s ease;
}

.product-card:hover .card-body {
    background: linear-gradient(to top, rgba(255,255,255,1) 0%, rgba(255,255,255,0.95) 100%);
}

/* Price bounce animation on hover */
.product-card:hover .price-main {
    animation: priceBounce 0.4s ease;
}

@keyframes priceBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ==========================================
   5. MOBILE-FIRST ENHANCEMENTS
   ========================================== */

/* Safe area padding for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
    
    .scroll-to-top {
        bottom: calc(90px + env(safe-area-inset-bottom));
    }
    
    .toast-stack {
        bottom: calc(100px + env(safe-area-inset-bottom));
    }
    
    .quick-view-container {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Larger touch targets on mobile */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .wishlist-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Disable hover effects on touch devices */
    @media (hover: none) {
        .product-card:hover {
            transform: none;
            box-shadow: none;
        }
        
        .product-card:hover .img-wrap img {
            transform: none;
        }
        
        .product-card:active {
            transform: scale(0.98);
        }
    }
}

/* Smooth scrolling for all */
html {
    scroll-behavior: smooth;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* ==========================================
   6. LOADING STATES
   ========================================== */

.skeleton-loader {
    background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text.short {
    width: 40%;
}

.skeleton-text.medium {
    width: 70%;
}

.skeleton-image {
    aspect-ratio: 1;
}

/* ==========================================
   7. FOCUS STATES FOR ACCESSIBILITY
   ========================================== */

*:focus-visible {
    outline: 3px solid #3B82F6;
    outline-offset: 2px;
}

.btn:focus-visible {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3);
}

/* ==========================================
   8. BODY SCROLL LOCK FOR MODALS
   ========================================== */

body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

