/* Huff Gravity Model Simulator — Tool-Specific Styles
   Relies on shared/css/main.css for: badges, dropzone, DSC panels,
   .hidden, .upload-status, .scenario-description, .interpretation-aid.
   Only tool-specific overrides belong here.
*/

/* ============================================================
   Method intro cards (3-up overview grid)
   ============================================================ */
.method-intro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) {
  .method-intro-grid { grid-template-columns: 1fr; }
}
.method-intro-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1.25rem;
  border-top: 4px solid #94a3b8;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.method-intro-card h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.method-intro-icon { font-size: 1.6rem; line-height: 1; }
.method-intro-tagline {
  font-style: italic;
  color: #475569;
  font-size: 0.9rem;
  margin: 0;
}

/* ============================================================
   Formula display
   ============================================================ */
.formula-card {
  background: #f8fafc;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-top: 0.75rem;
}

.formula-display {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 1.15rem;
  text-align: center;
  padding: 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin: 0.75rem 0;
  letter-spacing: 0.5px;
  color: var(--app-text);
}

.formula-legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.legend-symbol {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-weight: 600;
  min-width: 30px;
  color: var(--app-accent);
}

/* ============================================================
   History timeline
   ============================================================ */
.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-left: 1rem;
  border-left: 3px solid var(--app-accent);
}

.timeline-item {
  padding-left: 0.75rem;
}

.timeline-item strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--app-accent);
}

.timeline-item p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--app-muted);
  line-height: 1.5;
}

/* ============================================================
   Parameter explainer cards
   ============================================================ */
.param-explainer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
}

@media (max-width: 700px) {
  .param-explainer {
    grid-template-columns: 1fr;
  }
}

.param-card {
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--app-border);
}

.param-card h4 {
  margin: 0 0 0.5rem 0;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 1rem;
}

.param-card p {
  margin: 0.35rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--app-muted);
}

.param-card--alpha {
  background: #eff6ff;
  border-color: #93c5fd;
}

.param-card--alpha h4 {
  color: #1d4ed8;
}

.param-card--beta {
  background: #fef3c7;
  border-color: #fcd34d;
}

.param-card--beta h4 {
  color: #92400e;
}

/* ============================================================
   Data Source Chooser — tool-specific additions only
   (Base DSC panel styles come from main.css)
   ============================================================ */

.scenario-controls__input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.scenario-controls__input select {
  flex: 1;
  min-width: 200px;
}

/* Dropzone + upload-status: styled by main.css */

/* ============================================================
   Map section
   ============================================================ */
.map-section {
  position: relative;
}

.huff-map {
  height: 520px;
  width: 100%;
  border-radius: 8px;
  z-index: 1;
  background: #e5e7eb;
}

/* ============================================================
   Map toolbar
   ============================================================ */
.map-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #f8f9fb;
  border-radius: 6px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbar-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--app-muted);
  white-space: nowrap;
}

.viz-toggle {
  display: flex;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  overflow: hidden;
}

.viz-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: #fff;
  color: var(--app-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.viz-btn:not(:last-child) {
  border-right: 1px solid var(--app-border);
}

.viz-btn.active {
  background: var(--app-accent);
  color: #fff;
}

.viz-btn:hover:not(.active) {
  background: #f0f7ff;
  color: var(--app-accent);
}

.whatif-btn {
  white-space: nowrap;
}

.whatif-btn.active {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}

#grid-resolution {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 4px;
  font-size: 0.85rem;
  background: #fff;
}

/* ============================================================
   What-if controls
   ============================================================ */
.whatif-controls {
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
}

.whatif-inputs {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.whatif-inputs label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--app-text);
}

.whatif-inputs input {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 4px;
  font-size: 0.9rem;
  width: 150px;
}

/* ============================================================
   Parameter sliders
   ============================================================ */
.param-sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: #f8f9fb;
  border-radius: 8px;
}

@media (max-width: 600px) {
  .param-sliders {
    grid-template-columns: 1fr;
  }
}

.slider-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  font-family: 'Georgia', 'Times New Roman', serif;
}

.slider-value {
  font-family: 'Inter', sans-serif;
  background: var(--app-accent);
  color: #fff;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
}

.slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--app-accent);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--app-muted);
  margin-top: 0.15rem;
}

/* ============================================================
   Map legend
   ============================================================ */
.map-legend {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f8f9fb;
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.legend-entry {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

/* ============================================================
   Callouts
   ============================================================ */
.callout {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.callout--blue {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1e40af;
}

/* ============================================================
   Results grid
   ============================================================ */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

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

.chart-container {
  min-height: 300px;
}

.section-intro {
  color: var(--app-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ============================================================
   Store results table
   ============================================================ */
.store-table-container {
  margin-top: 1.5rem;
  overflow-x: auto;
}

.store-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.store-table th,
.store-table td {
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--app-border);
}

.store-table th {
  background: #f1f5f9;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--app-muted);
}

.store-table .swatch-cell {
  width: 20px;
}

.store-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.15);
}

/* ============================================================
   Comparison summary
   ============================================================ */
.comparison-summary {
  margin-top: 1rem;
  padding: 1rem;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
}

.comparison-summary .delta-positive {
  color: #16a34a;
  font-weight: 600;
}

.comparison-summary .delta-negative {
  color: #dc2626;
  font-weight: 600;
}

/* ============================================================
   Beta examples
   ============================================================ */
.beta-examples {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.beta-example {
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-left: 3px solid var(--app-accent);
  border-radius: 0 6px 6px 0;
}

.beta-example strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--app-text);
}

.beta-example p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--app-muted);
  line-height: 1.5;
}

/* ============================================================
   Export buttons
   ============================================================ */
.export-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* .hidden: styled by main.css */

.results-hidden {
  display: none;
}

.chart-height-md {
  height: 320px;
}

.chart-height-lg {
  height: 360px;
}

.formula-display--sm {
  font-size: 0.95rem;
}

/* Leaflet popup overrides */
.store-popup .leaflet-popup-content {
  margin: 8px 12px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.store-popup h4 {
  margin: 0 0 4px 0;
  font-size: 0.95rem;
}

.store-popup p {
  margin: 2px 0;
  font-size: 0.8rem;
  color: #64748b;
}

/* ============================================================
   Advanced Mode — toolbar button
   ============================================================ */
.advanced-btn {
  white-space: nowrap;
}

.advanced-btn.active {
  background: #7c3aed;
  color: #fff;
  border-color: #7c3aed;
}

/* ============================================================
   Advanced Mode — controls panel
   ============================================================ */
.advanced-controls {
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  background: #faf5ff;
  border: 1px solid #d8b4fe;
  border-left: 4px solid #7c3aed;
}

.advanced-controls > h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  color: #7c3aed;
}

.advanced-layer {
  margin-bottom: 0.75rem;
  border: 1px solid #e9d5ff;
  border-radius: 6px;
  overflow: hidden;
}

.advanced-layer > summary {
  padding: 0.6rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  background: #f3e8ff;
  color: #5b21b6;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.advanced-layer > summary::-webkit-details-marker {
  display: none;
}

.advanced-layer > summary::before {
  content: '▸';
  transition: transform 0.2s;
}

.advanced-layer[open] > summary::before {
  transform: rotate(90deg);
}

.advanced-layer > .layer-body {
  padding: 0.75rem 1rem;
}

.layer-callout {
  background: #f5f3ff;
  border-left: 3px solid #a78bfa;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
  border-radius: 0 4px 4px 0;
  font-size: 0.82rem;
  font-style: italic;
  color: #6b7280;
  line-height: 1.5;
}

/* ---- MCI slider grid ---- */
.mci-sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.25rem;
}

@media (max-width: 700px) {
  .mci-sliders {
    grid-template-columns: 1fr;
  }
}

.mci-slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mci-slider-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--app-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mci-slider-group input[type="range"] {
  width: 100%;
  accent-color: #7c3aed;
}

.mci-weight-value {
  font-family: 'Inter', sans-serif;
  background: #7c3aed;
  color: #fff;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
}

/* ---- Friction slider ---- */
.friction-slider {
  max-width: 350px;
}

.friction-slider label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.friction-slider input[type="range"] {
  width: 100%;
  accent-color: #7c3aed;
}

.friction-value {
  font-family: 'Inter', sans-serif;
  background: #7c3aed;
  color: #fff;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ---- Population toggle ---- */
.population-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.population-toggle label {
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.population-disclaimer {
  font-size: 0.78rem;
  font-style: italic;
  color: #9ca3af;
  margin-top: 0.35rem;
}

/* ---- Cannibalization table ---- */
.cannibalization-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.cannibalization-table th,
.cannibalization-table td {
  padding: 0.4rem 0.6rem;
  text-align: center;
  border: 1px solid #e5e7eb;
}

.cannibalization-table th {
  background: #f3e8ff;
  font-weight: 600;
  font-size: 0.75rem;
  color: #5b21b6;
}

.cannibalization-table .cannibal-cell--high {
  background: #fecaca;
}

.cannibalization-table .cannibal-cell--med {
  background: #fef3c7;
}

.cannibalization-table .cannibal-cell--low {
  background: #f0fdf4;
}

.cannibalization-table .cannibal-label {
  text-align: left;
  font-weight: 600;
  background: #faf5ff;
}

/* ---- Tornado controls & chart ---- */
.tornado-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.tornado-controls select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 4px;
  font-size: 0.85rem;
}

.tornado-chart {
  height: 320px;
}

/* ---- Per-store heatmap select ---- */
.store-heatmap-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.store-heatmap-select select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 4px;
  font-size: 0.85rem;
}

.store-heatmap-select label {
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---- Population overlay circles ---- */
.population-circle-label {
  font-size: 0.7rem;
  color: #7c3aed;
  font-weight: 600;
  white-space: nowrap;
}

/* ============================================================
   Pedagogy — Beyond the Simulation
   ============================================================ */
.pedagogy-cite {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #6b7280;
  font-style: italic;
}

/* Methodology data tables */
.methodology-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.75rem 0;
}
.methodology-table th,
.methodology-table td {
  padding: 0.5rem 0.65rem;
  border: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
}
.methodology-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--app-text);
  white-space: nowrap;
}
.methodology-table td:nth-child(2),
.methodology-table td:nth-child(4) {
  text-align: right;
  white-space: nowrap;
}

/* Brand-strength / attractiveness profile tables in scenario descriptions */
.brand-strength-details {
  margin: 0.75rem 0;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fafbfc;
}
.brand-strength-details summary {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--app-text);
}
.brand-strength-details[open] summary {
  border-bottom: 1px solid #e2e8f0;
}
.brand-strength-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin: 0;
}
.brand-strength-table th,
.brand-strength-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
}
.brand-strength-table th {
  background: #f1f5f9;
  font-weight: 600;
  color: var(--app-text);
  white-space: nowrap;
  font-size: 0.8rem;
}
.brand-strength-table tr:last-child td {
  border-bottom: none;
}
.brand-strength-table td:nth-child(3) {
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
  min-width: 3rem;
}
.score-high {
  color: #16a34a;
}
.score-mid {
  color: #d97706;
}
.score-low {
  color: #dc2626;
}

/* ============================================================
   Responsive — advanced controls
   ============================================================ */
@media (max-width: 768px) {
  .advanced-controls {
    padding: 0.75rem;
  }

  .tornado-chart {
    height: 260px;
  }
}
