/* ══════════════════════════════════════════════
   NEXUS — Multi Agent Research System
   Dark Cinematic Theme + Glassmorphism
   ══════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #06060c;
  --bg-secondary: #0c0c18;
  --glass-bg: rgba(12, 12, 30, 0.55);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-hover: rgba(255, 255, 255, 0.08);
  --text-primary: #e8e8f0;
  --text-secondary: #8888a8;
  --text-muted: #555570;
  --cyan: #00d4ff;
  --purple: #8b5cf6;
  --magenta: #f472b6;
  --emerald: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --gradient-main: linear-gradient(135deg, #00d4ff, #8b5cf6);
  --gradient-warm: linear-gradient(135deg, #f472b6, #8b5cf6);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  cursor: none;
}

/* ── Custom Scrollbar ─────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.5); }

/* ── Canvas Background ────────────────────── */
#particleCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── Ambient Background Orbs ─────────────── */
#ambientOrbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.06;
  animation: orbFloat 30s ease-in-out infinite;
}

.orb-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #00d4ff, transparent 70%);
  top: -10%;
  right: -5%;
  animation-duration: 28s;
  opacity: 0.07;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #8b5cf6, transparent 70%);
  bottom: 0;
  left: -10%;
  animation-duration: 32s;
  animation-delay: -10s;
  opacity: 0.06;
}

.orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #f472b6, transparent 70%);
  top: 50%;
  right: -10%;
  animation-duration: 36s;
  animation-delay: -16s;
  opacity: 0.04;
}

.orb-4 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #10b981, transparent 70%);
  bottom: -10%;
  left: 30%;
  animation-duration: 30s;
  animation-delay: -22s;
  opacity: 0.04;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(40px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(30px, 40px) scale(1.03); }
}

/* ── Cursor Glow ──────────────────────────── */
#cursorGlow {
  position: fixed;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.5) 0%, transparent 70%);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: width 0.25s var(--ease), height 0.25s var(--ease), opacity 0.25s var(--ease);
  mix-blend-mode: screen;
}

#cursorGlow.hovering {
  width: 48px;
  height: 48px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.5) 0%, transparent 70%);
}

/* ── Click Ripples ────────────────────────── */
#rippleContainer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(0, 212, 255, 0.4);
  transform: translate(-50%, -50%) scale(0);
  animation: rippleExpand 0.8s var(--ease) forwards;
}

@keyframes rippleExpand {
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
    width: 300px;
    height: 300px;
  }
}

/* ── App Layout ───────────────────────────── */
#app {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px 60px;
}

/* ── Header ───────────────────────────────── */
#header {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
}

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

.logo-icon {
  display: flex;
  align-items: center;
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(0, 212, 255, 0.3)); }
  50% { filter: drop-shadow(0 0 12px rgba(0, 212, 255, 0.6)); }
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 3px;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding-left: 4px;
  border-left: 1px solid var(--text-muted);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  animation: dotPulse 2s ease-in-out infinite;
}

.header-status.running .status-dot {
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.5);
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Glass Panel ──────────────────────────── */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 36px;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.glass-panel:hover {
  border-color: var(--glass-hover);
  box-shadow: 0 0 40px rgba(0, 212, 255, 0.03);
}

/* ── Main Workspace ───────────────────────── */
#workspace {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ── Input Section ────────────────────────── */
#inputSection {
  text-align: center;
  padding: 56px 40px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.1;
  margin-bottom: 14px;
}

.gradient-text {
  background: var(--gradient-main);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.6;
  max-width: 520px;
  margin: 0 auto 32px;
}

.input-container { max-width: 600px; margin: 0 auto; }

.input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 56px;
  padding: 6px 6px 6px 20px;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.input-wrapper:focus-within {
  border-color: rgba(0, 212, 255, 0.3);
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.07);
}

.input-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  margin-right: 10px;
}

#topicInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 12px 0;
  cursor: none;
}

#topicInput::placeholder { color: var(--text-muted); }

.submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-main);
  color: white;
  cursor: none;
  flex-shrink: 0;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.submit-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.submit-btn:active { transform: scale(0.95); }

.submit-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Section Titles ───────────────────────── */
.section-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

/* ── Pipeline Section ─────────────────────── */
#pipelineSection { padding: 0; }

.pipeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.pipeline-timer {
  font-family: 'Space Grotesk', monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 2px;
}

.pipeline-steps {
  display: flex;
  align-items: center;
  gap: 0;
}

.step-card {
  position: relative;
  flex: 1;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  transition: border-color 0.4s var(--ease), box-shadow 0.4s var(--ease), transform 0.3s var(--ease);
}

.step-progress-border {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-main);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s var(--ease);
}

.step-card.running .step-progress-border {
  transform: scaleX(1);
  animation: progressPulse 1.5s ease-in-out infinite;
}

.step-card.done .step-progress-border {
  transform: scaleX(1);
  animation: none;
}

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

.step-card.running {
  border-color: rgba(0, 212, 255, 0.25);
  box-shadow: 0 0 25px rgba(0, 212, 255, 0.06);
  transform: translateY(-2px);
}

.step-card.done {
  border-color: rgba(16, 185, 129, 0.25);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.04);
}

.step-number {
  font-family: var(--font-display);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 2px;
}

.step-card.running .step-number { color: var(--cyan); }
.step-card.done .step-number { color: var(--emerald); }

.step-name {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.step-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 2.8em;
}

.step-card.running .step-desc { color: var(--text-secondary); }

.step-status {
  display: flex;
  align-items: center;
  margin-top: 4px;
}

.step-status-icon {
  display: flex;
  align-items: center;
  color: var(--text-muted);
}

.step-card.running .step-status-icon {
  color: var(--cyan);
  animation: spin 1.5s linear infinite;
}

.step-card.done .step-status-icon { color: var(--emerald); }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.step-connector {
  width: 20px;
  height: 1px;
  background: var(--glass-border);
  flex-shrink: 0;
}

/* ── Report Section ───────────────────────── */
.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.report-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.report-topic {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 56px;
  border: 1px solid rgba(0, 212, 255, 0.25);
  background: rgba(0, 212, 255, 0.06);
  color: var(--cyan);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: none;
  transition: all 0.3s var(--ease);
  letter-spacing: 0.3px;
}

.download-btn:hover {
  background: rgba(0, 212, 255, 0.12);
  border-color: rgba(0, 212, 255, 0.45);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.1);
  transform: translateY(-1px);
}

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

/* ── Upload & Cancel Buttons ───────────────────────── */
.upload-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: none;
  padding: 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease);
}

.upload-btn:hover {
  color: var(--cyan);
  background: rgba(0, 212, 255, 0.1);
}

.cancel-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: none;
  padding: 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease);
}

.cancel-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.upload-status {
  font-size: 0.75rem;
  color: var(--cyan);
  margin-top: 10px;
  text-align: left;
  padding-left: 10px;
}

.remove-attachment {
  color: #ef4444;
  cursor: pointer;
  margin-left: 8px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.remove-attachment:hover {
  color: #f87171;
  text-decoration: underline;
}

/* ── Source Cards ───────────────────────── */
.sources-container {
  margin-top: 24px;
  margin-bottom: 24px;
}

.sources-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

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

.source-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s var(--ease);
  cursor: none;
}

.source-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(0, 212, 255, 0.3);
  transform: translateY(-2px);
}

.source-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--cyan);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-url {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-snippet {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.report-container { padding: 40px; }

.report-content {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.report-content h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin: 28px 0 12px;
  letter-spacing: -0.5px;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.report-content h1:first-child { margin-top: 0; }

.report-content h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 24px 0 10px;
  color: var(--text-primary);
}

.report-content h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 18px 0 8px;
  color: var(--text-secondary);
}

.report-content p { margin-bottom: 14px; }

.report-content ul, .report-content ol {
  margin: 8px 0 14px 22px;
}

.report-content li {
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.report-content li::marker { color: var(--cyan); }

.report-content strong { color: #fff; font-weight: 600; }

.report-content a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 212, 255, 0.2);
  transition: border-color 0.2s;
}

.report-content a:hover { border-color: var(--cyan); }

.report-content code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: rgba(139, 92, 246, 0.12);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--purple);
}

.report-content pre {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
  font-size: 0.85rem;
}

.report-content pre code {
  background: none;
  padding: 0;
  color: var(--text-secondary);
}

.report-content hr {
  border: none;
  height: 1px;
  background: var(--glass-border);
  margin: 24px 0;
}

.report-content blockquote {
  border-left: 3px solid var(--purple);
  padding: 10px 18px;
  margin: 12px 0;
  color: var(--text-secondary);
  background: rgba(139, 92, 246, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ── Feedback Section ─────────────────────── */
.feedback-container {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.feedback-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 90px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.15);
}

.score-number {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.score-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.feedback-content {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.feedback-content strong { color: var(--text-primary); }

/* ── Error Section ────────────────────────── */
.error-container {
  text-align: center;
  padding: 40px;
}

.error-icon {
  font-size: 2.5rem;
  margin-bottom: 14px;
}

.error-message {
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.retry-btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 28px;
  border-radius: 56px;
  border: 1px solid rgba(0, 212, 255, 0.3);
  background: transparent;
  color: var(--cyan);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: none;
  transition: all 0.3s var(--ease);
}

.retry-btn:hover {
  background: rgba(0, 212, 255, 0.08);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.1);
}

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

/* ── Animations ───────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.5s var(--ease) forwards;
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 768px) {
  body { cursor: auto; }
  #cursorGlow { display: none; }
  .hero-title { font-size: 2rem; }
  #inputSection { padding: 36px 20px; }
  .pipeline-steps { flex-direction: column; }
  .step-connector { width: 1px; height: 14px; }
  .glass-panel { padding: 24px; }
  .report-container { padding: 24px; }
  .feedback-container { flex-direction: column; }
}
