/* ===============================
   Layout & Toolbar
   =============================== */

.country-panel-root {
  max-width: 1100px;
  margin: 24px auto;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.cp-grid > .left-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.cp-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 18px;
}

.cp-chip {
  position: relative;
  padding: 8px 12px;
  font-size: 16px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #ccc;
  cursor: pointer;
}

.cp-chip.active {
  background: #000;
  color: #fff;
}

.cp-chip-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #B02963;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* ===============================
   Map Container
   =============================== */

.map-wrap {
  position: relative;
  background: #f8f9fb;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  padding: 12px;
  width: 100%;
  padding-top: 30%;
  padding-bottom: 50%;
  overflow: hidden;
}

#cp-map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  box-sizing: border-box;
}

/* ===============================
   Country Styles
   =============================== */

.country {
  fill: #0f335c;
  cursor: pointer;
  transition: fill 0.12s ease;
}

.country[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.25;
}

.country:hover {
  fill: #1b4f8a;
}

.country.selected {
  fill: #B02963;
  stroke: #fff;
  stroke-width: 2;
}

.land {
  fill: #C0C7D3;
  stroke: #fff;
  stroke-width: 0.5;
  cursor: pointer;
  transition: fill 0.3s ease;
}

.land.with-data {
  fill: #193259;
}

.land.selected {
  fill: #B02963;
}

/* ===============================
   Tooltip Styles
   =============================== */

.rich-tooltip {
  position: absolute;
  z-index: 20;
  pointer-events: auto;
  transform: translate(-50%, -100%);
  display: none;
}

.rich-tooltip.show {
  display: block;
}

.tip-card {
  background: #111;
  color: #ffffff;
  opacity: 0.95;
  border-radius: 12px;
  padding: 16px;
  width: 280px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 1);
}

.tip-header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.tip-header .flag {
  width: 24px;
  height: 16px;
  margin-right: 8px;
  border-radius: 3px;
  border: 1px solid #fff;
}

.tip-title {
  line-height: 1.2;
}

.tip-title strong {
  font-size: 1rem;
  display: block;
}

.tip-title span {
  font-size: 0.8rem;
  opacity: 0.75;
}

.tip-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tip-tags .badge {
  background: #fff;
  color: #111;
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 3px 8px;
}

.tip-sample {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.sample-value {
  font-weight: bold;
  font-size: 1.2rem;
}

.tip-chart {
  width: 100%;
}

.mini-spark {
  width: 100%;
  height: 54px;
}

.tip-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  position: absolute;
  top: 10px;
  right: 10px;
}

.tip-close:hover {
  color: #B02963;
}

.spark-hover-tip {
  position: absolute;
  padding: 4px 8px;
  font-size: 12px;
  background: #111;
  color: #fff;
  border-radius: 4px;
  pointer-events: none;
  z-index: 9999;
  display: none;
  white-space: nowrap;
  font-family: sans-serif;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.spark-point {
  transition: fill 0.2s ease;
  cursor: pointer;
}

.spark-point:hover {
  fill: #B02963;
}

/* ===============================
   Year List
   =============================== */

.year-item {
  all: unset;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.year-item .flag {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border-radius: 2px;
}

.year-item .country-name {
  color: #111;
}

.year-item:hover .country-name {
  color: #B02963;
}

.year-item.active .country-name {
  font-weight: bold;
  color: #B02963;
}

@media (max-width: 768px) {
  .map-wrap {
    aspect-ratio: unset;
    height: auto;
  }

  #cp-map {
    width: 100%;
    height: 100%;
  }

  #cp-year-list .year-item {
    min-width: 45%;
  }
}

@media (max-width: 480px) {
  #cp-year-list .year-item {
    min-width: 100%;
  }
}

/* ===============================
   Horizontal Region Row Layout
   =============================== */

/* === Region-wise Country List Layout === */

.cp-region-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 50px;
  margin-top: 50px;
  overflow-x: auto;
  padding-bottom: 16px;
}

.cp-region {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: fit-content; /* 3 columns + 2 gaps */
}

.cp-region-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 16px;
  color: #222;
}

/* Render multi-column region lists */
.cp-region-columns {
  display: flex;
  flex-direction: row;
  gap: 32px;
  flex-wrap: nowrap;
}

/* Each column is a vertical list */
.cp-country-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 120px;  /* Ensures fixed width for each column */
}

.cp-country-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  color: #111;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.cp-country-item:hover .cp-country-name {
  color: #B02963;
}

.cp-country-item.active .cp-country-name {
  font-weight: 600;
  color: #B02963;
}

.cp-flag {
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
}

.cp-country-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive stacking */
@media (max-width: 768px) {
  .cp-region-row {
    flex-direction: column;
    gap: 32px;
  }

  .cp-region-columns {
    flex-direction: column;
    gap: 16px;
  }
}