/**
 * Frontend UI Enhancements
 * Modern animations, micro-interactions, and visual improvements
 * Fully compatible with theming system (uses CSS variables)
 * Version: 2.0.2
 */

/* ==============================================
   SMOOTH SCROLL & BASE ANIMATIONS
   ============================================== */

html {
    scroll-behavior: smooth;
}

body {
    transition: background-color 0.3s ease;
}

/* ==============================================
   ADVANCED ANIMATIONS & KEYFRAMES
   ============================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* ==============================================
   SCROLL REVEAL ANIMATIONS
   ============================================== */

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* ==============================================
   CARD ENHANCEMENTS
   ============================================== */

.card-hover {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card-hover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(var(--theme-primary-rgb), 0.05), rgba(var(--theme-secondary-rgb), 0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.card-hover:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

.card-hover:hover::before {
    opacity: 1;
}

/* Card shimmer effect on load */
.card-shimmer {
    position: relative;
    overflow: hidden;
}

.card-shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

/* ==============================================
   BUTTON ENHANCEMENTS
   ============================================== */

.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:active {
    transform: scale(0.98);
}

/* Floating button effect */
.btn-float {
    animation: float 3s ease-in-out infinite;
}

/* Pulse button for CTAs */
.btn-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ==============================================
   IMAGE ENHANCEMENTS
   ============================================== */

.img-hover-zoom {
    overflow: hidden;
    border-radius: var(--border-radius, 8px);
}

.img-hover-zoom img {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.img-hover-zoom:hover img {
    transform: scale(1.1);
}

/* Image overlay effect */
.img-overlay {
    position: relative;
    overflow: hidden;
}

.img-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.3));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.img-overlay:hover::after {
    opacity: 1;
}

/* ==============================================
   GRADIENT OVERLAYS
   ============================================== */

.gradient-overlay {
    position: relative;
}

.gradient-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-secondary));
    opacity: 0.9;
    z-index: 1;
}

.gradient-overlay > * {
    position: relative;
    z-index: 2;
}

/* Animated gradient */
.gradient-animated {
    background: linear-gradient(
        -45deg,
        var(--theme-primary),
        var(--theme-secondary),
        var(--theme-accent),
        var(--theme-primary)
    );
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ==============================================
   LOADING STATES
   ============================================== */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--border-radius, 8px);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(var(--theme-primary-rgb), 0.2);
    border-top-color: var(--theme-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==============================================
   BADGES & LABELS
   ============================================== */

.badge-floating {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    animation: bounce 2s ease-in-out infinite;
}

.badge-glow {
    box-shadow: 0 0 20px rgba(var(--theme-primary-rgb), 0.6);
}

/* ==============================================
   SECTION DECORATIONS
   ============================================== */

.section-pattern {
    position: relative;
}

.section-pattern::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.03;
    background-image:
        repeating-linear-gradient(45deg, transparent, transparent 10px, currentColor 10px, currentColor 11px),
        repeating-linear-gradient(-45deg, transparent, transparent 10px, currentColor 10px, currentColor 11px);
    pointer-events: none;
}

/* Decorative shapes */
.shape-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.15;
    pointer-events: none;
    animation: float 6s ease-in-out infinite;
}

.shape-blob-1 {
    width: 400px;
    height: 400px;
    background: var(--theme-primary);
    top: -200px;
    right: -200px;
}

.shape-blob-2 {
    width: 300px;
    height: 300px;
    background: var(--theme-secondary);
    bottom: -150px;
    left: -150px;
    animation-delay: 2s;
}

/* ==============================================
   TEXT EFFECTS
   ============================================== */

.text-gradient {
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-shadow-soft {
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.text-shadow-strong {
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ==============================================
   HOVER UNDERLINE EFFECTS
   ============================================== */

.hover-underline {
    position: relative;
    text-decoration: none;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--theme-primary);
    transition: width 0.3s ease;
}

.hover-underline:hover::after {
    width: 100%;
}

/* ==============================================
   BACKDROP EFFECTS
   ============================================== */

.backdrop-blur {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.9);
}

.backdrop-blur-dark {
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.5);
}

/* ==============================================
   INTERACTIVE STATS
   ============================================== */

.stat-counter {
    font-variant-numeric: tabular-nums;
    transition: all 0.3s ease;
}

.stat-counter:hover {
    transform: scale(1.1);
    color: var(--theme-primary);
}

/* ==============================================
   BREADCRUMB ENHANCEMENTS
   ============================================== */

.breadcrumbs a {
    position: relative;
    transition: color 0.3s ease;
}

.breadcrumbs a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--theme-primary);
    transition: width 0.3s ease;
}

.breadcrumbs a:hover::after {
    width: 100%;
}

/* ==============================================
   PRODUCT CARD ENHANCEMENTS
   ============================================== */

/* Product badge styling moved to product-layouts.css */

.product-badge-text {
    position: absolute;
    top: 10px;
    right: -20px;
    transform: rotate(45deg);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 10;
}

/* ==============================================
   FILTER CHIPS
   ============================================== */

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(var(--theme-primary-rgb), 0.1);
    color: var(--theme-primary);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.filter-chip:hover {
    background: rgba(var(--theme-primary-rgb), 0.2);
    transform: translateY(-2px);
}

.filter-chip.active {
    background: var(--theme-primary);
    color: white;
}

/* ==============================================
   TOOLTIP
   ============================================== */

[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 0.875rem;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
}

[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==============================================
   SCROLLBAR STYLING
   ============================================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: rgba(var(--theme-primary-rgb), 0.3);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--theme-primary-rgb), 0.5);
}

/* ==============================================
   PROGRESS BAR
   ============================================== */

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(var(--theme-primary-rgb), 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--theme-primary), var(--theme-secondary));
    border-radius: 2px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 1.5s infinite;
}

/* ==============================================
   PARALLAX EFFECT
   ============================================== */

.parallax-slow {
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ==============================================
   GLASSMORPHISM
   ============================================== */

.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.glass-dark {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==============================================
   RESPONSIVE OPTIMIZATIONS
   ============================================== */

@media (max-width: 768px) {
    .card-hover:hover {
        transform: translateY(-4px);
    }

    .shape-blob {
        display: none;
    }

    [data-tooltip]::before {
        display: none;
    }
}

/* ==============================================
   REDUCED MOTION PREFERENCE
   ============================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==============================================
   PRINT OPTIMIZATIONS
   ============================================== */

@media print {
    .card-hover,
    .btn,
    .badge-floating {
        animation: none;
        transform: none;
        box-shadow: none;
    }
}
