/* ============================================
   AI Tools - Visual Design System
   Purple/Blue gradient theme for AI-powered tools
   ============================================ */

:root {
  /* AI Color Palette */
  --ai-primary: #8b5cf6;
  --ai-primary-hover: #a78bfa;
  --ai-secondary: #6366f1;
  --ai-accent: #c084fc;
  --ai-gradient: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #3b82f6 100%);
  --ai-gradient-warm: linear-gradient(135deg, #c084fc 0%, #8b5cf6 50%, #6366f1 100%);
  --ai-glow: 0 0 20px rgba(139, 92, 246, 0.3), 0 0 60px rgba(99, 102, 241, 0.1);
  --ai-glow-strong: 0 0 20px rgba(139, 92, 246, 0.5), 0 0 40px rgba(99, 102, 241, 0.3), 0 0 80px rgba(59, 130, 246, 0.1);
  --ai-bg: rgba(139, 92, 246, 0.06);
  --ai-bg-hover: rgba(139, 92, 246, 0.12);
  --ai-border: rgba(139, 92, 246, 0.25);
  --ai-border-hover: rgba(139, 92, 246, 0.5);
  --ai-text: #c4b5fd;
  --ai-text-bright: #e9d5ff;
  --ai-radius: 14px;
}

/* ---- AI Tool Card ---- */
.ai-tool-card {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--ai-border);
  border-radius: var(--ai-radius);
  padding: 24px;
  transition: all 0.3s ease;
  overflow: hidden;
}
.ai-tool-card::before {
  content: '';
  position: absolute;
  inset: -1.5px;
  border-radius: inherit;
  background: var(--ai-gradient);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.ai-tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--ai-glow-strong);
  border-color: transparent;
  animation: ai-card-pulse 1.5s ease-in-out infinite;
}
@keyframes ai-card-pulse {
  0%, 100% { box-shadow: var(--ai-glow); }
  50% { box-shadow: 0 0 25px rgba(139, 92, 246, 0.6), 0 0 50px rgba(99, 102, 241, 0.4), 0 0 100px rgba(59, 130, 246, 0.2); }
}
.ai-tool-card:hover::before {
  opacity: 1;
}
.ai-tool-card .card-inner {
  position: relative;
  z-index: 1;
}

/* NEW Badge */
.ai-badge-new {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 3px 10px;
  background: var(--ai-gradient);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 20px;
  text-transform: uppercase;
  animation: ai-badge-pulse 2s ease-in-out infinite;
}
@keyframes ai-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
}

/* AI Icon (CSS-only) */
.ai-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--ai-gradient);
  color: #fff;
  font-size: 1.3rem;
  flex-shrink: 0;
  position: relative;
}
.ai-icon::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 17px;
  background: var(--ai-gradient);
  opacity: 0.3;
  z-index: -1;
  filter: blur(6px);
}

/* Inline SVG AI icon variant */
.ai-icon-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--ai-gradient);
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(139, 92, 246, 0.4));
}
.ai-icon-svg svg {
  width: 26px;
  height: 26px;
}

/* ---- AI Hero Section (Homepage) ---- */
.ai-hero-section {
  position: relative;
  margin-bottom: 48px;
  padding: 48px 32px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--ai-border);
  background: linear-gradient(-45deg, rgba(139, 92, 246, 0.12), rgba(99, 102, 241, 0.10), rgba(59, 130, 246, 0.08), rgba(168, 85, 247, 0.12));
  background-size: 400% 400%;
  animation: ai-gradient-flow 8s ease infinite;
}
@keyframes ai-gradient-flow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.ai-hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 50%);
  animation: ai-bg-shift 8s ease-in-out infinite alternate;
}
@keyframes ai-bg-shift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(2%, -2%); }
}
.ai-hero-section > * {
  position: relative;
  z-index: 1;
}
.ai-hero-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  background: var(--ai-gradient-warm);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.ai-hero-subtitle {
  color: var(--ai-text);
  font-size: 1.05rem;
  margin-bottom: 28px;
}
.ai-hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

/* ---- AI Input Fields ---- */
.ai-input-wrapper {
  position: relative;
}
.ai-input-wrapper textarea,
.ai-input-wrapper input[type="text"],
.ai-input-wrapper select {
  width: 100%;
  padding: 14px 16px 14px 46px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--ai-radius);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: all 0.25s ease;
}
.ai-input-wrapper textarea:focus,
.ai-input-wrapper input:focus,
.ai-input-wrapper select:focus {
  border-color: var(--ai-primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}
.ai-input-icon {
  position: absolute;
  left: 14px;
  top: 16px;
  width: 20px;
  height: 20px;
  color: var(--ai-primary);
  opacity: 0.7;
}

/* ---- AI Output Area ---- */
.ai-output-area {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--ai-radius);
  padding: 20px;
  min-height: 200px;
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-output-area.typing {
  border-color: var(--ai-border);
}
.ai-output-area.typing::after {
  content: '▌';
  animation: ai-cursor-blink 0.8s step-end infinite;
  color: var(--ai-primary);
  font-weight: 100;
}
@keyframes ai-cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ---- AI Loading States ---- */
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
}
/* Pulsing dots */
.ai-loading-dots {
  display: flex;
  gap: 8px;
}
.ai-loading-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ai-gradient);
  animation: ai-dot-pulse 1.4s ease-in-out infinite;
}
.ai-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-dot-pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
/* Spinning ring */
.ai-loading-ring {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--ai-primary);
  border-radius: 50%;
  animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin {
  to { transform: rotate(360deg); }
}
.ai-loading-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  animation: ai-fade-pulse 2s ease-in-out infinite;
}
@keyframes ai-fade-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ---- AI Action Button ---- */
.ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--ai-gradient);
  color: #fff;
  border: none;
  border-radius: var(--ai-radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}
.ai-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--ai-glow);
}
.ai-btn:active {
  transform: translateY(0);
}
.ai-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.ai-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}
.ai-btn:hover::after {
  transform: translateX(100%);
}

/* ---- AI Skeleton Loading ---- */
.ai-skeleton {
  background: var(--surface);
  border-radius: var(--ai-radius);
  overflow: hidden;
}
.ai-skeleton-line {
  height: 16px;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  border-radius: 8px;
  animation: ai-skeleton-shimmer 1.5s ease-in-out infinite;
  margin-bottom: 12px;
}
.ai-skeleton-line:last-child { margin-bottom: 0; }
.ai-skeleton-line.w-100 { width: 100%; }
.ai-skeleton-line.w-80 { width: 80%; }
.ai-skeleton-line.w-60 { width: 60%; }
.ai-skeleton-line.w-40 { width: 40%; }
@keyframes ai-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- AI Star Marker (for tool lists) ---- */
.ai-star-marker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--ai-text-bright);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 8px;
  vertical-align: middle;
}

/* ---- Stagger fade-in for AI cards ---- */
.ai-tool-card {
  opacity: 0;
  animation: ai-card-fadein 0.5s ease forwards;
}
.ai-tool-card:nth-child(1) { animation-delay: 0.05s; }
.ai-tool-card:nth-child(2) { animation-delay: 0.15s; }
.ai-tool-card:nth-child(3) { animation-delay: 0.25s; }
.ai-tool-card:nth-child(4) { animation-delay: 0.35s; }
.ai-tool-card:nth-child(5) { animation-delay: 0.45s; }
.ai-tool-card:nth-child(6) { animation-delay: 0.55s; }
.ai-tool-card:nth-child(7) { animation-delay: 0.65s; }
.ai-tool-card:nth-child(8) { animation-delay: 0.75s; }
@keyframes ai-card-fadein {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .ai-hero-section {
    padding: 28px 20px;
  }
  .ai-hero-title {
    font-size: 1.5rem;
  }
  .ai-hero-grid {
    grid-template-columns: 1fr;
  }
  .ai-tool-card {
    padding: 20px;
  }
}

/* ---- Dark theme compatibility (already dark by default, but ensure) ---- */
@media (prefers-color-scheme: light) {
  :root {
    --ai-bg: rgba(139, 92, 246, 0.05);
    --ai-bg-hover: rgba(139, 92, 246, 0.1);
  }
}
