/* ============================================================
   RAG.CSS — RAG page specific styles
   ============================================================ */

/* RAG page uses its own root variables (separate from global.css) */
:root {
  --bg-primary: #0b0d13;
  --bg-secondary: #11131a;
  --bg-tertiary: #161822;
  --surface: #1a1d28;
  --surface-high: #22263a;
  --primary: #00d1ff;
  --primary-dim: rgba(0,209,255,0.12);
  --accent: #7c5cff;
  --accent-dim: rgba(124,92,255,0.15);
  --success: #00c853;
  --warning: #ffc107;
  --error: #ff5252;
  --border-ghost: rgba(255,255,255,0.06);
  --border-subtle: rgba(255,255,255,0.12);
  --text-primary: #e8eaf0;
  --text-secondary: #8891a8;
  --text-muted: #555d73;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --gold: #ffd700;
  --gold-dim: rgba(255,215,0,0.12);
  --silver: #c0c0c0;
  --bronze: #cd7f32;
}

/* RAG overrides for shared globals (when loaded after global.css) */
.rag-page { background: var(--bg-primary); }
.rag-page .top-navbar { background: var(--surface-high); }

/* Main container */
.main-container { max-width: 1400px; margin: 0 auto; padding: 32px 24px; }
.page-header { margin-bottom: 28px; }
.page-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 12px; }
.page-subtitle { color: var(--text-secondary); font-size: 0.9rem; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 28px;
  border: 1px solid var(--border-ghost);
  width: fit-content;
}
.tab {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab:hover { color: var(--text-primary); }
.tab.active { background: var(--surface); color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

/* Card */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-ghost);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* Medallion diagram */
.medallion-diagram { display: flex; align-items: center; justify-content: center; gap: 0; margin: 24px 0; }
.medallion-layer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 28px;
  border-radius: var(--radius-md);
  border: 2px solid;
  min-width: 140px;
}
.medallion-layer.bronze { background: rgba(205,127,50,0.08); border-color: rgba(205,127,50,0.4); color: #cd7f32; }
.medallion-layer.silver { background: rgba(192,192,192,0.08); border-color: rgba(192,192,192,0.4); color: #c0c0c0; }
.medallion-layer.gold { background: rgba(255,215,0,0.08); border-color: rgba(255,215,0,0.4); color: #ffd700; }
.medallion-layer .layer-icon { font-size: 2rem; }
.medallion-layer .layer-name { font-weight: 700; font-size: 0.9rem; }
.medallion-layer .layer-desc { font-size: 0.72rem; opacity: 0.8; text-align: center; max-width: 120px; }
.medallion-arrow { font-size: 1.5rem; color: var(--text-muted); margin: 0 8px; }
.medallion-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 16px;
  padding: 10px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning);
}

/* Tables grid */
.tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.table-card {
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all 0.2s;
  cursor: pointer;
}
.table-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(255,215,0,0.1); }
.table-card.not-indexed { border-color: var(--border-subtle); }
.table-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.table-name .badge { font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.badge.gold { background: var(--gold-dim); color: var(--gold); }
.badge.indexed { background: var(--success); color: #000; }
.badge.pending { background: rgba(255,193,7,0.2); color: var(--warning); }
.table-meta { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 12px; }
.table-actions { display: flex; gap: 8px; }

/* Index card */
.index-card {
  background: var(--bg-secondary);
  border: 1px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}
.index-card-title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.form-input {
  background: var(--surface);
  border: 1px solid var(--border-ghost);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.9rem;
  width: 100%;
  font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--primary); }
.index-actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; flex-wrap: wrap; }

/* Q&A layout */
.qa-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; min-height: 460px; }
.qa-sidebar { display: flex; flex-direction: column; gap: 6px; }
.sidebar-title { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 8px; }
.sidebar-item {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: all 0.2s;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-item:hover { background: var(--surface); color: var(--text-primary); }
.sidebar-item.selected { background: var(--gold-dim); color: var(--gold); border-color: rgba(255,215,0,0.2); }
.qa-main { display: flex; flex-direction: column; }
.qa-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
  padding: 40px;
  border: 1px dashed var(--border-ghost);
  border-radius: var(--radius-md);
}
.qa-empty-icon { font-size: 3rem; opacity: 0.5; }
.qa-empty-text { font-size: 0.9rem; line-height: 1.5; }
.qa-chat { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.qa-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 500px;
  padding: 4px;
}

/* Messages */
.message {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 95%;
}
.message.user {
  background: var(--surface-high);
  color: var(--text-primary);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.message.assistant {
  background: var(--gold-dim);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,215,0,0.15);
}
.message.assistant table { border-collapse: collapse; width: auto; margin: 12px 0; font-size: 0.85rem; }
.message.assistant table th { background: rgba(255,215,0,0.15); color: var(--gold); padding: 8px 14px; text-align: left; font-weight: 600; border: 1px solid rgba(255,215,0,0.25); }
.message.assistant table td { padding: 7px 14px; border: 1px solid var(--border-ghost); color: var(--text-primary); }
.message.assistant table tr:nth-child(even) td { background: rgba(255,255,255,0.03); }
.message.assistant table tr:hover td { background: rgba(255,215,0,0.05); }
.message.assistant p:first-child { margin-top: 0; }
.message.assistant p:last-child { margin-bottom: 0; }
.message.assistant ul, .message.assistant ol { margin: 8px 0; padding-left: 20px; }
.message.assistant li { margin: 4px 0; }
.message.assistant strong { color: var(--gold); }

/* Sources panel */
.sources-panel {
  background: var(--surface);
  border: 1px solid var(--border-ghost);
  border-radius: var(--radius-md);
  padding: 12px;
  max-height: 120px;
  overflow-y: auto;
}
.sources-title { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.source-item { font-size: 0.8rem; color: var(--text-secondary); padding: 5px 0; border-bottom: 1px solid var(--border-ghost); }
.source-item:last-child { border-bottom: none; }
.source-label { color: var(--gold); font-weight: 600; margin-right: 6px; }

/* Q&A input row */
.qa-input-row { display: flex; gap: 10px; margin-top: 10px; }
.qa-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border-ghost);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  transition: border-color 0.2s;
}
.qa-input:focus { outline: none; border-color: var(--primary); }
.qa-input::placeholder { color: var(--text-muted); }

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--primary); color: #0b0d13; }
.btn-primary:hover { background: #33daff; box-shadow: 0 4px 16px rgba(0,209,255,0.3); }
.btn-gold { background: var(--gold-dim); color: var(--gold); border: 1px solid rgba(255,215,0,0.3); }
.btn-gold:hover { background: rgba(255,215,0,0.2); }
.btn-outline { background: transparent; border: 1px solid var(--border-subtle); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: rgba(255,82,82,0.15); color: var(--error); border: 1px solid rgba(255,82,82,0.3); }
.btn-danger:hover { background: rgba(255,82,82,0.25); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Plan alert */
.plan-alert {
  background: rgba(255,193,7,0.08);
  border: 1px solid rgba(255,193,7,0.25);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--warning);
}

/* Tutorial steps */
.tutorial-step { border: 1px solid var(--border-ghost); border-radius: var(--radius-md); margin-bottom: 12px; }
.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.step-header:hover { background: var(--surface-high); }
.step-number {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary-dim);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem;
  flex-shrink: 0;
}
.step-title { flex: 1; font-weight: 600; font-size: 0.95rem; }
.step-duration { font-size: 0.75rem; color: var(--text-muted); }
.step-toggle {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-high);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  transition: transform 0.2s;
}
.step-header.open .step-toggle { transform: rotate(180deg); }
.step-content { display: none; border-top: 1px solid var(--border-ghost); }
.step-content.open { display: block; }
.step-body { padding: 20px; }
.step-description { font-size: 0.9rem; line-height: 1.65; color: var(--text-secondary); margin-bottom: 16px; }
.step-description strong { color: var(--text-primary); }

/* Concept box */
.concept-box {
  background: var(--accent-dim);
  border: 1px solid rgba(124,92,255,0.25);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin: 12px 0;
  font-size: 0.875rem;
  line-height: 1.5;
}
.concept-box .concept-title { font-weight: 700; color: var(--accent); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }

/* Code block */
.code-block { background: #0d1117; border: 1px solid var(--border-ghost); border-radius: var(--radius-md); margin: 12px 0; overflow: hidden; }
.code-header {
  background: var(--surface);
  padding: 10px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-ghost);
  display: flex;
  align-items: center;
  gap: 8px;
}
.code-header .lang-badge { background: var(--primary-dim); color: var(--primary); padding: 2px 8px; border-radius: 4px; font-size: 0.7rem; }
.code-content {
  padding: 16px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #e6e6e6;
  white-space: pre;
}
.code-content .comment { color: #8b949e; }
.code-content .keyword { color: #ff7b72; }
.code-content .string { color: #a5d6ff; }
.code-content .function { color: #d2a8ff; }
.code-content .number { color: #79c0ff; }
.copy-btn { margin-left: auto; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.75rem; padding: 4px 8px; border-radius: 4px; transition: all 0.2s; }
.copy-btn:hover { color: var(--primary); background: var(--primary-dim); }

/* Info box */
.info-box { background: var(--surface); border-radius: var(--radius-md); padding: 16px; margin: 12px 0; border-left: 3px solid var(--primary); }
.info-box-title { font-weight: 600; font-size: 0.875rem; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.info-box p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }

/* Video grid */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.video-card { background: var(--surface); border: 1px solid var(--border-ghost); border-radius: var(--radius-md); overflow: hidden; transition: all 0.2s; }
.video-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.video-thumbnail { width: 100%; aspect-ratio: 16/9; background: #000; display: flex; align-items: center; justify-content: center; font-size: 3rem; position: relative; }
.video-thumbnail::after { content: '▶'; position: absolute; font-size: 2rem; opacity: 0.9; }
.video-info { padding: 12px; }
.video-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
.video-meta { font-size: 0.75rem; color: var(--text-muted); }

/* Indexing overlay */
.indexing-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(11,13,19,0.88);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.indexing-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 40px 48px;
  text-align: center;
  max-width: 440px;
  box-shadow: 0 24px 80px rgba(255,215,0,0.2);
}
.indexing-spinner { width: 52px; height: 52px; border: 3px solid rgba(255,215,0,0.2); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 0 auto 20px; }
.indexing-title { font-size: 1.1rem; font-weight: 700; color: var(--gold); margin-bottom: 8px; }
.indexing-subtitle { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 20px; }
.indexing-steps { text-align: left; }
.indexing-step { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 0.85rem; color: var(--text-secondary); }
.indexing-step.done { color: var(--success); }
.indexing-step.active { color: var(--gold); }
.indexing-step-icon { font-size: 1.1rem; width: 20px; text-align: center; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--surface-high); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 12px 20px; font-size: 0.875rem; z-index: 9999; box-shadow: 0 8px 32px rgba(0,0,0,0.5); animation: slideIn 0.3s ease; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }

/* Spinner */
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-ghost); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state-icon { font-size: 3rem; opacity: 0.4; margin-bottom: 12px; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state-text { font-size: 0.875rem; line-height: 1.5; }

/* Hidden */
.hidden { display: none !important; }

/* Scroll fix for tutorial steps */
html { overflow-x: hidden; }
body { overflow-x: hidden; }