/* Agent Article Styles */

/* Pyodide Cell Styles */
.pyodide-cell {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin: 24px 0;
}

.pyodide-cell .demo-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pyodide-cell .demo-badge {
  background: #3b82f6;
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.pyodide-cell .demo-badge-final {
  background: #10b981;
}

.pyodide-cell .demo-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-color);
}

.pyodide-cell textarea.pyodide-code {
  width: 100%;
  font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  resize: vertical;
  tab-size: 4;
}

.pyodide-cell textarea.pyodide-code:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.pyodide-cell textarea.pyodide-code[readonly] {
  background: #1e293b;
  cursor: default;
  resize: none;
}

.pyodide-cell textarea.pyodide-code[readonly]:focus {
  border-color: var(--border-color);
  box-shadow: none;
}

.pyodide-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.pyodide-controls button {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.pyodide-controls button:hover:not(:disabled) {
  background: #2563eb;
  transform: translateY(-1px);
}

.pyodide-controls button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.pyodide-controls button[data-pyodide-action="clear"] {
  background: var(--bg-secondary);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.pyodide-controls button[data-pyodide-action="clear"]:hover:not(:disabled) {
  background: var(--border-color);
}

.pyodide-status {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-left: auto;
}

.pyodide-status[data-status-type="success"] {
  color: #10b981;
}

.pyodide-status[data-status-type="error"] {
  color: #ef4444;
}

.pyodide-output {
  background: #0f172a;
  color: #f1f5f9;
  font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  padding: 16px;
  border-radius: 8px;
  margin-top: 12px;
  min-height: 100px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  white-space: pre-wrap;
  word-break: break-word;
}

.pyodide-output:empty::before {
  content: "Clique sur 'Exécuter' pour voir le résultat...";
  color: #64748b;
  font-style: italic;
}

.pyodide-output-line {
  display: block;
  padding: 2px 0;
}

.pyodide-output-line.error {
  color: #f87171;
}

/* Solution dropdown */
details {
  margin: 20px 0;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

details summary {
  padding: 12px 16px;
  background: var(--bg-secondary);
  cursor: pointer;
  user-select: none;
}

details summary:hover {
  background: var(--border-color);
}

details[open] summary {
  border-bottom: 1px solid var(--border-color);
}

.solution-code {
  margin: 0;
  padding: 0;
}

.solution-code pre {
  margin: 0;
  padding: 16px;
  background: #0f172a;
  overflow-x: auto;
}

.solution-code code {
  font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #e2e8f0;
  white-space: pre;
}

/* Mini Demo Styles (legacy) */
.mini-demo {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  margin: 20px 0;
}

.demo-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.demo-badge {
  background: #3b82f6;
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.demo-badge-final {
  background: #10b981;
}

.demo-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-color);
}

/* Flow visualization */
.demo-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.flow-box {
  background: var(--bg-color);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
  font-size: 0.85rem;
  min-width: 80px;
  transition: all 0.3s ease;
  opacity: 0.5;
}

.flow-box.active {
  opacity: 1;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  transform: scale(1.02);
}

.flow-box.user {
  border-color: #8b5cf6;
}

.flow-box.llm {
  border-color: #3b82f6;
}

.flow-box.json {
  border-color: #f59e0b;
  font-family: monospace;
  font-size: 0.75rem;
}

.flow-box.output {
  border-color: #10b981;
}

.flow-box.code {
  border-color: #ef4444;
}

.flow-box.result {
  border-color: #10b981;
}

.flow-arrow {
  color: var(--text-secondary);
  font-size: 1.2rem;
  opacity: 0.5;
}

/* Halt warning */
.demo-halt {
  background: #fef3c7;
  border: 2px solid #f59e0b;
  color: #92400e;
  padding: 12px 16px;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  margin: 16px 0;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.demo-halt.blink {
  opacity: 1;
  animation: pulse 1s ease-in-out 3;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* Run button */
.demo-run-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  margin: 12px 0;
}

.demo-run-btn:hover:not(:disabled) {
  background: var(--border-color);
}

.demo-run-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.demo-run-btn.btn-primary {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.demo-run-btn.btn-primary:hover:not(:disabled) {
  background: #2563eb;
}

/* Output */
.demo-output {
  background: #0f172a;
  color: #f1f5f9;
  font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 16px;
  border-radius: 8px;
  margin-top: 12px;
  min-height: 120px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
}

.demo-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-line {
  padding: 2px 0;
}

.log-line .timestamp {
  color: #64748b;
  font-size: 0.8rem;
  margin-right: 8px;
}

.json-output {
  background: #0f172a;
  padding: 12px;
  border-radius: 6px;
  margin: 8px 0;
  color: #10b981;
  overflow-x: auto;
}

.code-call {
  color: #60a5fa;
  padding-left: 16px;
}

/* Full agent demo */
.agent-full {
  background: linear-gradient(135deg, var(--bg-color) 0%, var(--bg-secondary) 100%);
}

.agent-status-mini {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 6px;
}

.agent-visualizer-mini {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 16px 0;
  padding: 12px;
  background: var(--bg-color);
  border-radius: 8px;
}

.mini-step {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.8rem;
  text-align: center;
  transition: all 0.3s ease;
  opacity: 0.5;
}

.mini-step.active {
  opacity: 1;
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  transform: scale(1.05);
}

.mini-arrow {
  color: var(--text-secondary);
  font-size: 1rem;
}

.agent-code-mini {
  background: #0f172a;
  border-radius: 8px;
  margin: 16px 0;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.agent-code-mini pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
}

.agent-code-mini code {
  font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #f1f5f9;
}

.agent-console {
  min-height: 200px;
  max-height: 400px;
}

/* Dark mode adjustments */
[data-theme="dark"] .demo-halt {
  background: rgba(245, 158, 11, 0.15);
}

[data-theme="dark"] .agent-code-mini {
  background: #0f172a;
}

[data-theme="dark"] .demo-output {
  background: #0f172a;
}

/* Step output styling */
.step-output {
  padding: 10px 12px;
  margin: 6px 0;
  border-radius: 6px;
  border-left: 4px solid;
  font-size: 0.9rem;
  line-height: 1.5;
}

.step-output strong {
  color: #f1f5f9;
}

.step-llm {
  border-left-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
}

.step-tool {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

.step-result {
  border-left-color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.step-final {
  border-left-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.1);
}

.step-error {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Responsive */
@media (max-width: 600px) {
  .demo-flow {
    flex-direction: column;
  }
  
  .flow-arrow {
    transform: rotate(90deg);
  }
  
  .agent-visualizer-mini {
    flex-direction: column;
  }
  
  .mini-arrow {
    transform: rotate(90deg);
  }
}
