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

:root {
  --font-family: 'Assistant', 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Heebo', 'Assistant', sans-serif;

  /* Light Theme Palette */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.85);
  --bg-secondary: #f1f5f9;
  --bg-input: #f8fafc;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  --accent-primary: #0284c7;
  --accent-primary-hover: #0369a1;
  --accent-glow: rgba(2, 132, 199, 0.15);

  --live-dot: #10b981;
  --live-dot-pulse: rgba(16, 185, 129, 0.35);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-card-hover: 0 12px 20px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Category colors */
  --cat-security: #dc2626;
  --cat-politics: #2563eb;
  --cat-economy: #059669;
  --cat-tech: #7c3aed;
  --cat-law: #d97706;
  --cat-foreign: #0284c7;
  --cat-society: #0d9488;
  --cat-default: #64748b;
}

[data-theme="dark"] {
  --bg-app: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #162032;
  --bg-header: rgba(15, 23, 42, 0.85);
  --bg-secondary: #1e293b;
  --bg-input: #1e293b;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --border-color: #1e293b;
  --border-focus: #38bdf8;

  --accent-primary: #38bdf8;
  --accent-primary-hover: #7dd3fc;
  --accent-glow: rgba(56, 189, 248, 0.2);

  --live-dot: #34d399;
  --live-dot-pulse: rgba(52, 211, 153, 0.35);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-card-hover: 0 12px 24px -3px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(56, 189, 248, 0.2);

  --cat-security: #f87171;
  --cat-politics: #60a5fa;
  --cat-economy: #34d399;
  --cat-tech: #a78bfa;
  --cat-law: #fbbf24;
  --cat-foreign: #38bdf8;
  --cat-society: #2dd4bf;
  --cat-default: #94a3b8;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  direction: rtl;
  text-align: right;
  min-height: 100vh;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
}

/* Header & Glassmorphism Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.live-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-secondary);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--live-dot);
  box-shadow: 0 0 0 0 var(--live-dot-pulse);
  animation: pulse-ring 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 var(--live-dot-pulse); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.icon-btn {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1rem;
}

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

/* Main Container & Hero Controls */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.search-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 0.75rem 2.75rem 0.75rem 1.25rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.search-clear-btn {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  display: none;
}

.search-clear-btn.visible {
  display: block;
}

/* Category Filter Pills */
.category-filter-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
}

.category-filter-bar::-webkit-scrollbar {
  height: 4px;
}

.category-filter-bar::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: var(--radius-full);
}

.filter-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-pill:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background-color: var(--bg-secondary);
}

.filter-pill.active {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.pill-count {
  font-size: 0.725rem;
  opacity: 0.85;
  background-color: rgba(0, 0, 0, 0.08);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
}

.filter-pill.active .pill-count {
  background-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Toast Banner */
.update-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: var(--text-primary);
  color: var(--bg-card);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transition: transform var(--transition-normal);
  cursor: pointer;
}

.update-toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Feed Stats Header */
.feed-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

/* News Grid Layout */
.news-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 768px) {
  .news-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .news-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* News Card */
.news-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.news-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background-color: var(--card-accent-color, var(--accent-primary));
}

.news-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
  background-color: var(--bg-card-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-category {
  font-size: 0.775rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--card-accent-color, var(--accent-primary));
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.card-category::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  margin-top: 0.25rem;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sentence-line {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.narrative-gaps-box {
  background-color: var(--bg-secondary);
  border-right: 3px solid var(--accent-primary);
  padding: 0.6rem 0.8rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.gaps-title {
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.sources-container {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.775rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.source-chip:hover {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

.external-icon {
  font-size: 0.7rem;
  opacity: 0.7;
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1.5rem;
  background-color: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

/* Skeleton Loading Animation */
.skeleton-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  height: 220px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.skeleton-line {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-color) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* History Timeline Drawer/Modal */
.history-modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.history-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.history-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  max-width: 440px;
  background-color: var(--bg-card);
  box-shadow: var(--shadow-lg);
  z-index: 310;
  transform: translateX(-100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.history-modal-overlay.open .history-drawer {
  transform: translateX(0);
}

.drawer-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
}

.drawer-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-batch-item {
  padding: 0.85rem 1rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-batch-item:hover {
  border-color: var(--accent-primary);
  background-color: var(--bg-card-hover);
}

.history-batch-item.active {
  border-color: var(--accent-primary);
  background-color: var(--accent-glow);
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 2rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.825rem;
  border-top: 1px solid var(--border-color);
  margin-top: 3rem;
}

.site-footer a {
  color: var(--accent-primary);
  text-decoration: none;
}
