/* Design System from figure_specs.md */
:root {
  /* Country Colors */
  --color-us: #2B6CB0;
  --color-china: #C53030;
  --color-india: #D69E2E;

  /* Exposure Colors */
  --color-high: #E53E3E;
  --color-low: #718096;
  --color-neutral: #4A5568;

  /* UI */
  --color-bg: #f7fafc;
  --color-card: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1a202c;
  --color-text-muted: #718096;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  padding: 2rem;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
}

h1 {
  font-weight: 700;
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

h2 {
  font-weight: 600;
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--color-neutral);
}

.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chart-container {
  position: relative;
  height: 400px;
  width: 100%;
}

.source {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 1rem;
  font-style: italic;
}

.key-insight {
  background: linear-gradient(135deg, #ebf8ff 0%, #e6fffa 100%);
  border-left: 4px solid var(--color-us);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.95rem;
}

.key-insight strong {
  color: var(--color-us);
}

/* Navigation */
nav {
  margin-bottom: 2rem;
}

nav a {
  color: var(--color-us);
  text-decoration: none;
  font-size: 0.875rem;
}

nav a:hover {
  text-decoration: underline;
}

/* Table styles */
table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.875rem;
}

th,
td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  background: var(--color-bg);
  cursor: pointer;
}

th:hover {
  background: #edf2f7;
}

tr:hover {
  background: #f7fafc;
}

.num {
  text-align: right;
  font-family: 'Roboto Mono', monospace;
}

/* Legend */
.legend {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .card {
    padding: 1rem;
  }

  .chart-container {
    height: 300px;
  }

  table {
    font-size: 0.75rem;
  }

  th,
  td {
    padding: 0.5rem;
  }
}

/* ========================================
   EMBED MODE - Dashboard styling for iframes
   ======================================== */

body.embed-mode {
  padding: 0;
  margin: 0;
  background: #fff;
  overflow-x: hidden;
  overflow-y: auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

body.embed-mode .container {
  max-width: 100%;
  width: 100%;
  height: 100%;
  padding: 1rem 1.5rem;
  margin: 0;
  display: flex;
  flex-direction: column;
}

body.embed-mode .card {
  padding: 1rem;
  margin-bottom: 0;
  border: none;
  box-shadow: none;
  border-radius: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Important for flexbox overflow */
}

/* Compact headers in embed mode */
body.embed-mode h1 {
  font-size: 1rem;
  margin-bottom: 0.35rem;
  line-height: 1.3;
  font-weight: 600;
}

body.embed-mode h2 {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Chart containers should flex to fill space */
body.embed-mode .chart-container {
  flex: 1;
  min-height: 0;
  height: auto;
  position: relative;
}

body.embed-mode .chart-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Compact controls */
body.embed-mode .controls {
  margin-bottom: 0.75rem;
  gap: 0.5rem;
}

body.embed-mode .btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
}

/* Reduce stats text if present */
body.embed-mode .stat-value {
  font-size: 1.25rem !important;
}

body.embed-mode .stat-label {
  font-size: 0.7rem !important;
}

/* Hide non-essential elements */
body.embed-mode nav,
body.embed-mode .source,
body.embed-mode .key-insight {
  display: none;
}

/* Compact legend */
body.embed-mode .legend {
  font-size: 0.7rem;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

body.embed-mode .legend-item {
  gap: 0.35rem;
}

body.embed-mode .legend-dot {
  width: 10px;
  height: 10px;
}

/* Map specific tweaks */
body.embed-mode .map-container {
  flex: 1;
  min-height: 0;
  height: 100%;
}

body.embed-mode #map {
  height: 100%;
  width: 100%;
}

/* Table scrolling in embed mode */
body.embed-mode .table-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

body.embed-mode table {
  font-size: 0.75rem;
}

body.embed-mode th,
body.embed-mode td {
  padding: 0.5rem 0.75rem;
}