:root {
  --bg-deep: #060810;
  --bg-surface: #0b0f1a;
  --bg-card: rgba(18, 24, 40, 0.7);
  --border: rgba(255, 255, 255, 0.08);
  --border-cyan: rgba(0, 240, 255, 0.3);
  --cyan: #00f0ff;
  --indigo: #6366f1;
  --purple: #a855f7;
  --emerald: #10b981;
  --green: #00ff88;
  --rose: #f43f5e;
  --red: #ff3366;
  --amber: #f59e0b;
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --font-sans: 'Outfit', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* --- Top Navigation --- */
.top-nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo-badge {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--cyan), var(--indigo));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #000;
  font-size: 1.25rem;
}

.logo-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.3px; }
.logo-sub { font-size: 0.72rem; color: var(--text-muted); font-family: var(--font-mono); }

.nav-tabs {
  display: flex;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.4);
  padding: 0.3rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-tab:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.nav-tab.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(99, 102, 241, 0.2));
  color: var(--cyan);
  border: 1px solid var(--border-cyan);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--emerald);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

/* --- Content Container --- */
.tab-content-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tab-pane {
  display: none;
  flex: 1;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
}

.pane-inner {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.section-header {
  margin-bottom: 1.5rem;
}
.section-header h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.4rem; letter-spacing: -0.5px; }
.section-header p { color: var(--text-muted); font-size: 0.95rem; }

/* --- Full Width Chat Container --- */
.chat-container {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  height: calc(100vh - 65px);
  display: flex;
  flex-direction: column;
  padding: 1rem 1.5rem;
  gap: 0.8rem;
}

/* --- Telemetry & Health Bar --- */
.chat-telemetry-bar {
  background: rgba(11, 15, 26, 0.85);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  backdrop-filter: blur(8px);
}

.telemetry-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.telemetry-label { color: var(--text-muted); font-weight: 500; }
.telemetry-val { font-family: var(--font-mono); font-weight: 600; }
.val-green { color: var(--green); }
.val-cyan { color: var(--cyan); }
.val-purple { color: #c084fc; }
.val-red { color: var(--red); }
.val-good { color: var(--green); }
.val-rose { color: var(--rose); }
.val-emerald { color: var(--emerald); }

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulseAnim 2s infinite;
}

@keyframes pulseAnim {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(0, 255, 136, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); }
}

.btn-ping {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ping:hover { background: rgba(0, 240, 255, 0.15); color: var(--cyan); border-color: var(--border-cyan); }

/* --- Chat Main Full Area --- */
.chat-main-full {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.chat-history {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.chat-bubble {
  max-width: 88%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.user-bubble {
  align-self: flex-end;
}
.user-bubble .bubble-body {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px 12px 2px 12px;
  color: #fff;
}

.bot-bubble {
  align-self: flex-start;
}
.bot-bubble .bubble-body {
  background: rgba(18, 24, 40, 0.7);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 2px;
  color: var(--text-main);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.bubble-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.bubble-avatar {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
}
.bot-bubble .bubble-avatar { background: var(--cyan); color: #000; }

.bubble-badge {
  font-size: 0.68rem;
  background: rgba(0, 240, 255, 0.1);
  color: var(--cyan);
  border: 1px solid var(--border-cyan);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.bubble-body {
  padding: 0.9rem 1.1rem;
  font-size: 0.92rem;
  line-height: 1.6;
}

.telemetry-badge-container {
  margin-top: 0.6rem;
  padding: 0.35rem 0.75rem;
  background: rgba(0, 240, 255, 0.05);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--cyan);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* --- Progress Bar --- */
.gen-progress-bar {
  padding: 0.4rem 1.2rem;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid var(--border);
}

.progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  animation: progressAnim 1.5s infinite linear;
}

@keyframes progressAnim {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

.progress-text {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--cyan);
  margin-top: 0.3rem;
}

/* --- Chat Input Wrapper --- */
.chat-input-wrapper {
  padding: 0.8rem 1.2rem;
  background: rgba(0,0,0,0.3);
  border-top: 1px solid var(--border);
}

.chat-input-bar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  background: #080c18;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  transition: border 0.2s;
}

.chat-input-bar:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

#chatInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  padding: 0.4rem;
}

.btn-send {
  background: linear-gradient(135deg, var(--cyan), var(--indigo));
  border: none;
  color: #000;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.btn-send:hover { transform: scale(1.05); }

.input-caption {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  text-align: center;
  font-family: var(--font-mono);
}

/* --- Cards & Tables --- */
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), var(--indigo));
  border: none;
  color: #000;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }

.benchmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.haystack-card {
  background: #090d1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  opacity: 0.6;
  transition: all 0.3s;
}

.needle-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.needle-query {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
}

.retrieved-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
  font-style: italic;
}

.status-tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 700;
}
.tag-pass { background: rgba(0, 255, 136, 0.15); color: var(--green); border: 1px solid rgba(0,255,136,0.3); }
.tag-fail { background: rgba(255, 51, 102, 0.15); color: var(--red); border: 1px solid rgba(255,51,102,0.3); }
.tag-warn { background: rgba(245, 158, 11, 0.15); color: var(--amber); border: 1px solid rgba(245,158,11,0.3); }

.stats-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-box {
  background: #080c18;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}
.stat-number { font-size: 1.6rem; font-weight: 800; font-family: var(--font-mono); color: var(--cyan); margin-bottom: 0.2rem; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th, .data-table td {
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: rgba(0,0,0,0.3);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.data-table tr:hover { background: rgba(255,255,255,0.02); }

/* --- Diagram Styles --- */
.diagram-container {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.diagram-block {
  background: #080c18;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.diagram-arrow {
  text-align: center;
  color: var(--cyan);
  font-size: 1.1rem;
}

.block-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.3rem; color: var(--cyan); }
.block-desc { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }

.rif-interception-box {
  margin-top: 0.8rem;
  background: rgba(0, 240, 255, 0.05);
  border: 1px solid var(--border-cyan);
  border-radius: 8px;
  padding: 0.8rem;
}

.interception-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 0.6rem;
}

.interception-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.8rem;
}

.sub-block {
  background: rgba(0,0,0,0.4);
  border-radius: 6px;
  padding: 0.6rem;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* --- Swagger Accordion Styles --- */
.swagger-endpoint {
  background: #080c18;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.8rem;
  overflow: hidden;
}

.endpoint-header {
  padding: 0.8rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  user-select: none;
}

.http-method {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  color: #000;
}
.method-post { background: var(--green); }
.method-get { background: var(--cyan); }

.endpoint-path { font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem; }
.endpoint-summary { color: var(--text-muted); font-size: 0.8rem; flex: 1; }
.expand-icon { color: var(--text-muted); font-size: 0.8rem; }

.endpoint-body {
  display: none;
  padding: 1.2rem;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}

.swagger-endpoint.open .endpoint-body { display: block; }
.swagger-endpoint.open .expand-icon { transform: rotate(180deg); }

.code-block {
  background: #04060c;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--cyan);
  overflow-x: auto;
  line-height: 1.5;
}
