/**
 * Trade Premium Animations
 * Adds scroll reveal, hover glow, skeleton loading,
 * gradient borders, button micro-interactions, and counter effects.
 */

/* ============================================================
   1. SMOOTH THEME TRANSITION (enhanced)
   ============================================================ */
html {
    transition: background-color 0.4s ease, color 0.4s ease;
}

body,
.navbar,
.card,
.card-header,
.card-body,
.modal-content,
.dropdown-menu,
.table,
.form-control,
.btn {
    transition: background-color 0.35s ease,
                color 0.35s ease,
                border-color 0.35s ease,
                box-shadow 0.35s ease,
                transform 0.25s ease;
}


/* ============================================================
   2. SCROLL REVEAL — Fade-in on scroll
   ============================================================ */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.7s cubic-bezier(0.23, 1, 0.32, 1);
}

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

/* Staggered delay for children */
.reveal-stagger > .reveal:nth-child(1) { transition-delay: 0.05s; }
.reveal-stagger > .reveal:nth-child(2) { transition-delay: 0.1s; }
.reveal-stagger > .reveal:nth-child(3) { transition-delay: 0.15s; }
.reveal-stagger > .reveal:nth-child(4) { transition-delay: 0.2s; }
.reveal-stagger > .reveal:nth-child(5) { transition-delay: 0.25s; }
.reveal-stagger > .reveal:nth-child(6) { transition-delay: 0.3s; }

/* Slide from left */
.reveal-left {
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.7s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.7s cubic-bezier(0.23, 1, 0.32, 1);
}
.reveal-left.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* Slide from right */
.reveal-right {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.7s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.7s cubic-bezier(0.23, 1, 0.32, 1);
}
.reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* Scale up */
.reveal-scale {
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}
.reveal-scale.revealed {
    opacity: 1;
    transform: scale(1);
}


/* ============================================================
   3. HOVER GLOW — Premium card glow on hover
   ============================================================ */
.glow-card {
    position: relative;
    transition: box-shadow 0.4s ease, transform 0.3s ease;
}

.glow-card:hover {
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.15),
                0 10px 40px rgba(0, 0, 0, 0.08);
    transform: translateY(-4px);
}

[data-theme="dark"] .glow-card:hover {
    box-shadow: 0 0 35px rgba(59, 130, 246, 0.2),
                0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Success glow variant */
.glow-success:hover {
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.15),
                0 10px 40px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .glow-success:hover {
    box-shadow: 0 0 35px rgba(16, 185, 129, 0.2),
                0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Danger glow variant */
.glow-danger:hover {
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.15),
                0 10px 40px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .glow-danger:hover {
    box-shadow: 0 0 35px rgba(239, 68, 68, 0.2),
                0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Warning glow variant */
.glow-warning:hover {
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.15),
                0 10px 40px rgba(0, 0, 0, 0.08);
}


/* ============================================================
   4. SKELETON LOADING
   ============================================================ */
@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        #e2e8f0 25%,
        #f1f5f9 37%,
        #e2e8f0 63%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.8s ease-in-out infinite;
    border-radius: 6px;
    min-height: 16px;
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(
        90deg,
        #334155 25%,
        #475569 37%,
        #334155 63%
    );
    background-size: 200% 100%;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 100%;
}
.skeleton-text:last-child {
    width: 60%;
}

.skeleton-title {
    height: 22px;
    margin-bottom: 12px;
    width: 70%;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-card {
    padding: 20px;
    border-radius: 12px;
}

.skeleton-btn {
    height: 38px;
    width: 120px;
    border-radius: 8px;
}


/* ============================================================
   5. BUTTON MICRO-INTERACTIONS (enhanced)
   ============================================================ */
.btn {
    position: relative;
    overflow: hidden;
}

/* Ripple effect container */
.btn .btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: btn-ripple-anim 0.6s ease-out;
    pointer-events: none;
}

@keyframes btn-ripple-anim {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Press effect */
.btn:active:not(:disabled) {
    transform: scale(0.96) !important;
    transition: transform 0.1s ease;
}

/* Enhanced hover: lift + shadow */
.btn-primary:hover,
.btn-success:hover,
.btn-info:hover,
.btn-danger:hover,
.btn-warning:hover,
.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

/* Icon spin on hover (for buttons with .btn-icon-spin) */
.btn-icon-spin:hover svg,
.btn-icon-spin:hover i {
    transition: transform 0.3s ease;
    transform: rotate(15deg);
}


/* ============================================================
   6. GRADIENT ANIMATED BORDER
   ============================================================ */
@keyframes gradient-rotate {
    0%   { --angle: 0deg; }
    100% { --angle: 360deg; }
}

.gradient-border {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: 0;
    padding: 2px;
    border-radius: 12px;
    background: linear-gradient(
        var(--gradient-angle, 0deg),
        #3b82f6,
        #8b5cf6,
        #ec4899,
        #f59e0b,
        #10b981,
        #3b82f6
    );
    background-size: 300% 300%;
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: gradient-border-spin 4s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes gradient-border-spin {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Subtle variant — only visible on hover */
.gradient-border-hover::before {
    opacity: 0;
    transition: opacity 0.4s ease;
}
.gradient-border-hover:hover::before {
    opacity: 1;
}


/* ============================================================
   7. NUMBER COUNTER ANIMATION
   ============================================================ */
.counter-value {
    display: inline-block;
    transition: transform 0.2s ease;
    font-variant-numeric: tabular-nums;
}

.counter-value.counting {
    color: var(--primary-color, #3b82f6);
}


/* ============================================================
   8. FLOATING LABELS (bonus micro-interaction)
   ============================================================ */
.float-label {
    position: relative;
}

.float-label label {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    font-size: 0.9rem;
    color: var(--text-muted, #64748b);
    pointer-events: none;
    transition: all 0.25s ease;
    background: var(--input-bg, #fff);
    padding: 0 4px;
}

.float-label input:focus ~ label,
.float-label input:not(:placeholder-shown) ~ label {
    top: 0;
    font-size: 0.75rem;
    color: var(--primary-color, #3b82f6);
    font-weight: 600;
}


/* ============================================================
   9. PULSE ANIMATION (for live indicators, badges)
   ============================================================ */
@keyframes pulse-ring {
    0%   { transform: scale(0.9); opacity: 1; }
    80%  { transform: scale(1.8); opacity: 0; }
    100% { transform: scale(1.8); opacity: 0; }
}

.pulse-dot {
    position: relative;
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success-color, #10b981);
}

.pulse-dot::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: inherit;
    animation: pulse-ring 1.5s ease-out infinite;
}


/* ============================================================
   10. TABLE ROW ANIMATION
   ============================================================ */
.table-animated tbody tr {
    transition: background-color 0.3s ease,
                transform 0.2s ease,
                box-shadow 0.2s ease;
}

.table-animated tbody tr:hover {
    transform: scale(1.005);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    z-index: 1;
    position: relative;
}

[data-theme="dark"] .table-animated tbody tr:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}


/* ============================================================
   11. THEME TOGGLE ANIMATION
   ============================================================ */
.theme-toggle .theme-icon {
    display: inline-block;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle:hover .theme-icon {
    transform: rotate(30deg) scale(1.2);
}

.theme-toggle:active .theme-icon {
    transform: rotate(180deg) scale(0.8);
}


/* ============================================================
   12. LOADING SPINNER (bonus)
   ============================================================ */
@keyframes spin-smooth {
    to { transform: rotate(360deg); }
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, #e2e8f0);
    border-top-color: var(--primary-color, #3b82f6);
    border-radius: 50%;
    animation: spin-smooth 0.8s linear infinite;
}

.spinner-sm {
    width: 18px;
    height: 18px;
    border-width: 2px;
}


/* ============================================================
   13. CURSOR SPARKLE TRAIL ✨
   ============================================================ */
@keyframes sparkle-float {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1) rotate(0deg);
    }
    50% {
        opacity: 0.7;
        transform: translate(var(--sx, 10px), var(--sy, -20px)) scale(0.6) rotate(180deg);
    }
    100% {
        opacity: 0;
        transform: translate(var(--ex, 15px), var(--ey, -40px)) scale(0) rotate(360deg);
    }
}

@keyframes click-ring {
    0% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(0);
    }
    70% {
        opacity: 0.2;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

.cursor-spark {
    position: fixed;
    pointer-events: none;
    z-index: 99999;
    border-radius: 50%;
    background: radial-gradient(circle, var(--spark-color, #60a5fa) 0%, transparent 70%);
    animation: sparkle-float var(--spark-dur, 0.8s) ease-out forwards;
}

.click-ring {
    position: fixed;
    pointer-events: none;
    z-index: 99998;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(96, 165, 250, 0.5);
    animation: click-ring 0.5s ease-out forwards;
}


/* ============================================================
   14. SCROLL PROGRESS BAR
   ============================================================ */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    z-index: 100000;
    transition: width 0.1s linear;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}


/* ============================================================
   15. FLOATING AMBIENT PARTICLES
   ============================================================ */
@keyframes particle-drift {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0);
    }
    10% {
        opacity: var(--p-opacity, 0.3);
        transform: scale(1);
    }
    90% {
        opacity: var(--p-opacity, 0.3);
    }
    100% {
        opacity: 0;
        transform: translate(var(--p-dx, 50px), var(--p-dy, -100px)) scale(0);
    }
}

.ambient-particle {
    position: fixed;
    pointer-events: none;
    z-index: -1;
    border-radius: 50%;
    background: var(--p-color, rgba(96, 165, 250, 0.2));
    animation: particle-drift var(--p-dur, 12s) ease-in-out infinite;
}




/* ============================================================
   17. TEXT SHIMMER GRADIENT
   ============================================================ */
@keyframes text-shimmer {
    0%   { background-position: -200% center; }
    100% { background-position: 200% center; }
}

.shimmer-text {
    background: linear-gradient(
        90deg,
        currentColor 30%,
        #60a5fa 50%,
        currentColor 70%
    );
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: text-shimmer 3s linear infinite;
}

[data-theme="dark"] .shimmer-text {
    background: linear-gradient(
        90deg,
        #e2e8f0 30%,
        #60a5fa 50%,
        #e2e8f0 70%
    );
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: text-shimmer 3s linear infinite;
}


/* ============================================================
   18. SMOOTH FOCUS GLOW FOR INPUTS
   ============================================================ */
.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15),
                0 0 20px rgba(59, 130, 246, 0.08) !important;
    transition: box-shadow 0.3s ease, border-color 0.3s ease !important;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2),
                0 0 20px rgba(96, 165, 250, 0.1) !important;
}


/* ============================================================
   19. SMOOTH LINK UNDERLINE ANIMATION
   ============================================================ */
.link-animate {
    position: relative;
    text-decoration: none !important;
}

.link-animate::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    transition: width 0.3s ease;
    border-radius: 1px;
}

.link-animate:hover::after {
    width: 100%;
}

/* ============================================================
   RESPONSIVE — Reduce motion for users who prefer it
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .reveal,
    .reveal-left,
    .reveal-right,
    .reveal-scale {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .skeleton {
        animation: none;
    }

    .gradient-border::before {
        animation: none;
    }

    .pulse-dot::before {
        animation: none;
    }

    .btn .btn-ripple {
        animation: none;
    }
}

