/* NASA Science Mission Citations - D3.js Charts Stylesheet */
/* Brand: The Planetary Society */

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

:root {
  --font-family: 'Poppins', Arial, sans-serif;
  --text-color: #414141;
  --text-muted: #666666;
  --bg-color: #F5F5F5;
  --grid-color: #cccccc;
  --border-color: #dddddd;
  --accent-color: #037CC2;
  --marker-stroke: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  color: var(--text-color);
  background-color: #ffffff;
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

/* Dashboard Layout */
.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.dashboard-header {
  text-align: center;
  margin-bottom: 32px;
}

.dashboard-header h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--text-color);
}

.dashboard-header .subtitle {
  font-size: 16px;
  color: var(--text-muted);
  margin: 0;
}

/* Controls */
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  padding: 16px;
  background: var(--bg-color);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.controls label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.controls select {
  font-family: var(--font-family);
  font-size: 14px;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-color);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.controls select:hover {
  border-color: var(--accent-color);
}

.controls select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.strategy-description {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* Division Controls */
.division-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 16px;
  border-left: 1px solid var(--border-color);
}

.control-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-color);
  transition: color 0.15s ease;
}

.checkbox-label:hover {
  color: var(--accent-color);
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent-color);
}

.checkbox-text {
  user-select: none;
}

/* Disabled state for controls */
.controls select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.controls select:disabled:hover {
  border-color: var(--border-color);
}

/* Chart-level controls (inside chart containers) */
.chart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}

.chart-controls label {
  color: var(--text-muted);
  font-weight: 500;
}

.chart-controls select {
  font-family: var(--font-family);
  font-size: 13px;
  padding: 4px 24px 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-color);
  color: var(--text-color);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.chart-controls select:hover {
  border-color: var(--accent-color);
}

.chart-controls select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Chart Grid */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

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

/* Chart Container */
.chart-container {
  background: var(--bg-color);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 20px;
  overflow: hidden;
}

.chart-container.full-width {
  grid-column: 1 / -1;
}

.chart-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--text-color);
}

.chart-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: -12px 0 16px 0;
}

/* SVG Charts */
.chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Axis Styling */
.axis path,
.axis line {
  stroke: var(--grid-color);
}

.axis text {
  font-family: var(--font-family);
  font-size: 11px;
  fill: var(--text-muted);
}

.axis-label {
  font-family: var(--font-family);
  font-size: 12px;
  fill: var(--text-muted);
  font-weight: 500;
}

/* Grid Lines */
.grid line {
  stroke: var(--grid-color);
  stroke-opacity: 0.5;
  shape-rendering: crispEdges;
}

.grid path {
  stroke-width: 0;
}

/* Markers */
.marker {
  stroke: var(--marker-stroke);
  stroke-width: 1.5px;
  opacity: 0.8;
  transition: opacity 0.15s ease;
}

.marker:hover {
  opacity: 1;
  stroke-width: 2px;
}

/* Bar Chart */
.bar {
  transition: opacity 0.15s ease;
}

.bar:hover {
  opacity: 0.85;
}

.bar-label {
  font-family: var(--font-family);
  font-size: 11px;
  fill: var(--text-color);
  font-weight: 500;
}

/* Reference Lines */
.reference-line {
  stroke: #999999;
  stroke-width: 1.5px;
  stroke-dasharray: 6, 4;
  opacity: 0.6;
}

.reference-annotation {
  font-family: var(--font-family);
  font-size: 11px;
  fill: #999999;
  font-style: italic;
}

/* Data Labels */
.data-label {
  font-family: var(--font-family);
  font-size: 10px;
  fill: var(--text-muted);
  pointer-events: none;
}

/* Tooltip */
.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(30, 30, 30, 0.92);
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.6;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.chart-tooltip.visible {
  opacity: 1;
}

.tooltip-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.tooltip-label {
  color: rgba(255, 255, 255, 0.7);
}

.tooltip-value {
  font-weight: 500;
  text-align: right;
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-symbol {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* Color Bar Legend */
.color-bar-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}

.color-bar {
  width: 200px;
  height: 12px;
  border-radius: 2px;
}

.color-bar-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 400px;
  color: var(--text-muted);
}

.loading::after {
  content: '';
  width: 24px;
  height: 24px;
  margin-left: 12px;
  border: 2px solid var(--grid-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Error State */
.error {
  color: #dc2626;
  text-align: center;
  padding: 40px;
}

/* Chart Message (informational, not error) */
.chart-message {
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
  font-style: italic;
}

/* Standalone Page */
.standalone-page {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.standalone-page .chart-container {
  min-height: 600px;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

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

.footer a:hover {
  text-decoration: underline;
}

/* CSV Export Button (legacy, positioned in chart) */
.csv-export-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
  padding: 6px 12px;
  background: #ffffff;
  border: 1px solid #cccccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.csv-export-btn:hover {
  background: #f5f5f5;
  border-color: #999999;
}

.csv-export-btn:active {
  background: #eeeeee;
}

/* Export Link (inline with controls) */
.export-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease;
  margin-left: 8px;
}

.export-link:hover {
  color: var(--accent-color);
  text-decoration: underline;
}

/* Print Styles */
@media print {
  body {
    background: white;
  }

  .controls {
    display: none;
  }

  .chart-container {
    box-shadow: none;
    border: 1px solid var(--border-color);
    break-inside: avoid;
  }
}
