/* CSS variables for consistent theming */
:root {
  --bg-dark: #07080d;
  --bg-card: rgba(16, 20, 35, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 242, 254, 0.15);

  --text-primary: #f1f3f9;
  --text-secondary: #9aa2b5;
  --text-muted: #626a7e;

  --teal-glow: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  --purple-glow: linear-gradient(135deg, #b19ffb 0%, #7d5fff 100%);
  --blue-glow: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  --emerald-glow: linear-gradient(135deg, #0ba360 0%, #3cba92 100%);

  --accent-teal: #00f2fe;
  --accent-purple: #7d5fff;
  --accent-blue: #2a5298;
  --accent-emerald: #3cba92;
  --accent-red: #ff5e62;
  --accent-yellow: #ffb300;
}

/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

body {
  font-family:
    "Outfit",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background-color: var(--bg-dark);
  background-image:
    radial-gradient(at 10% 20%, rgba(125, 95, 255, 0.08) 0px, transparent 50%),
    radial-gradient(at 90% 10%, rgba(0, 242, 254, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Custom Scrollbar for Webkit */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  color: var(--accent-teal);
  filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.5));
}

.logo-text h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #00f2fe, #b19ffb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-indicator.online {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.status-indicator.running {
  background-color: var(--accent-yellow);
  box-shadow: 0 0 8px var(--accent-yellow);
  animation: pulse 1.5s infinite;
}

/* Workspace Layout */
.workspace-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  flex-grow: 1;
}

/* Sidebar Panel */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Glass Cards */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-icon {
  width: 20px;
  height: 20px;
}

.text-teal {
  color: var(--accent-teal);
}
.text-purple {
  color: var(--accent-purple);
}

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Query Input Styles */
textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s ease;
}

textarea:focus {
  border-color: var(--accent-teal);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
}

/* Suggestion Tags */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion-tag {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.suggestion-tag:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Buttons */
.gradient-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--teal-glow);
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.gradient-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 242, 254, 0.35);
}

.gradient-btn:active {
  transform: translateY(0);
}

.gradient-btn:disabled {
  background: var(--text-muted);
  color: rgba(255, 255, 255, 0.4);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-icon {
  width: 16px;
  height: 16px;
}

/* Pipeline Graph Styles */
.pipeline-graph {
  display: flex;
  flex-direction: column;
  padding-left: 10px;
}

.pipeline-node {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  transition: all 0.3s ease;
}

.node-bullet {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.node-bullet i {
  width: 14px;
  height: 14px;
}

.node-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.pipeline-line {
  width: 2px;
  height: 20px;
  background: var(--border-color);
  margin-left: 11px;
  transition: all 0.3s ease;
}

/* Pipeline Node States */
.pipeline-node.completed .node-bullet {
  background: rgba(60, 186, 146, 0.2);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

.pipeline-node.completed .node-label {
  color: var(--text-primary);
}

.pipeline-node.active .node-bullet {
  background: rgba(0, 242, 254, 0.15);
  border-color: var(--accent-teal);
  color: var(--accent-teal);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
  animation: activePulse 2s infinite;
}

.pipeline-node.active .node-label {
  color: #fff;
  font-weight: 600;
  text-shadow: 0 0 8px rgba(0, 242, 254, 0.3);
}

.pipeline-line.completed {
  background: var(--accent-emerald);
}

.pipeline-line.active {
  background: linear-gradient(
    180deg,
    var(--accent-emerald),
    var(--accent-teal)
  );
}

@keyframes activePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(0, 242, 254, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 242, 254, 0);
  }
}

@keyframes pulse {
  0% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.5;
  }
}

/* Right Output Panel */
.output-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Navigation Tabs */
.output-tabs {
  display: flex;
  gap: 10px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  width: fit-content;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn i {
  width: 15px;
  height: 15px;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: #000;
  background: var(--teal-glow);
  font-weight: 600;
}

/* Tab Contents */
.tab-contents {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.tab-content {
  display: none;
  flex-grow: 1;
  animation: fadeIn 0.4s ease;
}

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

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

/* Glass Inner Card */
.glass-inner-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 25px;
  min-height: 500px;
  flex-grow: 1;
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.01);
}

/* Report Viewer Action Bar */
.viewer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 20px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.action-btn i {
  width: 14px;
  height: 14px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  flex-grow: 1;
}

.large-empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  stroke-width: 1.5;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.85rem;
  max-width: 300px;
}

/* Markdown Rendering Style overrides */
.markdown-body {
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 0.95rem;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  color: #fff;
}

.markdown-body h1 {
  font-size: 1.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.markdown-body h2 {
  font-size: 1.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 6px;
}

.markdown-body p {
  margin-bottom: 16px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 20px;
  margin-bottom: 16px;
}

.markdown-body li {
  margin-bottom: 6px;
}

.markdown-body pre {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 10px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.markdown-body code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
}

.markdown-body blockquote {
  border-left: 4px solid var(--accent-teal);
  padding: 0 15px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 12px;
}

.markdown-body th {
  background: rgba(255, 255, 255, 0.04);
}

/* State Blocks */
.state-blocks {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.state-section {
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 16px 20px;
  transition: all 0.3s ease;
}

.card-gradient-purple {
  background: linear-gradient(
    135deg,
    rgba(125, 95, 255, 0.08) 0%,
    rgba(0, 0, 0, 0) 100%
  );
  border-left: 4px solid var(--accent-purple);
}
.card-gradient-teal {
  background: linear-gradient(
    135deg,
    rgba(0, 242, 254, 0.08) 0%,
    rgba(0, 0, 0, 0) 100%
  );
  border-left: 4px solid var(--accent-teal);
}
.card-gradient-blue {
  background: linear-gradient(
    135deg,
    rgba(30, 60, 114, 0.15) 0%,
    rgba(0, 0, 0, 0) 100%
  );
  border-left: 4px solid var(--accent-blue);
}
.card-gradient-emerald {
  background: linear-gradient(
    135deg,
    rgba(11, 163, 96, 0.08) 0%,
    rgba(0, 0, 0, 0) 100%
  );
  border-left: 4px solid var(--accent-emerald);
}

.state-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.state-section h3 i {
  width: 16px;
  height: 16px;
}

.state-data {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.15);
  padding: 10px 15px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

/* Selected Papers Tab styling */
.section-title {
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
}

.section-title h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.section-title p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.papers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.paper-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.paper-card h4 {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
}

.paper-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.paper-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.badge.category {
  background: rgba(125, 95, 255, 0.15);
  color: #c0b3ff;
}

/* Live Terminal Log Styles */
.terminal-card {
  background: #050609;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  height: 520px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0b0d14;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.red {
  background-color: var(--accent-red);
}
.dot.yellow {
  background-color: var(--accent-yellow);
}
.dot.green {
  background-color: var(--accent-emerald);
}

.terminal-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.clear-logs-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s ease;
}

.clear-logs-btn:hover {
  color: var(--accent-red);
}

.clear-logs-btn i {
  width: 12px;
  height: 12px;
}

.terminal-body {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  padding: 15px;
  flex-grow: 1;
  overflow-y: auto;
  color: #d1d8e6;
  display: flex;
  flex-direction: column;
  gap: 8px;
  line-height: 1.5;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line.system-line {
  color: var(--text-muted);
}
.log-line.node-line {
  color: #fbc2eb;
  font-weight: 700;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 6px;
  margin-top: 4px;
}
.log-line.tool-line {
  color: var(--accent-teal);
}
.log-line.error-line {
  color: var(--accent-red);
  font-weight: 500;
}
.log-line.text-line {
  color: #d1d8e6;
}
.log-line.complete-line {
  color: var(--accent-emerald);
  font-weight: bold;
  border-bottom: 1.5px dashed var(--accent-emerald);
  padding-bottom: 6px;
}

/* Responsive adjustments */
@media (max-width: 1100px) {
  .workspace-layout {
    grid-template-columns: 1fr;
  }
}
