/*
 * Custom stylesheet for the News Sentiment Dashboard
 * Modern Glassmorphism Design
 */

/* Root colour variables */
:root {
  /* Modern Dark Theme Palette */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  
  /* Brand Colors */
  --accent-primary: #6366f1; /* Indigo */
  --accent-secondary: #8b5cf6; /* Violet */
  --gradient-1: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  
  /* Sentiment Colors */
  --positive: #10b981; /* Emerald */
  --neutral: #94a3b8; /* Slate */
  --negative: #ef4444; /* Red */
  
  /* Glassmorphism */
  --glass: rgba(30, 41, 59, 0.7);
  --glass-hover: rgba(30, 41, 59, 0.9);
  --glass-border: rgba(255, 255, 255, 0.08);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Background Gradients */
.bg-gradient {
  position: fixed;
  top: -20%;
  left: -10%;
  width: 50%;
  height: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(15, 23, 42, 0) 70%);
  z-index: -1;
  pointer-events: none;
}

.bg-gradient-2 {
  position: fixed;
  bottom: -20%;
  right: -10%;
  width: 50%;
  height: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, rgba(15, 23, 42, 0) 70%);
  z-index: -1;
  pointer-events: none;
}

/* Layout containers */
.dashboard {
  display: flex;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 24px;
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 10;
}

.sidebar h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  font-weight: 600;
}

.source-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.btn {
  cursor: pointer;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.btn.small {
  font-size: 12px;
  padding: 6px 12px;
}

.sources-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

/* Scrollbar styling */
.sources-list::-webkit-scrollbar {
  width: 4px;
}

.sources-list::-webkit-scrollbar-track {
  background: transparent;
}

.sources-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.source-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  transition: all 0.2s ease;
  font-size: 14px;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.source-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

.source-item.selected {
  background: rgba(99, 102, 241, 0.1);
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.2);
}

.source-item span:last-child {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--text-tertiary);
}

.source-item.selected span:last-child {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-primary);
}

/* Main Content */
.main {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
}

/* Header styling */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--glass-border);
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.page-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.status-text {
  font-size: 13px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-text::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  background-color: var(--positive);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--positive);
}

/* Header Button */
.header-btn {
  padding: 10px 20px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 8px;
  color: var(--accent-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.header-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-lg);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--text-tertiary);
  opacity: 0.3;
}

.stat-card.positive::before { background: var(--positive); opacity: 1; }
.stat-card.neutral::before { background: var(--neutral); opacity: 1; }
.stat-card.negative::before { background: var(--negative); opacity: 1; }

.stat-card .stat-title {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .stat-value {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.stat-card.positive .stat-value { color: var(--positive); text-shadow: 0 0 20px rgba(16, 185, 129, 0.2); }
.stat-card.neutral .stat-value { color: var(--neutral); }
.stat-card.negative .stat-value { color: var(--negative); text-shadow: 0 0 20px rgba(239, 68, 68, 0.2); }

/* Widgets grid */
.widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.chart-widget {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  height: 400px;
  transition: all 0.3s ease;
}

.chart-widget:hover {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
}

.chart-widget .widget-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chart-widget canvas {
  flex: 1;
  width: 100% !important;
  height: auto !important;
  max-height: 320px;
}

.dropdown {
  display: inline-block;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropdown:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.dropdown:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* Headlines widget */
.headlines-widget {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
}

.headlines-widget .widget-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.headline-count {
  font-size: 13px;
  color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 12px;
}

.headlines-list {
  list-style: none;
  max-height: 400px;
  overflow-y: auto;
  margin: 0 -12px;
  padding: 0 12px;
}

.headlines-list::-webkit-scrollbar {
  width: 4px;
}

.headlines-list::-webkit-scrollbar-track {
  background: transparent;
}

.headlines-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.headlines-list li {
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

.headlines-list li:last-child {
  border-bottom: none;
}

.headlines-list li:hover {
  transform: translateX(4px);
}

.headline-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.headline-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* View All Button */
.view-all-btn {
  padding: 12px 24px;
  background: var(--gradient-1);
  border: none;
  border-radius: 8px;
  color: white;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-block;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.view-all-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Responsive design */
@media (max-width: 1024px) {
  .dashboard {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    max-height: 300px;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
  }
  
  .main {
    padding: 24px;
  }
}

@media (max-width: 768px) {
  .widgets-grid {
    grid-template-columns: 1fr;
  }
  
  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
}
