/* ═══════════════════════════════════════════════════════════
   AINewz DASHBOARD — Design System
   Brand: Black bg · #BFF549 accent · Inter · 0px radius
═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ─── CSS Variables ─────────────────────────────────────── */
:root {
  --bg: #000000;
  --bg-1: #0a0a0a;
  --bg-2: #111111;
  --bg-3: #1a1a1a;
  --bg-4: #222222;
  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(191, 245, 73, 0.25);

  --accent: #BFF549;
  --accent-dim: rgba(191, 245, 73, 0.12);
  --accent-glow: rgba(191, 245, 73, 0.3);

  --text-primary: #ffffff;
  --text-secondary: #888888;
  --text-muted: #555555;

  --link: #99A1AF;

  /* Source colors */
  --c-bens: #BFF549;
  --c-rundown: #5B8DEF;
  --c-reddit: #FF6B35;
  --c-saved: #A855F7;

  --sidebar-w: 240px;
  --topbar-h: 72px;

  --font: 'Inter', -apple-system, sans-serif;
  --radius: 0px;
  --radius-sm: 4px;
  --radius-md: 8px;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 24px rgba(191, 245, 73, 0.15);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
}

input,
select {
  font-family: var(--font);
}

.hidden {
  display: none !important;
}

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-4);
  border-radius: 2px;
}

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

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-text {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 20px 12px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-3);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-3);
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 28px;
  text-align: center;
}

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

/* Sidebar Status */
.sidebar-status {
  padding: 16px 16px 24px;
  border-top: 1px solid var(--border);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-dot.live {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse-dot 2s infinite;
}

.status-dot.error {
  background: #ef4444;
}

.status-dot.loading {
  background: #f59e0b;
  animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.status-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.status-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-left: 16px;
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.refresh-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.refresh-btn svg {
  width: 14px;
  height: 14px;
}

.refresh-btn.spinning svg {
  animation: spin 1s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════════
   MAIN LAYOUT
═══════════════════════════════════════════════════════════ */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.sidebar-toggle:hover {
  background: var(--bg-3);
  color: var(--text-primary);
}

.sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

.topbar-title h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Search */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px 9px 38px;
  color: var(--text-primary);
  font-size: 14px;
  width: 220px;
  transition: all var(--transition);
  outline: none;
}

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

.search-input:focus {
  border-color: var(--accent);
  background: var(--bg-3);
  box-shadow: 0 0 0 3px var(--accent-dim);
  width: 260px;
}

/* Sort */
.sort-select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: all var(--transition);
}

.sort-select:hover,
.sort-select:focus {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ─── Stats Bar ──────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 12px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.stat-card {
  flex: 1;
  min-width: 100px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-2);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-value.source-bens {
  color: var(--c-bens);
}

.stat-value.source-rundown {
  color: var(--c-rundown);
}

.stat-value.source-reddit {
  color: var(--c-reddit);
}

.stat-value.source-saved {
  color: var(--c-saved);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── Error Banner ───────────────────────────────────────── */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 28px 0;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 13px;
}

.error-banner svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ─── Articles Section ───────────────────────────────────── */
.articles-section {
  flex: 1;
  padding: 24px 28px 40px;
}

/* Grid */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ─── Article Card ───────────────────────────────────────── */
.article-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.4s ease both;
}

.article-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--source-color, var(--accent));
  opacity: 0;
  transition: opacity var(--transition);
}

.article-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.article-card:hover::before {
  opacity: 1;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Card Hero Image ────────────────────────────────────── */
.card-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-3);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.article-card:hover .card-image img {
  transform: scale(1.04);
}

.card-image-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px;
  background: linear-gradient(to bottom,
      rgba(0, 0, 0, 0.55) 0%,
      rgba(0, 0, 0, 0) 50%,
      rgba(0, 0, 0, 0.7) 100%);
}

.card-image-overlay .save-btn {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

.card-image-overlay .save-btn:hover {
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
}

.card-image-overlay .save-btn.saved {
  color: var(--c-saved);
  background: rgba(168, 85, 247, 0.2);
}

/* ─── Card Body (text content) ───────────────────────────── */
.card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

/* Card top row (no-image variant) */
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 18px 0;
}

.source-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 2px;
}

.badge-bens {
  background: rgba(191, 245, 73, 0.12);
  color: var(--c-bens);
}

.badge-rundown {
  background: rgba(91, 141, 239, 0.12);
  color: var(--c-rundown);
}

.badge-reddit {
  background: rgba(255, 107, 53, 0.12);
  color: var(--c-reddit);
}

/* Save button */
.save-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition);
  flex-shrink: 0;
}

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

.save-btn.saved {
  color: var(--c-saved);
}

.save-btn svg {
  width: 15px;
  height: 15px;
}

.save-btn.saved svg {
  fill: var(--c-saved);
}

/* Card title */
.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Card summary */
.card-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Card footer */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

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

.card-meta svg {
  width: 12px;
  height: 12px;
}

.card-score {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--c-reddit);
  font-weight: 600;
}

.card-score svg {
  width: 12px;
  height: 12px;
}

.card-read-link {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

.article-card:hover .card-read-link {
  opacity: 1;
}

.card-read-link svg {
  width: 11px;
  height: 11px;
}

/* ─── Skeleton Loaders ───────────────────────────────────── */
.skeleton-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sk-badge,
.sk-title,
.sk-body,
.sk-footer {
  background: var(--bg-3);
  border-radius: 2px;
  animation: shimmer 1.5s ease-in-out infinite;
}

.sk-badge {
  height: 18px;
  width: 80px;
}

.sk-title {
  height: 16px;
  width: 100%;
}

.sk-title.short {
  width: 70%;
}

.sk-body {
  height: 13px;
  width: 100%;
}

.sk-body.short {
  width: 85%;
}

.sk-footer {
  height: 12px;
  width: 60%;
  margin-top: 8px;
}

@keyframes shimmer {
  0% {
    opacity: 0.4;
  }

  50% {
    opacity: 0.8;
  }

  100% {
    opacity: 0.4;
  }
}

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  gap: 16px;
}

.empty-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.empty-icon svg {
  width: 32px;
  height: 32px;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 32px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

.modal-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 2px;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--bg-3);
  color: var(--text-primary);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.modal-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.modal-summary {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  background: var(--accent);
  color: #000;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-primary:hover {
  background: #d4ff5e;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary svg {
  width: 14px;
  height: 14px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-secondary:hover {
  border-color: var(--c-saved);
  color: var(--c-saved);
  background: rgba(168, 85, 247, 0.08);
}

.btn-secondary.saved {
  border-color: var(--c-saved);
  color: var(--c-saved);
  background: rgba(168, 85, 247, 0.08);
}

.btn-secondary.saved svg {
  fill: var(--c-saved);
}

.btn-secondary svg {
  width: 14px;
  height: 14px;
}

/* ═══════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  z-index: 999;
  animation: toastIn 0.3s ease;
  box-shadow: var(--shadow-card);
  max-width: 320px;
}

@keyframes toastIn {
  from {
    transform: translateY(12px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast.success {
  border-color: var(--accent);
  color: var(--accent);
}

.toast.error {
  border-color: #ef4444;
  color: #fca5a5;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .articles-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.8);
  }

  .main {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .topbar {
    padding: 0 16px;
  }

  .articles-section {
    padding: 16px;
  }

  .stats-bar {
    padding: 16px;
  }

  .search-input {
    width: 160px;
  }

  .search-input:focus {
    width: 200px;
  }
}

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

  .stats-bar {
    gap: 8px;
  }

  .stat-value {
    font-size: 22px;
  }

  .topbar-right {
    gap: 8px;
  }

  .sort-select {
    display: none;
  }
}