/* Stella.Support Magic - Ambient Intelligence Effects */

/* Aurora Background */
.aurora-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}
.aurora-bg::before,
.aurora-bg::after {
    content: "";
    position: absolute;
    width: 60vmax;
    height: 60vmax;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.07;
    animation: aurora-drift 20s ease-in-out infinite alternate;
}
.aurora-bg::before {
    background: radial-gradient(circle, var(--color-ai) 0%, transparent 70%);
    top: -30%;
    left: -10%;
}
.aurora-bg::after {
    background: radial-gradient(circle, var(--color-accent) 0%, transparent 70%);
    bottom: -30%;
    right: -10%;
    animation-delay: -10s;
    animation-direction: alternate-reverse;
}
@keyframes aurora-drift {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(5%, 8%) scale(1.1); }
    100% { transform: translate(-3%, -5%) scale(0.95); }
}

/* Particle Canvas */
#ai-particles {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

/* Sparkle Burst */
@keyframes sparkle-pop {
    0%   { transform: scale(0) rotate(0deg); opacity: 1; }
    50%  { transform: scale(1.2) rotate(180deg); opacity: 0.8; }
    100% { transform: scale(0) rotate(360deg); opacity: 0; }
}
.sparkle {
    position: absolute;
    width: 6px; height: 6px;
    background: var(--color-ai);
    border-radius: 50%;
    pointer-events: none;
    animation: sparkle-pop 0.7s ease-out forwards;
    box-shadow: 0 0 6px var(--color-ai), 0 0 12px var(--color-ai-glow);
}

/* AI Typing / Streaming Text */
.ai-typewriter {
    overflow: hidden;
    border-right: 2px solid var(--color-ai);
    white-space: nowrap;
    animation: typewriter-cursor 0.7s step-end infinite;
}
@keyframes typewriter-cursor {
    0%, 100% { border-color: var(--color-ai); }
    50%      { border-color: transparent; }
}
.ai-streaming-text span {
    opacity: 0;
    animation: stream-in 0.15s ease forwards;
}
@keyframes stream-in {
    to { opacity: 1; }
}

/* Neural Network Ambient Pattern */
.neural-pattern {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 20% 30%, var(--color-ai-glow) 1px, transparent 1px),
        radial-gradient(circle at 60% 70%, rgba(6, 182, 212, 0.15) 1px, transparent 1px),
        radial-gradient(circle at 80% 20%, var(--color-ai-glow) 1px, transparent 1px);
    background-size: 120px 120px, 150px 150px, 100px 100px;
    animation: neural-float 30s linear infinite;
    opacity: 0.4;
}
@keyframes neural-float {
    0%   { background-position: 0 0, 0 0, 0 0; }
    100% { background-position: 120px 120px, -150px 150px, 100px -100px; }
}

/* Magic Hover Lift */
.magic-hover {
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.35s ease;
}
.magic-hover:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 12px 40px -8px var(--color-ai-glow),
                0 0 0 1px var(--color-ai-border);
}

/* Gradient Border Animation */
.gradient-border {
    position: relative;
    border: none !important;
}
.gradient-border::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--color-ai), var(--color-accent), var(--color-ai));
    background-size: 300% 300%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: gradient-rotate 4s linear infinite;
    opacity: 0.6;
    pointer-events: none;
}
@keyframes gradient-rotate {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Enhanced AI Insights Panel */
.ai-insights {
    position: relative;
    overflow: hidden;
}
.ai-insights::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent 0%, var(--color-ai-glow) 10%, transparent 20%);
    animation: insights-sweep 8s linear infinite;
    opacity: 0.15;
    pointer-events: none;
}
@keyframes insights-sweep {
    to { transform: rotate(360deg); }
}

/* Stat Card Enhancements */
.stat-card-modern {
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.stat-card-modern:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 60px -15px var(--color-ai-glow);
}
.stat-card-modern .stat-value {
    background: linear-gradient(135deg, #fff 30%, var(--color-ai));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Sidebar AI Status Sweep */
.sidebar-ai-status {
    position: relative;
    overflow: hidden;
}
.sidebar-ai-status::after {
    content: "";
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, var(--color-ai-glow), transparent);
    animation: status-sweep 3s ease-in-out infinite;
}
@keyframes status-sweep {
    0%   { left: -100%; }
    50%  { left: 100%; }
    100% { left: 100%; }
}

/* Command Palette Glow */
.command-palette-backdrop.active .command-palette {
    box-shadow: 0 0 80px -20px var(--color-ai-glow),
                0 0 0 1px var(--color-ai-border);
}
.command-palette-input:focus {
    box-shadow: 0 0 0 2px var(--color-ai-glow);
}

/* Page Transition */
.app-content {
    animation: page-enter 0.4s ease-out;
}
@keyframes page-enter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* AI Loading State */
.ai-loading {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.ai-loading .neuron {
    width: 6px; height: 6px;
    background: var(--color-ai);
    border-radius: 50%;
    animation: neuron-pulse 1.2s ease-in-out infinite;
    box-shadow: 0 0 8px var(--color-ai-glow);
}
.ai-loading .neuron:nth-child(2) { animation-delay: 0.2s; }
.ai-loading .neuron:nth-child(3) { animation-delay: 0.4s; }
@keyframes neuron-pulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40%           { transform: scale(1.2); opacity: 1; }
}

/* Auth Pages Particle Grid */
.auth-container .brand-panel {
    position: relative;
    overflow: hidden;
}
.auth-container .brand-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(var(--color-ai-glow) 1px, transparent 1px);
    background-size: 30px 30px;
    animation: grid-drift 20s linear infinite;
    opacity: 0.3;
}
@keyframes grid-drift {
    to { background-position: 30px 30px; }
}

/* Ticket Row AI Indicator */
.ticket-row {
    position: relative;
    transition: all 0.25s ease;
}
.ticket-row:hover {
    background: var(--color-ai-surface) !important;
}
.ticket-row.ai-classified::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--color-ai), var(--color-accent));
    border-radius: 0 2px 2px 0;
}

/* Badge Glow */
.ai-badge {
    animation: badge-glow 2s ease-in-out infinite alternate;
}
@keyframes badge-glow {
    from { box-shadow: 0 0 4px var(--color-ai-glow); }
    to   { box-shadow: 0 0 12px var(--color-ai-glow), 0 0 24px rgba(139, 92, 246, 0.1); }
}

/* Helper / Tip Cards */
.ai-helper-card {
    border-left: 3px solid var(--color-ai);
    background: var(--color-ai-surface);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
}
.ai-helper-card::after {
    content: "";
    position: absolute;
    top: 0; right: 0;
    width: 60px; height: 60px;
    background: radial-gradient(circle, var(--color-ai-glow), transparent 70%);
    opacity: 0.3;
}

/* Notification Bell Magic */
.topbar-notification-dot {
    animation: bell-pulse 2s ease-in-out infinite;
}
@keyframes bell-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* AI Thought Bubble */
.ai-thought {
    position: relative;
    background: var(--color-ai-surface);
    border: 1px solid var(--color-ai-border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
}

/* Staggered Fade-In for Lists */
.stagger-in > * {
    opacity: 0;
    transform: translateY(10px);
    animation: stagger-fade 0.4s ease forwards;
}
.stagger-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-in > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-in > *:nth-child(8) { animation-delay: 0.4s; }
.stagger-in > *:nth-child(n+9) { animation-delay: 0.45s; }
@keyframes stagger-fade {
    to { opacity: 1; transform: translateY(0); }
}

/* Card Entrance */
.card-entrance {
    animation: card-enter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes card-enter {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Flash Message Slide */
.alert {
    animation: flash-slide 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes flash-slide {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Button Ripple on AI Actions */
.btn-ai-action {
    position: relative;
    overflow: hidden;
}
.btn-ai-action .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple-expand 0.6s ease-out;
    pointer-events: none;
}
@keyframes ripple-expand {
    to { transform: scale(4); opacity: 0; }
}

/* Input Focus Glow */
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 3px var(--color-ai-glow), 0 0 20px -5px var(--color-ai-glow) !important;
    border-color: var(--color-ai) !important;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* AI Scan Line */
.ai-scanning {
    position: relative;
    overflow: hidden;
}
.ai-scanning::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-ai), var(--color-accent), transparent);
    animation: scan-line 2s ease-in-out infinite;
    box-shadow: 0 0 15px var(--color-ai-glow);
}
@keyframes scan-line {
    0%   { top: 0; opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

/* Confidence Meter */
.confidence-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--color-border);
    overflow: hidden;
    position: relative;
}
.confidence-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--color-ai), var(--color-accent));
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}
.confidence-bar-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: confidence-shine 2s ease-in-out infinite;
}
@keyframes confidence-shine {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Floating Action Hint */
.ai-float-hint {
    animation: float-bob 3s ease-in-out infinite;
}
@keyframes float-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

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