/* NewsLens - Dark Theme */
*, *::before, *::after {
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #1e2130;
  --bg-hover: #252838;
  --text-primary: #e1e4eb;
  --text-secondary: #8b8fa3;
  --text-muted: #5c6073;
  --border: #2a2d3e;
  --accent: #6c8cff;
  --accent-hover: #5a7aff;

  --bias-left: #4a90d9;
  --bias-lean-left: #7bacd4;
  --bias-center: #8b8fa3;
  --bias-lean-right: #d4877b;
  --bias-right: #d94a4a;

  --star-color: #f5c542;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-header {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sidebar-header h1 span {
  color: var(--accent);
}

.sidebar-section {
  padding: 8px 12px;
}

.sidebar-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 8px 4px;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  text-align: left;
}

.filter-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  font-weight: 500;
}

.filter-btn .badge {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-left { background: var(--bias-left); }
.badge-lean-left { background: var(--bias-lean-left); }
.badge-center { background: var(--bias-center); }
.badge-lean-right { background: var(--bias-lean-right); }
.badge-right { background: var(--bias-right); }

/* Stats box */
.stats-box {
  margin: 16px 12px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.stats-box h4 {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 3px 0;
}

.stats-row .label {
  color: var(--text-secondary);
}

.stats-row .value {
  font-weight: 600;
  color: var(--text-primary);
}

.stats-bar {
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 10px;
  gap: 2px;
}

.stats-bar-segment {
  height: 100%;
  border-radius: 2px;
  min-width: 2px;
}

/* Action buttons in sidebar */
.sidebar-actions {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.action-btn {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  margin-bottom: 8px;
  transition: all 0.15s;
  text-align: center;
}

.action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.action-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.action-btn.primary:hover {
  background: var(--accent-hover);
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: 280px;
  padding: 24px 32px;
  max-width: 900px;
}

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

.feed-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.feed-count {
  font-size: 13px;
  color: var(--text-muted);
}

/* Search */
.search-bar {
  margin-bottom: 20px;
}

.search-bar input {
  width: 100%;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus {
  border-color: var(--accent);
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

/* Article cards */
.article-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
}

.article-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.article-card.read {
  opacity: 0.6;
}

.article-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.source-name {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.bias-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bias-badge.left { background: var(--bias-left); color: #fff; }
.bias-badge.lean-left { background: var(--bias-lean-left); color: #fff; }
.bias-badge.center { background: var(--bias-center); color: #fff; }
.bias-badge.lean-right { background: var(--bias-lean-right); color: #fff; }
.bias-badge.right { background: var(--bias-right); color: #fff; }

.article-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

.article-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.article-summary {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.article-star {
  float: right;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 4px;
  transition: all 0.15s;
}

.article-star:hover,
.article-star.starred {
  color: var(--star-color);
}

/* Article Reader View */
.reader {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px;
}

.reader-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.reader-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
  transition: color 0.15s;
}

.reader-back:hover {
  color: var(--accent);
}

.reader-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 16px;
}

.reader-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.reader-meta .source-name {
  font-size: 14px;
}

.reader-meta .article-time {
  font-size: 13px;
}

.reader-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.reader-actions button,
.reader-actions a {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

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

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.reader-content {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-primary);
}

.reader-content p {
  margin-bottom: 16px;
}

.no-content {
  color: var(--text-muted);
  font-style: italic;
  padding: 40px 0;
  text-align: center;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
}

.loading-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

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

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  .reader {
    padding: 16px 8px;
  }
  .reader-title {
    font-size: 22px;
  }
}

/* Mobile sidebar toggle */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .sidebar.open {
    display: block;
    z-index: 50;
  }
}

/* ==================== Feed Tabs & Sort ==================== */

.feed-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.feed-tab {
  padding: 8px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s;
}

.feed-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.feed-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.sort-modes {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.sort-btn {
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}

.sort-btn:hover {
  color: var(--text-secondary);
  border-color: var(--text-muted);
}

.sort-btn.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

/* ==================== Don't Miss Section ==================== */

.dont-miss {
  margin-bottom: 28px;
}

.dont-miss-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dont-miss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.dont-miss-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid var(--accent);
}

.dont-miss-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.dont-miss-card .dm-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.dont-miss-card .dm-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.dont-miss-card .dm-sources {
  font-weight: 600;
  color: var(--accent);
}

/* ==================== Story Cards ==================== */

.story-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.story-card:hover {
  background: var(--bg-hover);
  border-color: rgba(108, 140, 255, 0.3);
  transform: translateY(-1px);
}

.story-card.expanded {
  border-color: var(--accent);
}

.story-headline {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.story-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.source-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: rgba(108, 140, 255, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
}

.story-time {
  font-size: 12px;
  color: var(--text-muted);
}

/* Bias distribution bar */
.bias-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  gap: 1px;
  margin-bottom: 12px;
}

.bias-bar-segment {
  height: 100%;
  border-radius: 3px;
  min-width: 3px;
  transition: width 0.3s;
}

.bias-bar-segment.left { background: var(--bias-left); }
.bias-bar-segment.center { background: var(--bias-center); }
.bias-bar-segment.right { background: var(--bias-right); }

/* Source pills */
.source-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.source-pill {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.source-pill.more {
  color: var(--text-muted);
  font-style: italic;
  border: none;
  background: none;
  padding-left: 2px;
}

.story-summary {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-top: 8px;
}

/* Expanded story view */
.story-expanded {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease, padding 0.3s ease;
  margin-top: 0;
  padding-top: 0;
}

.story-expanded.open {
  max-height: 2000px;
  opacity: 1;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.bias-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

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

.bias-column {
  min-width: 0;
}

.bias-column-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}

.bias-column-header .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.bias-column-header .dot.left { background: var(--bias-left); }
.bias-column-header .dot.center { background: var(--bias-center); }
.bias-column-header .dot.right { background: var(--bias-right); }

.bias-column .cluster-article {
  padding: 8px 0;
  border-bottom: 1px solid rgba(42, 45, 62, 0.5);
}

.bias-column .cluster-article:last-child {
  border-bottom: none;
}

.cluster-article-source {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.cluster-article-title {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.35;
  cursor: pointer;
  transition: color 0.15s;
}

.cluster-article-title:hover {
  color: var(--accent);
}

.cluster-article-title a {
  color: inherit;
  text-decoration: none;
}

.cluster-article-title a:hover {
  color: var(--accent);
}

.cluster-article-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.bias-column-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 0;
}

/* ==================== Bias legend under bar ==================== */

.bias-bar-legend {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 8px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Collapsible bias columns */
.bias-column-header.collapsible {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bias-column-header.collapsible:hover {
  color: var(--text-primary);
}

.collapse-arrow {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.bias-column-articles {
  transition: max-height 0.3s ease, opacity 0.2s ease;
  overflow: hidden;
}

.bias-column-articles.collapsed {
  max-height: 0;
  opacity: 0;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 49;
}

.sidebar-overlay.active {
  display: block;
}
