.stats-container {
  max-width: 622px;
  width: 95vw;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0px 18px 0px 18px;
  box-sizing: border-box;
  background-color: var(--bg-secondary);
  border-radius: 18px;
  overflow-y: auto;
  position: relative;
  /* max-height: 100%; */
  font-family: var(--font-family);
  /* border: 1.5px solid #e0e0e0; */
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  /* height: 585px; */
}

.stats-container .wrapper {
  border: 1px solid #63636385;
  border-radius: 8px;
  /* margin: 24px 18px 0 18px; */
  padding: 3px 0 13px 0;
  background: var(--bg-primary);
}

.stats-container .close-btn {
  position: absolute;
  top: 7px;
  right: 18px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #444;
  z-index: 2;
}

.stats-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden; /* Prevent scrolling */
}

/* Prevent body scroll when stats modal is open */
body.stats-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.stats-container {
  animation: slideInScale 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInScale {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.stats-popup {
  width: 90%;
  max-width: 600px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  padding: 20px;
  position: relative;
  font-family: var(--font-family);
}

.title {
  font-size: 1.5rem;
  /* font-weight: bold; */
  margin-bottom: 20px;
  text-align: center;
  color: var(--txt-primary);
  text-align: center;
  font-family: Outfit;
  font-size: 28px;
  font-style: normal;
  font-weight: 600;
  /* line-height: normal; */
  letter-spacing: 2.24px;
  /* text-transform: uppercase; */
}

.distribution-row:last-child {
  border: none;
  padding-bottom: 0;
}

.summary {
  /* display: grid
; */
  /* grid-template-columns: 1fr 1fr; */
  /* gap: 10px; */
  width: 100%;
  text-align: center;
  margin-bottom: 20px;
}

.summary div {
  padding: 10px;
  background-color: #f9f9f9;
  /* border-radius: 4px; */
  font-size: 1rem;
}

.summary .summary-detail {
  align-items: center;
  border-bottom: 1px solid #63636354;
  display: flex;
  gap: 55px;
  height: 38px;
  justify-content: center;
  background: var(--bg-primary);
  color: var(--txt-primary);
}

.subtitle {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 10px;
  text-align: center;
  color: var(--txt-primary);
  text-align: center;
  font-family: Outfit;
  font-size: 24px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  letter-spacing: 2.2px;
}

.distribution {
  width: 100%;
  animation: fadeInUp 0.6s ease-out;
}

.distribution-row {
  display: grid;
  grid-template-columns: 1fr 4fr 1fr;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #63636354;
  padding: 7px 0px;
  opacity: 0;
  animation: slideInRow 0.5s ease-out forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRow {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes barGrowIn {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* Hover effects */
.distribution-row:hover {
  background-color: rgba(76, 175, 80, 0.05);
  transition: background-color 0.3s ease;
}

.distribution-row:hover .bar-fill {
  animation-duration: 2s;
  filter: brightness(1.1);
  transition: filter 0.3s ease;
}

.distribution-row:hover .bar-count-value {
  transform: translateY(-50%) scale(1.1);
  transition: transform 0.3s ease;
}

.label {
  text-align: center;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--txt-primary);
}

.bar-container {
  background-color: #63636324;
  border-radius: 6px;
  overflow: hidden;
  width: 446px;
  height: 20px;
  border: 1px solid rgba(99, 99, 99, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
}

/* .bar-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  animation: shimmer 2s ease-in-out infinite;
  animation-delay: 0.5s;
} */

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

.bar-fill {
  height: 100%;
  /* background: linear-gradient(
    90deg,
    #388e3c 0%,
    #4caf50 25%,
    #66bb6a 50%,
    #4caf50 75%,
    #388e3c 100%
  ); */
  background-size: 300% 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  animation: flowingGreen 3s ease-in-out infinite, barGrowIn 1s ease-out;
  transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.3);
  transform-origin: left center;
}

.bar-count-value {
    color: white;
    height: 20px;
    position: absolute;
    right: 6px;
    text-align: center;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Flowing animation keyframes */
@keyframes flowingGreen {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes flowingOrange {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* High contrast mode override */
body.high-contrast .bar-fill {
  background: linear-gradient(
    90deg,
    #e65100 0%,
    #FF6A00 25%,
    #ff8a50 50%,
    #FF6A00 75%,
    #e65100 100%
  ) !important;
  background-size: 300% 100% !important;
  animation: flowingOrange 3s ease-in-out infinite, barGrowIn 1s ease-out !important;
}

body.high-contrast .bar-count-value {
  color: black;
  /* text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8); */
}

.percent {
  text-align: center;
  font-size: 0.9rem;
  color: var(--txt-primary);
}

.footer {
  color: var(--txt-secondary);
  text-align: center;
  font-family: Outfit;
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: normal;
  padding: 5px 0px 5px 0px;
}

.footer .link {
  color: #3A8B23;
  cursor: pointer;
  text-decoration: none;
}

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

.stats-star {
  width: 15px;
  height: 15px;
  object-fit: contain;
  vertical-align: middle;
}

.stats-container::-webkit-scrollbar {
  width: 1px;
}

.summary-detail-key {
  width: 50%;
  text-align: right;
  letter-spacing: 2.2px;
}

.summary-detail-value {
  width: 50%;
}

@media (max-width: 768px) {
  .stats-container {

    border-radius: 10px;
    font-size: 0.95rem;
    padding: 0 10px;
    /* height: 517px; */
  }

  .stats-container .wrapper {
    border-radius: 6px;
    padding: 0px 0px 10px 10px;
  }

  .title {
    font-size: 1.1rem;
    margin-bottom: 10px;
  }

  .close-btn img {
    width: 14px;
    height: 14px;
  }

  .subtitle {
    font-size: 1rem;
    margin-bottom: 16px;
  }

  .summary div {
    padding: 6px;
    font-size: 0.95rem;
  }

  .summary .summary-detail {
    gap: 21px;
    font-size: 0.95rem;
    /* width: 366px;
    height: 36px; */
  }

  .distribution-row {
    grid-template-columns: 1fr 4fr 1fr;
    gap: 4px;
    /* margin-bottom: 6px; */
    font-size: 0.9rem;
  }

  .label {
    font-size: 0.9rem;
  }

  .bar-container {
    /* height: 10px; */
    border-radius: 3px;
    width: 255px
  }

  .bar-fill {
    border-radius: 3px;
  }

  .value,
  .percent {
    font-size: 0.8rem;
  }

  .footer {
    font-size: 0.8rem;
    margin-top: 3px;
    padding: 5px 0px 5px 0px;
  }

  .summary-detail-key {
    /* color: #2D2D2D; */
    /* text-align: right; */
    font-family: 'Outfit';
    font-size: 14px;
    /* font-style: normal; */
    font-weight: 500;
    /* line-height: normal; */
    text-transform: capitalize;
  }

  .stats-star {
    width: 12px;
    height: 12px;
  }

  .bar-count-value {
    font-size: 10px;
    padding-right: 4px;
  }
}