/* ThemeVally Toolkit Progress Bar */

.tv-progress {
  --tv-progress-track-color: #f1f2f6;
  --tv-progress-track-height: 10px;
  --tv-progress-track-radius: 5px;

  --tv-progress-fill-color: #3b5998;
  --tv-progress-fill-height: 10px;
  --tv-progress-fill-radius: 5px;

  --tv-progress-duration: 1500ms;
  --tv-progress-delay: 0ms;
  --tv-progress-easing: ease-in-out;
  --tv-progress-counter-duration: var(--tv-progress-duration);
  --tv-progress-counter-delay: var(--tv-progress-delay);
  --tv-progress-value: 0%;

  /* Defaults for Premium Marker */
  --tv-progress-marker-offset-x: 0px;
  --tv-progress-marker-offset-y: -40px;
  --tv-progress-marker-arrow-size: 4px;

  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.tv-progress__wrapper {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* Linear */
.tv-progress--linear .tv-progress__track {
  width: 100%;
  background: var(--tv-progress-track-color);
  height: var(--tv-progress-track-height);
  border-radius: var(--tv-progress-track-radius);
  position: relative;
  overflow: visible;
  transition: all 0.3s ease;
}
.tv-progress:hover .tv-progress__track {
  background: var(--tv-progress-track-hover-color, var(--tv-progress-track-color));
  box-shadow: var(--tv-progress-track-hover-shadow, none);
}

.tv-progress--linear .tv-progress__fill {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  height: var(--tv-progress-fill-height);
  background: var(--tv-progress-fill-color);
  border-radius: var(--tv-progress-fill-radius);
  width: 0%;
  transition: width var(--tv-progress-duration) var(--tv-progress-easing) var(--tv-progress-delay), background-color 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.tv-progress:hover .tv-progress__fill {
  background-color: var(--tv-progress-fill-hover-color, var(--tv-progress-fill-color));
  box-shadow: var(--tv-progress-fill-hover-shadow, none);
}

.tv-progress.is-animated.tv-progress--linear .tv-progress__fill {
  width: var(--tv-progress-value);
}

/* Striped Fill */
.tv-progress--striped-yes .tv-progress__fill {
  background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
  background-size: 1rem 1rem;
}

.tv-progress--animated-stripe-yes .tv-progress__fill {
  animation: tv-progress-stripes 1s linear infinite;
}

@keyframes tv-progress-stripes {
  from {
    background-position: 1rem 0;
  }
  to {
    background-position: 0 0;
  }
}

/* Target Line */
.tv-progress__target {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: #000;
  z-index: 2;
  transform: translateX(-50%);
}

/* Circle & Semi-Circle */
.tv-progress__circle-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tv-progress__circle-svg {
  transform: rotate(-90deg);
  width: var(--tv-progress-circle-size, 150px);
  height: var(--tv-progress-circle-size, 150px);
}

.tv-progress--semi-circle .tv-progress__circle-svg {
  transform: rotate(180deg);
  height: calc(var(--tv-progress-circle-size, 150px) / 2);
}

.tv-progress__circle-track,
.tv-progress__circle-fill {
  fill: none;
  stroke-width: var(--tv-progress-track-height);
}

.tv-progress__circle-track {
  stroke: var(--tv-progress-track-color);
}

.tv-progress__circle-fill {
  stroke: var(--tv-progress-fill-color);
  stroke-dasharray: var(--tv-progress-dasharray, 1000);
  stroke-dashoffset: var(--tv-progress-dasharray, 1000);
  transition: stroke-dashoffset var(--tv-progress-duration) var(--tv-progress-easing) var(--tv-progress-delay);
}

.tv-progress.is-animated .tv-progress__circle-fill {
  stroke-dashoffset: var(--tv-progress-dashoffset, 0);
}

.tv-progress__circle-content {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  inset: 0;
}

.tv-progress--semi-circle .tv-progress__circle-content {
  top: auto;
  bottom: 0;
  height: 50%;
}

/* Multi & Step */
.tv-progress--multi .tv-progress__track {
  display: flex;
  width: 100%;
  background: var(--tv-progress-track-color);
  height: var(--tv-progress-track-height);
  border-radius: var(--tv-progress-track-radius);
}

.tv-progress--multi .tv-progress__segment {
  height: 100%;
  transition: width var(--tv-progress-duration) var(--tv-progress-easing) var(--tv-progress-delay);
  width: 0%;
}

.tv-progress.is-animated.tv-progress--multi .tv-progress__segment {
  width: var(--tv-segment-value, 0%);
}

/* Typography & Header */
.tv-progress__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--tv-progress-header-gap, 10px);
}

.tv-progress__title,
.tv-progress__subtitle {
  margin: 0;
  padding: 0;
}

/* Premium Marker / Tooltip */
.tv-progress__marker {
  position: absolute;
  top: var(--tv-progress-marker-top, -40px);

  /* Perfect Clamping Logic */
  left: 0%;
  transform: translateX(0%);

  display: inline-block;
  align-items: center;
  justify-content: center;
  gap: 4px;

  background: var(--tv-progress-marker-bg, #000);
  color: var(--tv-progress-marker-color, #fff);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;

  opacity: 0;
  transition:
    left var(--tv-progress-duration) var(--tv-progress-easing) var(--tv-progress-delay),
    transform var(--tv-progress-duration) var(--tv-progress-easing) var(--tv-progress-delay),
    opacity var(--tv-progress-duration) var(--tv-progress-easing) var(--tv-progress-delay),
    background-color 0.3s ease,
    color 0.3s ease;
  pointer-events: none;
  z-index: 10;
}
.tv-progress:hover .tv-progress__marker {
  background: var(--tv-progress-marker-hover-bg, var(--tv-progress-marker-bg, #000));
  color: var(--tv-progress-marker-hover-color, var(--tv-progress-marker-color, #fff));
}

.tv-progress.is-animated .tv-progress__marker {
  opacity: 1;
  left: var(--tv-progress-value);
  transform: translateX(calc(var(--tv-progress-value) * -1));
}

/* Marker Arrow */
.tv-progress__marker::before {
  position: absolute;
  content: "";

  bottom: var(--tv-progress-marker-arrow-y, -8px);

  border-top: var(--tv-progress-marker-arrow-size, 4px) solid var(--tv-progress-marker-bg, #000);
  border-right: var(--tv-progress-marker-arrow-size, 4px) solid transparent;
  border-left: var(--tv-progress-marker-arrow-size, 4px) solid transparent;
  border-bottom: 0;

  /* Arrow Tracking Logic */
  right: 0%;
  transform: translateX(-50%);
  transition: left var(--tv-progress-duration) var(--tv-progress-easing) var(--tv-progress-delay);
}

/* .tv-progress.is-animated .tv-progress__marker::before {
  left: var(--tv-progress-value);
} */

/* RTL Support */
.rtl .tv-progress__marker {
  left: auto;
  right: 0%;
  transform: translateX(0%);
}
.rtl .tv-progress.is-animated .tv-progress__marker {
  right: var(--tv-progress-value);
  transform: translateX(var(--tv-progress-value));
}
.rtl .tv-progress__marker::before {
  left: auto;
  right: 0%;
  transform: translateX(50%);
}
.rtl .tv-progress.is-animated .tv-progress__marker::before {
  right: var(--tv-progress-value);
}

/* Circle Layout Marker overrides */
.tv-progress--circle .tv-progress__marker,
.tv-progress--semi-circle .tv-progress__marker {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  transform: none;
  opacity: 1;
}
.tv-progress--circle .tv-progress__marker::before,
.tv-progress--semi-circle .tv-progress__marker::before {
  display: none;
}

/* A11y */
@media (prefers-reduced-motion: reduce) {
  .tv-progress__fill,
  .tv-progress__circle-fill,
  .tv-progress__segment,
  .tv-progress__marker,
  .tv-progress__marker::before {
    transition: none !important;
    animation: none !important;
  }
}
