/* AlgoTester Design System & Color Tokens */
:root {
  --bg-app: #080c14;
  --bg-panel: rgba(15, 23, 42, 0.75);
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-terminal: #030712;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: #6366f1;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-cyan: #06b6d4;
  --accent-error: #ef4444;
  --accent-warning: #f59e0b;
  --accent-success: #10b981;
  
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  --glass-filter: blur(14px);
}

/* Light Theme Variables */
body.light-theme {
  --bg-app: #f1f5f9;
  --bg-panel: rgba(255, 255, 255, 0.9);
  --bg-card: rgba(248, 250, 252, 0.95);
  --bg-terminal: #1e293b;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-active: #4f46e5;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --shadow-glow: 0 4px 20px rgba(99, 102, 241, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 45%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.08) 0px, transparent 45%),
    radial-gradient(at 50% 50%, rgba(239, 68, 68, 0.04) 0px, transparent 50%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Glassmorphism Panel */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: var(--glass-filter);
  -webkit-backdrop-filter: var(--glass-filter);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

/* App Header */
.app-header {
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(8, 12, 20, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #ef4444 0%, #f59e0b 50%, #6366f1 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.35);
}

.brand-badge-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.light-theme .brand-title {
  background: linear-gradient(to right, #0f172a, #334155);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.version-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.brand-tagline {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.quick-samples-dropdown {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sample-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sample-dropdown {
  background: var(--bg-terminal);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.sample-dropdown:hover,
.sample-dropdown:focus {
  border-color: var(--border-active);
}

.btn-icon {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-card);
  border-color: var(--border-active);
}

/* Steps Progress Bar */
.steps-progress-bar {
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 2rem;
}

.steps-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.step-item.active {
  opacity: 1;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-terminal);
  border: 2px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  transition: all 0.3s ease;
}

.step-item.active .step-num {
  border-color: var(--accent-primary);
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

.step-meta {
  display: flex;
  flex-direction: column;
}

.step-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.step-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border-subtle);
  margin: 0 1rem;
}

@media (max-width: 800px) {
  .step-subtitle {
    display: none;
  }
}

/* Main Container Layout */
.main-container {
  max-width: 1440px;
  margin: 1.5rem auto;
  padding: 0 2rem;
  flex: 1;
  width: 100%;
}

.algotester-grid {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .algotester-grid {
    grid-template-columns: 1fr;
  }
}

/* Panels */
.input-panel,
.results-panel {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 560px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.step-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.field-step {
  font-size: 0.7rem;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-weight: 800;
}

.char-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.language-selector-wrap {
  display: flex;
  gap: 0.5rem;
}

.form-select {
  flex: 1;
  background: var(--bg-terminal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
}

.form-select:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.textarea-wrapper {
  position: relative;
}

.form-textarea {
  width: 100%;
  background: var(--bg-terminal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-textarea.error-terminal {
  border-left: 3px solid var(--accent-error);
}

.form-textarea:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 0.4rem 0;
  user-select: none;
}

.optional-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.chevron-icon {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.chevron-icon.open {
  transform: rotate(180deg);
}

.collapsible-body {
  display: none;
  margin-top: 0.35rem;
}

.collapsible-body.open {
  display: block;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-primary-hover) 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-large {
  width: 100%;
  padding: 0.85rem;
  font-size: 0.98rem;
}

.btn-subtle {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s;
}

.btn-subtle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-copy {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-copy:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  gap: 0.85rem;
  flex: 1;
}

.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 1.15rem;
  color: var(--text-primary);
}

.empty-state p {
  max-width: 380px;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Results Content */
.solution-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: fadeIn 0.3s ease-out;
}

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

.error-classification-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md);
}

.banner-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.error-type-tag {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: #fca5a5;
}

.severity-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.lang-tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Solution Cards */
.solution-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-understand {
  border-left: 4px solid var(--accent-warning);
}

.card-solution {
  border-left: 4px solid var(--accent-success);
}

.card-step-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.step-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.card-step-badge h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.subhead {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.plain-english-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.root-cause-text {
  font-size: 0.88rem;
  line-height: 1.6;
  color: #e2e8f0;
}

.triggers-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.triggers-list li {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding-left: 1.2rem;
  position: relative;
  line-height: 1.4;
}

.triggers-list li::before {
  content: "•";
  position: absolute;
  left: 0.3rem;
  color: var(--accent-warning);
  font-size: 1.1rem;
}

.solution-strategy {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-primary);
}

/* Code Diff / Fix Block */
.code-diff-container {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-terminal);
}

.diff-header {
  background: rgba(255, 255, 255, 0.04);
  padding: 0.5rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.diff-editor {
  padding: 0.85rem;
  overflow-x: auto;
}

.code-pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: #38bdf8;
}

.prevention-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}

.prevention-box p {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #a7f3d0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #10b981;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 1.25rem 2rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: rgba(8, 12, 20, 0.8);
  margin-top: auto;
}
