/* ═══════════════════════════════════════════════════
   CodeAI — Animations & Effects
   ═══════════════════════════════════════════════════ */

/* ── Keyframes ── */

@keyframes cube-spin {
  0%   { transform: rotateX(0deg) rotateY(0deg); }
  100% { transform: rotateX(360deg) rotateY(360deg); }
}

@keyframes drop-cube-float {
  0%, 100% { transform: translateY(0px) rotateY(0deg); }
  50%       { transform: translateY(-12px) rotateY(180deg); }
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.4); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 6px rgba(0, 255, 136, 0); }
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

@keyframes spinner-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

@keyframes progress-scan {
  0%   { transform: scaleX(0); transform-origin: left; }
  50%  { transform: scaleX(1); transform-origin: left; }
  51%  { transform: scaleX(1); transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}

@keyframes border-dash {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -20; }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(0, 245, 255, 0.2); }
  50%       { box-shadow: 0 0 30px rgba(0, 245, 255, 0.5), 0 0 60px rgba(0, 245, 255, 0.2); }
}

@keyframes neon-flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
    text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan), 0 0 40px var(--neon-cyan);
  }
  20%, 24%, 55% {
    text-shadow: none;
  }
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slide-in-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes typing-dots {
  0%, 20%  { content: '.'; }
  40%      { content: '..'; }
  60%, 100%{ content: '...'; }
}

@keyframes scan-line {
  0%   { top: 0; opacity: 0.6; }
  100% { top: 100%; opacity: 0; }
}

@keyframes matrix-rain {
  0%   { transform: translateY(-100%); opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}

@keyframes border-glow-rotate {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes float-particle {
  0%   { transform: translateY(0) translateX(0) scale(1); opacity: 0.6; }
  33%  { transform: translateY(-30px) translateX(15px) scale(1.1); opacity: 0.8; }
  66%  { transform: translateY(-15px) translateX(-10px) scale(0.9); opacity: 0.5; }
  100% { transform: translateY(0) translateX(0) scale(1); opacity: 0.6; }
}

@keyframes ai-thinking {
  0%   { transform: rotate(0deg) scale(1); }
  25%  { transform: rotate(90deg) scale(1.1); }
  50%  { transform: rotate(180deg) scale(1); }
  75%  { transform: rotate(270deg) scale(0.9); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes code-highlight-sweep {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes terminal-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@keyframes ripple {
  0%   { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(4); opacity: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

@keyframes success-bounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.15); }
  60%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

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

/* ── Animation Utility Classes ── */

.anim-fade-in       { animation: fade-in 0.3s ease forwards; }
.anim-slide-up      { animation: slide-in-up 0.3s ease forwards; }
.anim-slide-right   { animation: slide-in-right 0.3s ease forwards; }
.anim-scale-in      { animation: scale-in 0.25s ease forwards; }
.anim-shake         { animation: shake 0.4s ease; }
.anim-bounce        { animation: success-bounce 0.4s ease; }
.anim-glow-pulse    { animation: glow-pulse 2s ease-in-out infinite; }

/* Stagger delays */
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.10s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.20s; }
.delay-5 { animation-delay: 0.25s; }

/* ── Particle System ── */
.particle {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  z-index: 0;
}

.particle-cyan {
  background: radial-gradient(circle, rgba(0, 245, 255, 0.8), transparent);
  animation: float-particle 6s ease-in-out infinite;
}

.particle-purple {
  background: radial-gradient(circle, rgba(139, 92, 246, 0.6), transparent);
  animation: float-particle 8s ease-in-out infinite reverse;
}

.particle-green {
  background: radial-gradient(circle, rgba(0, 255, 136, 0.5), transparent);
  animation: float-particle 10s ease-in-out infinite;
}

/* ── Scan Line Effect ── */
.scan-line-effect {
  position: relative;
  overflow: hidden;
}

.scan-line-effect::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(0, 245, 255, 0.4), transparent);
  animation: scan-line 3s linear infinite;
  pointer-events: none;
}

/* ── Glowing Border ── */
.glow-border {
  position: relative;
}

.glow-border::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple), var(--neon-green), var(--neon-cyan));
  background-size: 300% 300%;
  animation: border-glow-rotate 4s linear infinite;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.glow-border:hover::before {
  opacity: 1;
}

/* ── AI Thinking Indicator ── */
.ai-thinking {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ai-thinking-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--neon-cyan);
  animation: thinking-bounce 1.2s ease-in-out infinite;
}

.ai-thinking-dot:nth-child(2) { animation-delay: 0.2s; background: var(--neon-purple); }
.ai-thinking-dot:nth-child(3) { animation-delay: 0.4s; background: var(--neon-green); }

@keyframes thinking-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-8px); opacity: 1; }
}

/* ── Code Sweep Highlight ── */
.code-sweep {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 245, 255, 0.15) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: code-highlight-sweep 1.5s ease-in-out;
}

/* ── Ripple Effect ── */
.ripple-container {
  position: relative;
  overflow: hidden;
}

.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(0, 245, 255, 0.3);
  animation: ripple 0.6s linear;
  pointer-events: none;
}

/* ── 3D Card Hover ── */
.card-3d {
  transform-style: preserve-3d;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-3d:hover {
  transform: perspective(800px) rotateX(-3deg) rotateY(3deg) translateZ(8px);
  box-shadow: 8px 8px 24px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 245, 255, 0.1);
}

/* ── Neon Text ── */
.neon-text-cyan {
  color: var(--neon-cyan);
  text-shadow:
    0 0 7px var(--neon-cyan),
    0 0 10px var(--neon-cyan),
    0 0 21px var(--neon-cyan);
}

.neon-text-green {
  color: var(--neon-green);
  text-shadow:
    0 0 7px var(--neon-green),
    0 0 10px var(--neon-green),
    0 0 21px var(--neon-green);
}

.neon-text-purple {
  color: var(--neon-purple);
  text-shadow:
    0 0 7px var(--neon-purple),
    0 0 10px var(--neon-purple),
    0 0 21px var(--neon-purple);
}

/* ── Gradient Text ── */
.gradient-text {
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-animated {
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple), var(--neon-green), var(--neon-cyan));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 4s ease infinite;
}

/* ── Button Press Effect ── */
.btn-press {
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-press:active {
  transform: scale(0.96) translateY(1px);
}

/* ── Holographic Shimmer ── */
.holographic {
  background: linear-gradient(
    135deg,
    rgba(0, 245, 255, 0.05) 0%,
    rgba(139, 92, 246, 0.05) 25%,
    rgba(0, 255, 136, 0.05) 50%,
    rgba(255, 107, 43, 0.05) 75%,
    rgba(0, 245, 255, 0.05) 100%
  );
  background-size: 400% 400%;
  animation: gradient-shift 8s ease infinite;
}

/* ── Terminal Typing Effect ── */
.typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--neon-cyan);
  animation:
    typing 2s steps(40, end),
    terminal-cursor 0.8s step-end infinite;
}

@keyframes typing {
  from { width: 0; }
  to   { width: 100%; }
}

/* ── Loading Bar ── */
.loading-bar {
  height: 2px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple), var(--neon-green));
  background-size: 200% 100%;
  animation: gradient-shift 1.5s ease infinite;
  border-radius: 1px;
}

/* ── Pulse Ring ── */
.pulse-ring {
  position: relative;
}

.pulse-ring::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 1px solid var(--neon-cyan);
  animation: pulse-ring-anim 2s ease-out infinite;
}

@keyframes pulse-ring-anim {
  0%   { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ── File Drop Highlight ── */
.drop-zone.drag-over .drop-zone-inner {
  animation: scale-in 0.2s ease;
}

.drop-zone.drag-over .drop-title {
  color: var(--neon-cyan);
  animation: neon-flicker 0.5s ease;
}

/* ── Chat Message Entrance ── */
.chat-msg {
  animation: slide-in-up 0.25s ease forwards;
}

/* ── Tab Active Indicator ── */
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
}

/* ── Right Tab Active Indicator ── */
.right-tab.active {
  position: relative;
}

.right-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--neon-cyan);
  border-radius: 1px;
  box-shadow: 0 0 8px var(--neon-cyan);
}

/* ── Action Item Hover Glow ── */
.action-item:hover .action-icon {
  filter: drop-shadow(0 0 6px rgba(0, 245, 255, 0.5));
  transform: scale(1.1);
  transition: all 0.15s ease;
}

/* ── Nav Button Active State ── */
.nav-btn.active {
  animation: glow-pulse 1.5s ease-in-out infinite;
}

/* ── Recording Active State ── */
.nav-btn-record.recording {
  background: rgba(255, 45, 120, 0.15);
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  animation: rec-blink 1s ease-in-out infinite;
}

/* ── Run Button Active ── */
.nav-btn-run.running {
  background: rgba(0, 255, 136, 0.1);
  border-color: var(--neon-green);
  animation: glow-pulse 1s ease-in-out infinite;
}

/* ── Insight Card Entrance ── */
.insight-card {
  animation: slide-in-up 0.3s ease forwards;
}

/* ── Scrollbar Glow on Hover ── */
.terminal-output:hover::-webkit-scrollbar-thumb,
.chat-messages:hover::-webkit-scrollbar-thumb {
  background: rgba(0, 245, 255, 0.3);
  box-shadow: 0 0 6px rgba(0, 245, 255, 0.3);
}

/* ── Logo Cube Glow ── */
.logo-cube .cube-face {
  box-shadow: inset 0 0 10px rgba(0, 245, 255, 0.1);
  transition: all 0.3s ease;
}

.logo-mark:hover .cube-face {
  border-color: rgba(0, 245, 255, 0.6);
  box-shadow: inset 0 0 15px rgba(0, 245, 255, 0.2), 0 0 10px rgba(0, 245, 255, 0.1);
}

/* ── Status Dot Colors ── */
.status-dot.error {
  background: var(--neon-pink);
  animation: status-pulse-error 1s ease-in-out infinite;
}

@keyframes status-pulse-error {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 45, 120, 0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(255, 45, 120, 0); }
}

.status-dot.thinking {
  background: var(--neon-purple);
  animation: status-pulse-think 0.6s ease-in-out infinite;
}

@keyframes status-pulse-think {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.4); }
}

/* ── Diff Line Animations ── */
.diff-line-added {
  background: rgba(0, 255, 136, 0.08);
  border-left: 3px solid var(--neon-green);
  animation: slide-in-right 0.2s ease;
}

.diff-line-removed {
  background: rgba(255, 45, 120, 0.08);
  border-left: 3px solid var(--neon-pink);
  animation: slide-in-right 0.2s ease;
}

/* ── Video Recording Pulse ── */
.video-preview-area.recording {
  box-shadow: 0 0 0 2px var(--neon-pink), 0 0 20px rgba(255, 45, 120, 0.3);
  animation: recording-border 1s ease-in-out infinite;
}

@keyframes recording-border {
  0%, 100% { box-shadow: 0 0 0 2px var(--neon-pink), 0 0 20px rgba(255, 45, 120, 0.3); }
  50%       { box-shadow: 0 0 0 3px var(--neon-pink), 0 0 35px rgba(255, 45, 120, 0.5); }
}

/* ── Topbar Gradient Line ── */
.topbar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0, 245, 255, 0.3) 20%,
    rgba(139, 92, 246, 0.3) 50%,
    rgba(0, 255, 136, 0.3) 80%,
    transparent 100%
  );
}

/* ── App Shell Entrance ── */
.app-shell {
  animation: fade-in 0.4s ease;
}

/* ── Sidebar Section Hover ── */
.sidebar-section {
  transition: background 0.2s ease;
}

/* ── File Item Glow on Active ── */
.file-item.active {
  box-shadow: inset 0 0 12px rgba(0, 245, 255, 0.05);
}

/* ── Chat Send Button Pulse ── */
.chat-send:not(:disabled) {
  animation: glow-pulse 3s ease-in-out infinite;
}

/* ── Mode Button Transition ── */
.mode-btn {
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mode-btn.active {
  transform: scale(1.05);
}