/* ═══════════════════════════════════════════════════════════════
   Data Visualization Studio — Tool-specific styles
   Extends shared/css/main.css design system
   Only styles NOT already in main.css belong here.
   ═══════════════════════════════════════════════════════════════ */

/* ── Variable Picker (unique to this tool) ──────────────────── */
.variable-picker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.variable-picker-col label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.variable-picker-col select {
  width: 100%;
}

.var-type-badge-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  min-height: 1.6rem;
}

.var-type-detail {
  font-size: 0.82rem;
  color: var(--app-muted);
}

/* ── Temporal Badge ─────────────────────────────────────────── */
.badge--temporal {
  background: #0891b2;
  color: #fff;
  border: none;
}

/* ── Clickable Type Override Badge ───────────────────────────── */
.badge--clickable {
  cursor: pointer;
  user-select: none;
  transition: box-shadow 0.15s, transform 0.1s;
}
.badge--clickable:hover {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, .45);
  transform: scale(1.05);
}
.badge--overridden {
  outline: 2px dashed #f59e0b;
  outline-offset: 1px;
}

/* ── Scenario Variable Tags ─────────────────────────────────── */
.var-tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: monospace;
  background: #e5e7eb;
  color: #374151;
}
.var-tag.categorical { background: #fde68a; color: #92400e; }
.var-tag.predictor   { background: #bfdbfe; color: #1e40af; }
.var-tag.temporal    { background: #a5f3fc; color: #0e7490; }

/* ── Group By / Time Variable Selector ──────────────────────── */
.groupby-wrapper {
  margin-top: 0.75rem;
  max-width: 380px;
}

.groupby-wrapper label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.groupby-wrapper select {
  width: 100%;
}

.hint-inline {
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--app-muted);
}

/* ── Combo Indicator (unique to this tool) ──────────────────── */
.combo-indicator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, #f0f9ff 0%, #e8f4fd 100%);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  margin-top: 1rem;
}

.combo-indicator__label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--app-text);
}

.combo-indicator__value {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--app-accent);
}

.combo-indicator__charts {
  font-size: 0.85rem;
  color: var(--app-muted);
}

.combo-indicator__charts--empty {
  color: var(--danger-color, #d64747);
  font-weight: 600;
}

.combo-indicator__hint {
  flex-basis: 100%;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.65rem 0.85rem;
  margin-top: 0.25rem;
  border-radius: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.combo-indicator__hint strong {
  color: #78350f;
}

/* ── Action Row ─────────────────────────────────────────────── */
.action-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ── Chart Type Pills (unique to this tool) ─────────────────── */
.chart-type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.chart-pill {
  padding: 0.45rem 1rem;
  border: 2px solid var(--app-border);
  border-radius: 999px;
  background: var(--app-card-bg);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--app-text);
}

.chart-pill:hover {
  border-color: var(--app-accent);
  color: var(--app-accent);
}

.chart-pill.active {
  background: var(--app-accent);
  border-color: var(--app-accent);
  color: #fff;
}

/* ── Temporal pill divider & temporal pill variant ──────────── */
.chart-pill-divider {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #0891b2;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
}

.chart-pill--temporal {
  border-color: #a5f3fc;
  background: linear-gradient(135deg, #f0fdfa 0%, #e0f7fa 100%);
}

.chart-pill--temporal:hover {
  border-color: #0891b2;
  color: #0891b2;
}

.chart-pill--temporal.active {
  background: linear-gradient(135deg, #0ea5e9 0%, #0891b2 100%);
  color: white;
  border-color: #0891b2;
}

.comp-temporal-tag {
  font-size: 0.65rem;
  font-weight: 600;
  color: #0891b2;
  background: #e0f7fa;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
  margin-left: 4px;
}

.comparison-chart-card--temporal {
  border-left: 3px solid #0ea5e9;
}

.chart-type-description {
  font-size: 0.9rem;
  color: var(--app-muted);
  min-height: 2rem;
  padding: 0.5rem 0;
}

/* ── Chart Container (min-height for Plotly/D3) ─────────────── */
.chart-container {
  position: relative;
  width: 100%;
  min-height: 420px;
  border-radius: 8px;
}

/* ── Data Preview (unique to this tool) ─────────────────────── */
.data-preview-empty {
  text-align: center;
  padding: 1.75rem 1rem;
  color: var(--app-muted, #6b7280);
  font-size: 0.95rem;
}

.data-preview-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--app-border);
}

.data-preview-meta {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.data-preview-table-wrap {
  max-height: 260px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--app-border);
}

.data-preview-table-wrap .data-table {
  font-size: 0.82rem;
  margin: 0;
}

.data-preview-table-wrap th,
.data-preview-table-wrap td {
  white-space: nowrap;
  padding: 0.35rem 0.6rem;
}

/* ── Temporal Column Confirmation Panel ─────────────────────── */
.temporal-confirm-panel {
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #f0fdfa 0%, #e0f7fa 100%);
  border: 1px solid #5eead4;
  border-left: 4px solid #0d9488;
  animation: temporalSlideIn 0.35s ease-out;
}

@keyframes temporalSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.temporal-confirm-header {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.temporal-confirm-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.temporal-confirm-header strong {
  display: block;
  font-size: 0.95rem;
  color: #134e4a;
  margin-bottom: 0.15rem;
}

.temporal-confirm-sub {
  font-size: 0.84rem;
  color: #115e59;
  margin: 0;
  line-height: 1.45;
}

.temporal-confirm-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.temporal-confirm-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #99f6e4;
  transition: background 0.2s, border-color 0.2s;
}

.temporal-confirm-row:hover {
  background: rgba(255, 255, 255, 0.95);
}

.temporal-confirm-row.unchecked {
  background: rgba(255, 255, 255, 0.35);
  border-color: #d1d5db;
  opacity: 0.7;
}

.temporal-confirm-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: #0d9488;
  flex-shrink: 0;
  cursor: pointer;
}

.temporal-confirm-col-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #134e4a;
  font-family: monospace;
  min-width: 120px;
}

.temporal-confirm-reason {
  font-size: 0.82rem;
  color: #115e59;
  flex: 1;
}

.temporal-confirm-sample {
  font-size: 0.78rem;
  color: #5f6b7a;
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

/* ── Comparison Grid (unique to this tool) ──────────────────── */
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.comparison-chart-card {
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 1rem;
  background: var(--app-card-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.comparison-chart-card h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.comparison-chart-container {
  width: 100%;
  min-height: 320px;
}

/* Reuse .chart-narrative from main.css but smaller variant for comparison cards */
.comparison-chart-narrative {
  margin-top: 0.75rem;
  background: #f8f9fb;
  padding: 0.75rem;
  border-radius: 8px;
  border-left: 3px solid #3b82f6;
  font-size: 0.88rem;
}

/* ── Comparison Callout (unique to this tool) ────────────────── */
.comparison-callout {
  margin-top: 1.25rem;
  background: linear-gradient(135deg, #fef9c3 0%, #fef3cd 100%);
  border: 1px solid #f3b440;
  border-left: 4px solid #f3b440;
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
}

.comparison-callout h4 {
  margin: 0 0 0.5rem;
  color: #92400e;
  font-size: 1rem;
}

.comparison-callout p {
  margin: 0.25rem 0;
  font-size: 0.93rem;
  line-height: 1.55;
}

.comparison-callout .reveals {
  color: #166534;
  font-weight: 600;
}

.comparison-callout .hides {
  color: #991b1b;
  font-weight: 600;
}

/* ── Diagnostics Grid — layout only (items styled in main.css) ─ */
.diagnostics-grid {
  display: grid;
  gap: 0.65rem;
}

/* ── Callout Boxes ──────────────────────────────────────────── */
.callout {
  border-radius: 10px;
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
  font-size: 0.93rem;
  line-height: 1.6;
}

.callout--info {
  background: linear-gradient(135deg, #f0f9ff 0%, #e8f4fd 100%);
  border: 1px solid #bfdbfe;
  border-left: 4px solid #3b82f6;
}

.callout--warning {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3cd 100%);
  border: 1px solid #f3b440;
  border-left: 4px solid #f59e0b;
}

.callout__title {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0 0 0.35rem;
  color: var(--app-text);
}

/* ── Feature Card Grid ─────────────────────────────────────── */
.feature-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.feature-card {
  background: var(--app-card-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.87rem;
  line-height: 1.45;
  text-align: center;
}

/* ── Sparkline Previews (variable picker) ──────────────────── */
.sparkline-wrap {
  margin-top: 0.4rem;
  height: 38px;
  overflow: hidden;
}

.sparkline-wrap svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Chart Card Header (title + download button row) ───────── */
.chart-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}

.chart-card__header h3 {
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════
   CHART OPTIONS PANEL
   Dynamic toggles/selects that change per chart type.
   ═══════════════════════════════════════════════════════════════ */

.chart-options-panel {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
}

.chart-options-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
}

.chart-options-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.25rem;
}

/* ── Collapsible tier sections ─────────────────────────────── */
.chart-options-tier {
  margin-top: 0.5rem;
  border-top: 1px dashed #e5e7eb;
}

.chart-options-tier-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0;
  font-size: 0.74rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  list-style: none;          /* hide default marker */
  transition: color 0.15s;
}

.chart-options-tier-header::-webkit-details-marker { display: none; }

.chart-options-tier-header::before {
  content: '▸';
  display: inline-block;
  font-size: 0.72rem;
  transition: transform 0.2s;
  color: #9ca3af;
}

.chart-options-tier[open] > .chart-options-tier-header::before {
  transform: rotate(90deg);
}

.chart-options-tier-header:hover {
  color: #6b7280;
}

.chart-options-tier-body {
  padding: 0.35rem 0 0.35rem 0.25rem;
  animation: optionsFadeIn 0.2s ease;
}

@keyframes optionsFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Toggle switch */
.chart-option-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.chart-option-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  width: 34px;
  height: 18px;
  background: #d1d5db;
  border-radius: 9px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.2s;
}

.chart-option-toggle input:checked + .toggle-slider {
  background: #2a7de1;
}

.chart-option-toggle input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.chart-option-toggle input:focus-visible + .toggle-slider {
  outline: 2px solid #2a7de1;
  outline-offset: 2px;
}

.toggle-text {
  font-size: 0.82rem;
  color: #374151;
  white-space: nowrap;
}

.chart-option-toggle input:not(:checked) ~ .toggle-text {
  color: #9ca3af;
}

/* Select dropdown */
.chart-option-select-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.select-text {
  font-size: 0.82rem;
  color: #374151;
  white-space: nowrap;
}

.chart-option-select {
  padding: 0.25rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 0.82rem;
  color: #374151;
  cursor: pointer;
}

.chart-option-select:focus {
  outline: 2px solid #2a7de1;
  outline-offset: 1px;
}

@media (max-width: 700px) {
  .chart-options-row {
    gap: 0.4rem 0.75rem;
  }
}

/* ── Utility Classes ───────────────────────────────────────── */
.mt-sm { margin-top: 0.65rem; }

.compact th,
.compact td {
  padding: 0.3rem 0.55rem;
  font-size: 0.82rem;
}

/* ── Pipeline Notices (binning, aggregation, cardinality) ──── */
.pipeline-notices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pipeline-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
  animation: noticeSlideIn 0.3s ease-out;
}

@keyframes noticeSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pipeline-notice--binning,
.pipeline-notice--aggregation {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #7dd3fc;
  border-left: 4px solid #0ea5e9;
  color: #0c4a6e;
}

.pipeline-notice--capping,
.pipeline-notice--cardinality {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3cd 100%);
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  color: #92400e;
}

.pipeline-notice--density {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-left: 4px solid #22c55e;
  color: #14532d;
}

.pipeline-notice--error {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fca5a5;
  border-left: 4px solid #ef4444;
  color: #7f1d1d;
}

.pipeline-notice__icon {
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1.4;
}

.pipeline-notice__message {
  flex: 1;
}

.pipeline-notice__message strong {
  font-weight: 700;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 700px) {
  .variable-picker-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .comparison-grid {
    grid-template-columns: 1fr;
  }

  .combo-indicator {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
}

/* ═══════════════════════════════════════════════════════════════
   SPARKLINE TIMELINE
   ═══════════════════════════════════════════════════════════════ */

.sparkline-timeline {
  margin-top: 0.35rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: linear-gradient(135deg, #fafbfc 0%, #f4f6f8 100%);
  overflow: hidden;
}

.sparkline-timeline svg {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════
   GAPMINDER TRANSPORT CONTROLS
   ═══════════════════════════════════════════════════════════════ */

.gapminder-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.gapminder-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a7de1, #1d5db8);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(42, 125, 225, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.gapminder-play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(42, 125, 225, 0.5);
}

.gapminder-play-btn:active {
  transform: scale(0.96);
}

.gapminder-scrubber {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #cbd5e1;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.gapminder-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2a7de1;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: grab;
}

.gapminder-scrubber::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2a7de1;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: grab;
}

.gapminder-time-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e3a5f;
  min-width: 4.5rem;
  text-align: center;
  white-space: nowrap;
}

.gapminder-speed {
  padding: 0.3rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  font-size: 0.82rem;
  color: #374151;
  cursor: pointer;
  flex-shrink: 0;
}

.gapminder-speed:focus {
  outline: 2px solid #2a7de1;
  outline-offset: 1px;
}

@media (max-width: 700px) {
  .gapminder-controls {
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
  }
  .gapminder-scrubber {
    order: 3;
    flex-basis: 100%;
  }
}
