/*
 * Custom stylesheet for the News Sentiment Dashboard
 *
 * This file defines a simple darkâ€'themed layout for the dashboard. It
 * arranges the page into a sidebar for selecting sources and a main
 * content area containing statistics, charts, and headline lists. The
 * design uses CSS variables for colours so that the sentiment colours
 * remain consistent across widgets.
 */

/* Root colour variables */
:root {
  --color-bg-primary: #0B0E18;
  --color-bg-secondary: #151B2C;
  --color-bg-widget: #1E2A3F;
  --color-text-primary: #ffffff;
  --color-text-secondary: rgba(255, 255, 255, 0.7);
  --color-text-tertiary: rgba(255, 255, 255, 0.5);
  --color-positive: #00D4AA;
  --color-neutral: #8B93A6;
  --color-negative: #FF6B9D;
  --gradient-1: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
  --glass: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  min-height: 100vh;
  display: flex;
}

/* Layout containers */
.dashboard {
  display: flex;
  width: 100%;
  overflow-x: hidden;
}

.sidebar {
  width: 260px;
  background: var(--color-bg-secondary);
  padding: 20px;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

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

.btn {
  cursor: pointer;
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  color: var(--color-text-primary);
  background: var(--color-bg-widget);
  transition: all 0.2s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

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

.sources-list {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.sources-list .source-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  transition: background 0.2s ease;
  font-size: 13px;
}

.sources-list .source-item.selected {
  background: var(--color-bg-widget);
  border-left: 3px solid #667EEA;
}

.sources-list .source-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.main {
  flex-grow: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Header styling */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
}

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

.page-title {
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

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

.status-text {
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* Header Button */
.header-btn {
  padding: 8px 16px;
  background: rgba(102, 126, 234, 0.2);
  border: 1px solid rgba(102, 126, 234, 0.4);
  border-radius: 8px;
  color: #667EEA;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.header-btn:hover {
  background: rgba(102, 126, 234, 0.3);
  transform: translateY(-1px);
}

/* Stats grid */
.stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  flex: 1 1 150px;
  background: var(--color-bg-widget);
  padding: 16px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-card .stat-title {
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--color-text-secondary);
  font-weight: 500;
}

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

.stat-card.positive .stat-value {
  color: var(--color-positive);
}
.stat-card.neutral .stat-value {
  color: var(--color-neutral);
}
.stat-card.negative .stat-value {
  color: var(--color-negative);
}

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

.chart-widget {
  background: var(--color-bg-widget);
  padding: 16px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.1);
  height: 350px; /* Fixed height instead of min-height */
  overflow: hidden; /* Prevent overflow */
}

.chart-widget .widget-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-text-primary);
  flex-shrink: 0; /* Prevent title from shrinking */
}

.chart-widget canvas {
  flex: 1; /* Take remaining space */
  max-height: 280px; /* Constrain maximum height */
  width: 100% !important; /* Force width constraint */
  height: auto !important; /* Let height be managed by container */
}

.dropdown {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 8px;
  font-size: 14px;
  color: var(--color-text-primary);
  background: var(--color-bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Headlines widget */
.headlines-widget {
  background: var(--color-bg-widget);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.headlines-widget .widget-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-text-primary);
}

.headline-count {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

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

.headlines-list li {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.headline-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.headline-meta {
  font-size: 12px;
  color: var(--color-text-tertiary);
}

/* View All Button */
.view-all-btn {
  padding: 8px 16px;
  background: rgba(102, 126, 234, 0.2);
  border: 1px solid rgba(102, 126, 234, 0.4);
  border-radius: 8px;
  color: #667EEA;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-block;
}

.view-all-btn:hover {
  background: rgba(102, 126, 234, 0.3);
  transform: translateX(2px);
}

/* 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: 768px) {
  .dashboard {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    max-height: 200px;
  }
  
  .widgets-grid {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    flex-direction: column;
  }
}
