/* Spyglass Dashboard Styles
   Matches landing page design tokens */

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

:root {
  --bg: #060a12;
  --surface: #0d1320;
  --surface-hover: #111827;
  --border: #1a2234;
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.12);
  --accent-hover: #00e6b8;
  --blue: #4a9eff;
  --blue-dim: rgba(74, 158, 255, 0.12);
  --red: #ff4a6a;
  --red-dim: rgba(255, 74, 106, 0.12);
  --yellow: #ffb84a;
  --yellow-dim: rgba(255, 184, 74, 0.12);
  --text: #e2e8f0;
  --muted: #8892a4;
  --heading: #f8fafc;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 212, 170, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 170, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* Layout */
.app {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Top Nav */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.topnav-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--heading);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon svg {
  width: 16px;
  height: 16px;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all 0.15s;
  font-weight: 500;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: rgba(255,255,255,0.1);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255, 74, 106, 0.2);
}

.btn-danger:hover {
  background: rgba(255, 74, 106, 0.2);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  font-weight: 500;
}

.stat-card .value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.02em;
}

.stat-card .value.accent {
  color: var(--accent);
}

.stat-card .sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.02em;
}

.page-header .subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4px;
}

/* Cards / Panels */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--heading);
}

.card-body {
  padding: 24px;
}

.card-body.no-pad {
  padding: 0;
}

/* Report Content (Markdown) */
.report-content {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text);
}

.report-content h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--heading);
  margin: 32px 0 16px 0;
  letter-spacing: -0.02em;
}

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

.report-content h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--heading);
  margin: 28px 0 12px 0;
  letter-spacing: -0.01em;
}

.report-content h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--heading);
  margin: 20px 0 8px 0;
}

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

.report-content strong {
  color: var(--heading);
  font-weight: 600;
}

.report-content ul, .report-content ol {
  margin: 8px 0 16px 20px;
}

.report-content li {
  margin-bottom: 6px;
}

.report-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.report-content th {
  text-align: left;
  font-weight: 600;
  color: var(--heading);
  padding: 10px 16px;
  border-bottom: 2px solid var(--border);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.report-content td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.report-content tr:last-child td {
  border-bottom: none;
}

.report-content code {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

.report-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--muted);
  font-style: italic;
}

/* Report List */
.report-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.report-list-item:last-child {
  border-bottom: none;
}

.report-list-item:hover {
  background: var(--surface-hover);
}

.report-list-item .title {
  font-weight: 600;
  color: var(--heading);
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.report-list-item .meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  gap: 16px;
}

.report-list-item .arrow {
  color: var(--muted);
  font-size: 1.2rem;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-success {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 170, 0.2);
}

.badge-warning {
  background: var(--yellow-dim);
  color: var(--yellow);
  border: 1px solid rgba(255, 184, 74, 0.2);
}

.badge-error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255, 74, 106, 0.2);
}

.badge-blue {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid rgba(74, 158, 255, 0.2);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--heading);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 20px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--muted);
  gap: 12px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Analyzing indicator */
.analyzing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
}

.analyzing .pulse-ring {
  width: 80px;
  height: 80px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.analyzing .pulse-ring svg {
  width: 32px;
  height: 32px;
  color: var(--accent);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.7; }
}

.analyzing h3 {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--heading);
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.analyzing p {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Source Form */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: var(--accent);
}

.form-group input::placeholder {
  color: #4a5568;
}

.form-group .hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  z-index: 1000;
  animation: slideUp 0.3s ease;
  max-width: 400px;
}

.toast.error {
  border-color: rgba(255, 74, 106, 0.3);
  color: var(--red);
}

.toast.success {
  border-color: rgba(0, 212, 170, 0.3);
  color: var(--accent);
}

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

/* Trend chart (simple CSS bars) */
.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
  padding: 8px 0;
}

.trend-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  opacity: 0.7;
  transition: opacity 0.15s;
  position: relative;
}

.trend-bar:hover {
  opacity: 1;
}

.trend-bar .tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  color: var(--text);
  margin-bottom: 4px;
}

.trend-bar:hover .tooltip {
  display: block;
}

/* Modal / Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--heading);
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* Source list item */
.source-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.source-item:last-child {
  border-bottom: none;
}

.source-item .source-info h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--heading);
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.source-item .source-info .meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.source-item .source-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Responsive */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .topnav {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }

  .topnav-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Section visibility */
.section { display: none; }
.section.active { display: block; }
