/* ── AI Intelligence Dashboard — Design System ──────────────── */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(18, 18, 30, 0.7);
  --bg-card-hover: rgba(25, 25, 40, 0.8);
  --border: rgba(124, 58, 237, 0.15);
  --border-hover: rgba(124, 58, 237, 0.35);

  --text-primary: #f0f0f5;
  --text-secondary: #9898b0;
  --text-muted: #5a5a75;

  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.3);
  --accent-gradient: linear-gradient(135deg, #7c3aed, #4f46e5);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── Ambient Background ───────────────────────────────────────── */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  animation: float 20s ease-in-out infinite;
}
.orb-1 {
  width: 600px; height: 600px;
  background: var(--accent);
  top: -200px; left: -100px;
  animation-delay: 0s;
}
.orb-2 {
  width: 500px; height: 500px;
  background: #4f46e5;
  bottom: -150px; right: -100px;
  animation-delay: -7s;
  animation-duration: 25s;
}
.orb-3 {
  width: 400px; height: 400px;
  background: #06b6d4;
  top: 40%; left: 50%;
  animation-delay: -14s;
  animation-duration: 30s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
}

/* ── Glass Card ───────────────────────────────────────────────── */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.glass-card:hover {
  border-color: var(--border-hover);
}

/* ── Header ───────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.logo {
  font-size: 2rem;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}
.header-title {
  font-size: 1.4rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}
.header-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* ── Bridge Status ────────────────────────────────────────────── */
.bridge-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  position: relative;
}
.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}
.status-dot.online::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--success);
  animation: pingDot 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.status-dot.offline { background: var(--text-muted); }
.status-dot.researching {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: pulse 1s ease-in-out infinite;
}
.status-dot.error { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

@keyframes pingDot {
  75%, 100% { transform: scale(2); opacity: 0; }
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px rgba(124, 58, 237, 0.5);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
}
.btn-sm:hover { opacity: 0.85; }

.btn-icon { font-size: 1.1rem; }

/* ── Main Layout ──────────────────────────────────────────────── */
.main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  max-width: 1440px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ── Report Panel ─────────────────────────────────────────────── */
.report-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Running State ────────────────────────────────────────────── */
.running-card {
  text-align: center;
  padding: 3rem 2rem;
  position: relative;
}
.pulse-ring {
  position: absolute;
  top: 50%; left: 50%;
  width: 120px; height: 120px;
  transform: translate(-50%, -70%);
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: pulseRing 2s ease-out infinite;
}
@keyframes pulseRing {
  0% { transform: translate(-50%, -70%) scale(0.8); opacity: 1; }
  100% { transform: translate(-50%, -70%) scale(2); opacity: 0; }
}
.running-icon { font-size: 3rem; margin-bottom: 1rem; position: relative; z-index: 1; }
.running-card h2 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.running-status { color: var(--text-secondary); margin-bottom: 1.5rem; }
.progress-bar {
  width: 100%;
  max-width: 300px;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  margin: 0 auto 1rem;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 30%;
  background: var(--accent-gradient);
  border-radius: 2px;
  animation: progress 3s ease-in-out infinite;
}
@keyframes progress {
  0% { width: 5%; margin-left: 0; }
  50% { width: 40%; margin-left: 30%; }
  100% { width: 5%; margin-left: 95%; }
}
.running-time { color: var(--text-muted); font-size: 0.8rem; }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-card {
  text-align: center;
  padding: 4rem 2rem;
}
.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-card h2 { font-size: 1.3rem; margin-bottom: 0.75rem; color: var(--text-secondary); }
.empty-card p { color: var(--text-muted); max-width: 400px; margin: 0 auto 0.5rem; }
.empty-hint { font-size: 0.8rem; }

/* ── Report Header ────────────────────────────────────────────── */
.report-header { padding: 1.5rem; }
.report-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}
.report-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.stat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.stat-icon { font-size: 0.9rem; }

/* ── Section Cards ────────────────────────────────────────────── */
.section-card {
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.section-card:hover {
  box-shadow: 0 8px 40px rgba(124, 58, 237, 0.08);
}
.highlight-card {
  border-color: rgba(124, 58, 237, 0.3);
  background: rgba(124, 58, 237, 0.06);
}
.highlight-card:hover {
  border-color: rgba(124, 58, 237, 0.5);
  box-shadow: 0 8px 40px rgba(124, 58, 237, 0.15);
}

.section-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}
.section-header:hover {
  background: rgba(255,255,255,0.02);
}
.section-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 0.1rem; }
.section-title-wrap { flex: 1; min-width: 0; }
.section-title-wrap h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.section-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.section-chevron {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform var(--transition);
  margin-top: 0.3rem;
}
.section-card.expanded .section-chevron {
  transform: rotate(180deg);
}

.section-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0 1.5rem;
}
.section-card.expanded .section-body {
  max-height: 3000px;
  padding: 0 1.5rem 1.5rem;
}

/* ── Section Content Styles ───────────────────────────────────── */
.item-card {
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: rgba(255,255,255,0.025);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}
.item-card:last-child { margin-bottom: 0; }
.item-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}
.item-label {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.35rem;
  margin-bottom: 0.35rem;
}
.label-high { background: rgba(239,68,68,0.15); color: #f87171; }
.label-medium { background: rgba(245,158,11,0.15); color: #fbbf24; }
.label-low { background: rgba(16,185,129,0.15); color: #34d399; }
.label-type { background: rgba(59,130,246,0.15); color: #60a5fa; }
.label-status { background: rgba(124,58,237,0.15); color: var(--accent-light); }
.item-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.4rem;
}
.item-source {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.item-source a {
  color: var(--accent-light);
  text-decoration: none;
}
.item-source a:hover { text-decoration: underline; }

.guide-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.8;
  white-space: pre-wrap;
}

.advisor-block {
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  background: rgba(124,58,237,0.04);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(124,58,237,0.1);
}
.advisor-block:last-child { margin-bottom: 0; }
.advisor-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-light);
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.advisor-text {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.7;
}

/* Tech table */
.tech-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.tech-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.tech-table td {
  padding: 0.6rem 0.75rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.tech-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 5.5rem;
  align-self: start;
  max-height: calc(100vh - 6.5rem);
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sidebar-card { padding: 1.25rem; }
.sidebar-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.sidebar-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ── Queue ────────────────────────────────────────────────────── */
.queue-input-wrap {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.queue-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.82rem;
  outline: none;
  transition: border-color var(--transition);
}
.queue-input:focus { border-color: var(--accent); }
.queue-input::placeholder { color: var(--text-muted); }

.queue-list {
  list-style: none;
}
.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.35rem;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.queue-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
  transition: color var(--transition);
}
.queue-remove:hover { color: var(--danger); }

/* ── History ──────────────────────────────────────────────────── */
.history-item {
  display: block;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
}
.history-item:hover { background: rgba(255,255,255,0.04); }
.history-item.active { background: rgba(124,58,237,0.1); border-left: 3px solid var(--accent); }
.history-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}
.history-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── AI Copilot Chat ──────────────────────────────────────────── */
.chat-messages {
  max-height: 250px;
  overflow-y: auto;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.5rem;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.message {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.4;
  max-width: 90%;
  word-wrap: break-word;
}
.ai-message {
  background: rgba(124, 58, 237, 0.1);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.user-message {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.typing-indicator {
  font-style: italic;
  color: var(--text-muted);
  animation: pulse 1.5s infinite;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
}
.chat-form input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.82rem;
  outline: none;
  transition: border-color var(--transition);
}
.chat-form input:focus { border-color: var(--accent); }
.chat-form input::placeholder { color: var(--text-muted); }

.icon-btn {
  background: var(--accent);
  border: none;
  color: white;
  min-width: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition);
}
.icon-btn:hover:not(:disabled) { opacity: 0.85; }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.trigger-container {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}
.trigger-topic-preview {
  font-size: 0.75rem;
  color: var(--success);
  margin-bottom: 0.5rem;
  font-weight: 600;
}
.full-width { width: 100%; justify-content: center; }

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

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.section-card {
  animation: fadeIn 0.4s ease-out both;
}
.section-card:nth-child(2) { animation-delay: 0.05s; }
.section-card:nth-child(3) { animation-delay: 0.1s; }
.section-card:nth-child(4) { animation-delay: 0.15s; }
.section-card:nth-child(5) { animation-delay: 0.2s; }
.section-card:nth-child(6) { animation-delay: 0.25s; }
.section-card:nth-child(7) { animation-delay: 0.3s; }
.section-card:nth-child(8) { animation-delay: 0.35s; }
.section-card:nth-child(9) { animation-delay: 0.4s; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
  .sidebar {
    position: static;
    max-height: none;
  }
  .header {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
  }
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
}
