/* ============================================
   CURS AGENTS IA — Animacions i Estil Custom
   ============================================ */

/* ---- Variables de color ---- */
:root {
  --ai-purple: #7c3aed;
  --ai-cyan: #06b6d4;
  --ai-green: #10b981;
  --ai-orange: #f59e0b;
  --ai-red: #ef4444;
  --ai-dark: #0f0f1a;
  --ai-card-bg: rgba(124, 58, 237, 0.08);
  --ai-glow: 0 0 20px rgba(124, 58, 237, 0.3);
  --ai-glow-cyan: 0 0 20px rgba(6, 182, 212, 0.3);
}

[data-md-color-scheme="slate"] {
  --ai-card-bg: rgba(124, 58, 237, 0.12);
  --md-default-bg-color: #0f0f1a;
}

/* ============================================
   HERO BANNER (pàgina d'inici)
   ============================================ */
.hero-banner {
  background: linear-gradient(135deg, #0f0f1a 0%, #1a0a2e 50%, #0a1628 100%);
  border-radius: 16px;
  padding: 3rem 2rem;
  text-align: center;
  margin: 2rem 0;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(124, 58, 237, 0.3);
  box-shadow: var(--ai-glow);
}

.hero-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(124, 58, 237, 0.15) 0%, transparent 60%),
              radial-gradient(circle at 70% 30%, rgba(6, 182, 212, 0.10) 0%, transparent 50%);
  animation: heroGlow 8s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes heroGlow {
  0%   { transform: scale(1) rotate(0deg); opacity: 0.7; }
  100% { transform: scale(1.1) rotate(5deg); opacity: 1; }
}

.hero-title {
  font-size: 2.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, #a78bfa, #06b6d4, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
  animation: fadeInDown 0.8s ease-out;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: rgba(200, 200, 220, 0.85);
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

.hero-badges {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.8s ease-out 0.4s both;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.2);
}

.badge-purple { background: rgba(124, 58, 237, 0.25); color: #c4b5fd; border-color: rgba(124, 58, 237, 0.4); }
.badge-cyan   { background: rgba(6, 182, 212, 0.20); color: #67e8f9; border-color: rgba(6, 182, 212, 0.4); }
.badge-green  { background: rgba(16, 185, 129, 0.20); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.4); }
.badge-orange { background: rgba(245, 158, 11, 0.20); color: #fcd34d; border-color: rgba(245, 158, 11, 0.4); }

/* ============================================
   TIMELINE D'HISTÒRIA
   ============================================ */
.timeline {
  position: relative;
  padding: 1rem 0;
  margin: 2rem 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--ai-purple), var(--ai-cyan), var(--ai-green));
}

.timeline-item {
  position: relative;
  padding-left: 60px;
  margin-bottom: 2rem;
  animation: slideInLeft 0.6s ease-out both;
}

.timeline-item:nth-child(1)  { animation-delay: 0.1s; }
.timeline-item:nth-child(2)  { animation-delay: 0.2s; }
.timeline-item:nth-child(3)  { animation-delay: 0.3s; }
.timeline-item:nth-child(4)  { animation-delay: 0.4s; }
.timeline-item:nth-child(5)  { animation-delay: 0.5s; }
.timeline-item:nth-child(6)  { animation-delay: 0.6s; }
.timeline-item:nth-child(7)  { animation-delay: 0.7s; }
.timeline-item:nth-child(8)  { animation-delay: 0.8s; }
.timeline-item:nth-child(9)  { animation-delay: 0.9s; }
.timeline-item:nth-child(10) { animation-delay: 1.0s; }

.timeline-dot {
  position: absolute;
  left: 10px;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--ai-purple);
  background: var(--md-default-bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--ai-purple);
  box-shadow: var(--ai-glow);
  transition: transform 0.2s ease;
}

.timeline-item:hover .timeline-dot {
  transform: scale(1.3);
  box-shadow: 0 0 25px rgba(124, 58, 237, 0.6);
}

.timeline-year {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ai-cyan);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.3rem;
}

.timeline-content {
  background: var(--ai-card-bg);
  border-left: 3px solid var(--ai-purple);
  border-radius: 0 8px 8px 0;
  padding: 0.8rem 1rem;
}

.timeline-content h4 {
  margin: 0 0 0.3rem 0;
  font-size: 1rem;
  color: #a78bfa;
}

.timeline-content p {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.85;
}

/* ============================================
   CARDS DE CONCEPTES (limitacions, components)
   ============================================ */
.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}

.concept-card {
  background: var(--ai-card-bg);
  border: 1px solid rgba(124, 58, 237, 0.2);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  cursor: default;
}

.concept-card::after {
  content: '';
  position: absolute;
  top: -100%;
  left: -100%;
  width: 300%;
  height: 300%;
  background: radial-gradient(circle, rgba(124,58,237,0.08) 0%, transparent 60%);
  transition: all 0.5s ease;
}

.concept-card:hover {
  transform: translateY(-4px);
  border-color: var(--ai-purple);
  box-shadow: var(--ai-glow);
}

.concept-card:hover::after {
  top: -50%;
  left: -50%;
}

.concept-card.danger { border-left: 4px solid var(--ai-red); }
.concept-card.warning { border-left: 4px solid var(--ai-orange); }
.concept-card.info    { border-left: 4px solid var(--ai-cyan); }
.concept-card.success { border-left: 4px solid var(--ai-green); }

.concept-icon {
  font-size: 2rem;
  margin-bottom: 0.8rem;
  display: block;
}

.concept-card h3 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem 0;
  color: #c4b5fd;
}

.concept-card p {
  font-size: 0.88rem;
  opacity: 0.82;
  margin: 0;
  line-height: 1.6;
}

/* ============================================
   DIAGRAMA ARQUITECTURA AGENT (animat)
   ============================================ */
.agent-diagram {
  background: linear-gradient(135deg, #0f0f1a, #1a0a2e);
  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: 16px;
  padding: 2rem;
  margin: 2rem 0;
  overflow-x: auto;
}

.agent-diagram-title {
  text-align: center;
  color: #a78bfa;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ---- FLUX animat SVG ---- */
.flow-diagram {
  width: 100%;
  min-width: 700px;
  max-width: 900px;
  margin: 0 auto;
  display: block;
}

/* Animació de pols per als nodes */
@keyframes nodePulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(124,58,237,0.4)); }
  50%       { filter: drop-shadow(0 0 12px rgba(124,58,237,0.9)); }
}

@keyframes dataPulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(6,182,212,0.4)); }
  50%       { filter: drop-shadow(0 0 12px rgba(6,182,212,0.9)); }
}

@keyframes greenPulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(16,185,129,0.4)); }
  50%       { filter: drop-shadow(0 0 12px rgba(16,185,129,0.9)); }
}

.node-brain   { animation: nodePulse 2.5s ease-in-out infinite; }
.node-tools   { animation: dataPulse 2.5s ease-in-out infinite 0.5s; }
.node-memory  { animation: greenPulse 2.5s ease-in-out infinite 1s; }
.node-plan    { animation: nodePulse 2.5s ease-in-out infinite 1.5s; }

/* Animació de les fletxes de flux */
@keyframes dashMove {
  to { stroke-dashoffset: -20; }
}

.flow-arrow {
  stroke-dasharray: 8 4;
  animation: dashMove 1.2s linear infinite;
}

.flow-arrow-slow {
  stroke-dasharray: 6 6;
  animation: dashMove 2s linear infinite;
}

/* ============================================
   TOKEN COUNTER VISUAL (context window demo)
   ============================================ */
.token-bar-container {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.token-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  color: #a78bfa;
}

.token-bar {
  height: 28px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  overflow: hidden;
  position: relative;
}

.token-bar-fill {
  height: 100%;
  border-radius: 6px;
  position: relative;
  transition: width 1s ease;
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
}

.token-bar-fill.system-prompt {
  background: linear-gradient(90deg, #7c3aed, #9d5ce5);
  width: 15%;
}
.token-bar-fill.history {
  background: linear-gradient(90deg, #0891b2, #06b6d4);
  width: 35%;
  position: absolute;
  left: 15%;
}
.token-bar-fill.context {
  background: linear-gradient(90deg, #059669, #10b981);
  width: 30%;
  position: absolute;
  left: 50%;
}
.token-bar-fill.available {
  background: rgba(255,255,255,0.07);
  width: 20%;
  position: absolute;
  left: 80%;
  color: rgba(255,255,255,0.4);
}

/* ============================================
   RAG PIPELINE ANIMACIÓ
   ============================================ */
.rag-pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 2rem 0;
  overflow-x: auto;
  padding: 1rem 0;
}

.rag-step {
  background: var(--ai-card-bg);
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: 10px;
  padding: 1rem;
  min-width: 130px;
  text-align: center;
  flex: 1;
  animation: fadeInScale 0.5s ease-out both;
  transition: all 0.3s ease;
}

.rag-step:hover {
  transform: scale(1.05);
  border-color: var(--ai-purple);
  box-shadow: var(--ai-glow);
}

.rag-step:nth-child(1)  { animation-delay: 0.1s; }
.rag-step:nth-child(3)  { animation-delay: 0.2s; }
.rag-step:nth-child(5)  { animation-delay: 0.3s; }
.rag-step:nth-child(7)  { animation-delay: 0.4s; }
.rag-step:nth-child(9)  { animation-delay: 0.5s; }

.rag-arrow {
  color: var(--ai-cyan);
  font-size: 1.5rem;
  padding: 0 0.25rem;
  animation: arrowBounce 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes arrowBounce {
  0%, 100% { transform: translateX(0); }
  50%       { transform: translateX(4px); }
}

.rag-icon {
  font-size: 1.8rem;
  display: block;
  margin-bottom: 0.4rem;
}

.rag-step h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a78bfa;
  margin: 0 0 0.3rem 0;
}

.rag-step p {
  font-size: 0.72rem;
  margin: 0;
  opacity: 0.75;
}

/* ============================================
   REACT (Reason+Act) LOOP ANIMACIÓ
   ============================================ */
.react-loop {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 2rem auto;
  aspect-ratio: 1;
}

.react-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: 0 0 30px rgba(124,58,237,0.5);
  animation: reactCenterPulse 2s ease-in-out infinite;
  z-index: 10;
}

@keyframes reactCenterPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(124,58,237,0.4); transform: translate(-50%, -50%) scale(1); }
  50%       { box-shadow: 0 0 40px rgba(124,58,237,0.8); transform: translate(-50%, -50%) scale(1.05); }
}

.react-node {
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  border: 2px solid;
  transition: all 0.3s ease;
  cursor: default;
}

.react-node:hover { transform: scale(1.1); }

.react-node.thought {
  background: rgba(124,58,237,0.2);
  border-color: #7c3aed;
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  animation: reactNodePulse 3s ease-in-out infinite 0s;
}

.react-node.action {
  background: rgba(6,182,212,0.2);
  border-color: #06b6d4;
  top: 50%;
  right: 5%;
  transform: translateY(-50%);
  animation: reactNodePulse 3s ease-in-out infinite 1s;
}

.react-node.observation {
  background: rgba(16,185,129,0.2);
  border-color: #10b981;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  animation: reactNodePulse 3s ease-in-out infinite 2s;
}

.react-node.plan {
  background: rgba(245,158,11,0.2);
  border-color: #f59e0b;
  top: 50%;
  left: 5%;
  transform: translateY(-50%);
  animation: reactNodePulse 3s ease-in-out infinite 0.5s;
}

@keyframes reactNodePulse {
  0%, 70%, 100% { opacity: 0.7; }
  35%            { opacity: 1; box-shadow: 0 0 15px currentColor; }
}

.react-node .node-icon { font-size: 1.5rem; margin-bottom: 0.2rem; }

/* ============================================
   COMPARACIÓ LLM vs AGENT
   ============================================ */
.comparison-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 2rem 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(124,58,237,0.2);
}

.comparison-table th {
  padding: 1rem 1.5rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.comparison-table th:first-child {
  background: rgba(30,30,50,0.8);
  color: #94a3b8;
}

.comparison-table th.llm-col {
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
}

.comparison-table th.agent-col {
  background: rgba(16,185,129,0.15);
  color: #6ee7b7;
}

.comparison-table td {
  padding: 0.85rem 1.5rem;
  font-size: 0.9rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  vertical-align: top;
}

.comparison-table td:first-child {
  background: rgba(15,15,30,0.5);
  font-weight: 600;
  color: #a78bfa;
}

.comparison-table td.llm-col {
  background: rgba(239,68,68,0.05);
  color: #fca5a5;
}

.comparison-table td.agent-col {
  background: rgba(16,185,129,0.05);
  color: #6ee7b7;
}

/* ============================================
   CODI ANIMAT — step execution
   ============================================ */
.code-execution {
  background: #0d1117;
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 10px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  overflow-x: auto;
}

.exec-line {
  display: block;
  padding: 0.1rem 0;
  border-radius: 3px;
  transition: background 0.2s;
}

.exec-line.active {
  background: rgba(124,58,237,0.2);
  animation: lineHighlight 1s ease-in-out infinite;
}

@keyframes lineHighlight {
  0%, 100% { background: rgba(124,58,237,0.15); }
  50%       { background: rgba(124,58,237,0.30); }
}

.exec-comment { color: #6e7681; }
.exec-keyword  { color: #ff7b72; }
.exec-string   { color: #a5d6ff; }
.exec-func     { color: #d2a8ff; }
.exec-var      { color: #ffa657; }
.exec-output   { color: #3fb950; }

/* ============================================
   ANIMACIONS GENERALS
   ============================================ */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

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

/* ============================================
   CALLOUTS ESPECIALS
   ============================================ */
.ai-callout {
  background: linear-gradient(135deg, rgba(124,58,237,0.1), rgba(6,182,212,0.08));
  border: 1px solid rgba(124,58,237,0.3);
  border-left: 4px solid var(--ai-purple);
  border-radius: 8px;
  padding: 1.2rem 1.5rem;
  margin: 1.5rem 0;
  position: relative;
}

.ai-callout::before {
  content: attr(data-icon);
  position: absolute;
  top: -12px;
  left: 1rem;
  background: var(--md-default-bg-color);
  padding: 0 0.5rem;
  font-size: 1.2rem;
}

.ai-callout-title {
  font-weight: 700;
  color: #a78bfa;
  margin-bottom: 0.5rem;
}

/* ---- Progress bar estil ---- */
.progress-container {
  margin: 1.5rem 0;
}

.progress-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.progress-label {
  font-size: 0.85rem;
  min-width: 150px;
  color: #c4b5fd;
}

.progress-bar-bg {
  flex: 1;
  height: 10px;
  background: rgba(255,255,255,0.07);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-inner {
  height: 100%;
  border-radius: 999px;
  animation: progressFill 1.5s ease-out both;
}

@keyframes progressFill {
  from { width: 0; }
}

.progress-bar-inner.high   { background: linear-gradient(90deg, #10b981, #34d399); }
.progress-bar-inner.medium { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-bar-inner.low    { background: linear-gradient(90deg, #ef4444, #f87171); }

.progress-pct {
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 35px;
  text-align: right;
  color: #94a3b8;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .hero-title { font-size: 1.8rem; }
  .concept-grid { grid-template-columns: 1fr; }
  .rag-pipeline { flex-direction: column; align-items: stretch; }
  .rag-arrow { transform: rotate(90deg); text-align: center; }
  .react-loop { max-width: 100%; }
  .comparison-table { font-size: 0.8rem; }
  .comparison-table th, .comparison-table td { padding: 0.6rem; }
}
