/* Political Risk Tracker - Dark Mode (shadcn-style) */

/* CSS Variables for Dark Theme */
:root {
  --background: 0 0% 3.9%;
  --foreground: 0 0% 98%;
  --card: 0 0% 3.9%;
  --card-foreground: 0 0% 98%;
  --popover: 0 0% 3.9%;
  --popover-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 0 0% 9%;
  --secondary: 0 0% 14.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 0 0% 14.9%;
  --muted-foreground: 0 0% 63.9%;
  --accent: 0 0% 14.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 98%;
  --border: 0 0% 14.9%;
  --input: 0 0% 14.9%;
  --ring: 0 0% 83.1%;
  --radius: 0.5rem;
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Header */
.header {
  background: linear-gradient(
    135deg,
    hsl(270 95% 4%) 0%,
    hsl(270 85% 50%) 100%
  );
  color: hsl(var(--foreground));
  padding: 24px;
  border-radius: 12px;
  margin-bottom: 32px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid hsl(var(--border));
}

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

.header h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  opacity: 0.9;
  color: hsl(var(--muted-foreground));
}

.methodology-link {
  color: #4a9eff;
  text-decoration: none;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.methodology-link:hover {
  background-color: rgba(74, 158, 255, 0.1);
  text-decoration: none;
}

.flag {
  font-size: 1.25rem;
}

.timestamp {
  font-weight: 500;
}

/* Cards */
.nowcast-card,
.events-section,
.sparkline-section,
.movers-section,
.sources-section {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.nowcast-card h2,
.events-section h2,
.sparkline-section h2,
.movers-section h2,
.sources-section h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: hsl(var(--foreground));
}

/* Risk Score */
.score-container {
  text-align: center;
  margin-bottom: 24px;
}

.score-main {
  font-size: 4rem;
  font-weight: 700;
  color: hsl(var(--primary));
  line-height: 1;
  margin-bottom: 8px;
}

.score-label {
  font-size: 1.125rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

.score-meta {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.score-delta {
  font-weight: 600;
}

.history-card {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid hsl(var(--border));
}

.history-card h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: hsl(var(--muted-foreground));
}

.history-sparkline {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--muted) / 0.2);
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 12px;
}

.history-sparkline svg {
  width: 100%;
  height: 100%;
}

.history-sparkline polyline {
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* Confidence Bands */
.confidence-bands {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-bottom: 24px;
}

.band {
  text-align: center;
}

.band-label {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  margin-bottom: 4px;
}

.band-range {
  font-size: 1rem;
  color: hsl(var(--foreground));
  font-weight: 600;
}

/* Movers */
.movers {
  margin-top: 24px;
}

.movers-label {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  margin-bottom: 8px;
}

.movers-list {
  color: hsl(var(--foreground));
  line-height: 1.6;
}

/* Events */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.event-item {
  display: grid;
  grid-template-columns: 120px 1fr 80px;
  gap: 16px;
  align-items: center;
  padding: 16px;
  background: hsl(var(--muted));
  border-radius: 8px;
  border: 1px solid hsl(var(--border));
  margin-bottom: 12px;
  min-height: 60px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.event-item:hover {
  background: hsl(var(--muted) / 0.6);
  border-color: hsl(var(--accent));
}

.event-time {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

.event-title {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  line-height: 1.4;
}

.event-score {
  display: flex;
  justify-content: flex-end;
}

.event-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 8px;
  line-height: 1.3;
}

.event-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  margin-top: auto; /* Push to bottom of flex container */
}

.severity-pill {
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.75rem;
}

.severity-1 {
  background: hsl(142.1 76.2% 36.3%);
  color: white;
}
.severity-2 {
  background: hsl(38 92% 50%);
  color: #111;
}
.severity-3 {
  background: hsl(25 95% 53%);
  color: white;
}
.severity-4 {
  background: hsl(0 84% 60%);
  color: white;
}
.severity-5 {
  background: hsl(0 72% 51%);
  color: white;
}

/* Decreasing risk severity (green) */
.severity-decreasing {
  background: hsl(142.1 76.2% 36.3%);
  color: white;
}

.event-type {
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  font-weight: 500;
  font-size: 0.75rem;
  padding: 2px 6px;
  background: hsl(var(--muted) / 0.5);
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Loading States */
.loading {
  color: hsl(var(--muted-foreground));
  font-style: italic;
  text-align: center;
  padding: 20px;
}

/* Source Status */
.source-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
}

.source-status.healthy {
  border-color: hsl(142.1 76.2% 36.3%);
  background: hsl(142.1 76.2% 36.3% / 0.1);
}

.source-status.warning {
  border-color: hsl(38 92% 50%);
  background: hsl(38 92% 50% / 0.1);
}

.source-status.error {
  border-color: hsl(0 84% 60%);
  background: hsl(0 84% 60% / 0.1);
}

.source-status-icon {
  font-size: 1.5rem;
  opacity: 0.8;
}

.source-status-text {
  flex: 1;
}

.source-status-title {
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 4px;
}

.source-status-detail {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

/* Trend Visualization */
.trend-container {
  padding: 16px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
}

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

.trend-label {
  font-weight: 600;
  color: hsl(var(--foreground));
}

.trend-score {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.trend-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trend-direction {
  font-weight: 600;
  font-size: 0.875rem;
}

.trend-meta {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.trend-placeholder {
  padding: 16px;
  text-align: center;
  color: hsl(var(--muted-foreground));
}

.trend-message {
  font-size: 0.875rem;
  margin-top: 4px;
}

/* Alert Banner */
.alert-banner {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-icon {
  font-size: 1.25rem;
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

.dashboard-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Section Styling for Perfect Balance */
.events-section,
.changes-section,
.sources-section {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  padding: 24px;
  min-height: 400px; /* Ensure consistent height */
}

.events-section h2,
.changes-section h2,
.sources-section h2 {
  margin: 0 0 20px 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--border));
  padding-bottom: 12px;
}

/* Risk Score Card */
.risk-score-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.risk-score-card h2 {
  margin: 0 0 16px 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.confidence-display {
  margin: 16px 0;
}

.confidence-level {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.key-factors {
  margin-top: 16px;
}

.factors-label {
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 8px;
}

.factors-list {
  color: hsl(var(--muted-foreground));
  line-height: 1.5;
}

/* Risk Metrics */
.risk-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
  padding: 16px;
  background: hsl(var(--muted) / 0.2);
  border-radius: 8px;
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  display: inline;
}

.metric-explanation {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.3;
}

/* Risk Thermometer */
.risk-thermometer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid hsl(var(--border));
}

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

.thermometer-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.current-score {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--accent));
}

.thermometer-container {
  position: relative;
}

.thermometer-track {
  position: relative;
  height: 12px;
  background: hsl(var(--muted));
  border-radius: 6px;
  overflow: hidden;
}

.thermometer-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e 0%, #f59e0b 50%, #ef4444 100%);
  border-radius: 6px;
  transition: width 0.5s ease;
}

.thermometer-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 20px;
  background: hsl(var(--foreground));
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 0.5s ease;
}

.thermometer-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.thermometer-label {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

/* Clickable Events */
.clickable-event {
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.clickable-event:hover {
  background: hsl(var(--accent) / 0.1);
  transform: translateX(4px);
}

.event-link {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.2s ease;
  font-size: 0.875rem;
}

.clickable-event:hover .event-link {
  opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 16px;
  }

  .header-content {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .header h1 {
    font-size: 1.875rem;
  }

  .score-main {
    font-size: 3rem;
  }

  .confidence-bands {
    flex-direction: column;
    gap: 16px;
  }

  .event-item {
    flex-direction: column;
    gap: 8px;
  }

  .event-time {
    min-width: auto;
  }
}

/* Focus and Accessibility */
*:focus {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* Smooth Transitions */
* {
  transition: all 0.2s ease-in-out;
}

/* Mobile Responsive for Dashboard */
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .dashboard-column {
    gap: 16px;
  }
}

/* Score Drivers */
.mover-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid hsl(var(--border));
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.mover-item:hover {
  background-color: hsl(var(--muted) / 0.5);
  border-radius: 4px;
  margin: 0 -8px;
  padding: 8px;
}

.mover-item:last-child {
  border-bottom: none;
}

.mover-change {
  font-size: 1.25rem;
  font-weight: 600;
}

.mover-change.change-positive {
  color: #ef4444;
}

.mover-change.change-neutral {
  color: #6b7280;
}

.mover-description {
  flex: 1;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  line-height: 1.4;
}

.mover-date {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  min-width: 50px;
}

.driver-evidence {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.mover-item:hover .driver-evidence {
  opacity: 1;
  color: hsl(var(--accent));
}

/* Data Sources */
.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.source-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: hsl(var(--muted) / 0.3);
  border: 1px solid hsl(var(--border));
  border-radius: 4px;
  text-decoration: none;
  color: hsl(var(--foreground));
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

.source-link:hover {
  background: hsl(var(--muted) / 0.5);
  border-color: hsl(var(--accent));
  color: hsl(var(--accent));
}

.source-icon {
  font-size: 0.875rem;
}

.source-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sources-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  padding-top: 8px;
  border-top: 1px solid hsl(var(--border));
}

.sources-count {
  font-weight: 600;
  color: hsl(var(--foreground));
}

.sources-types {
  opacity: 0.8;
}

.history-single {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}
