@use 'ui-design-system/src/styles/semantic/index' as *;

.ui-progress-circle {
  // Core Structure
  display: inline-flex;
  position: relative;
  align-items: center;
  justify-content: center;

  // Sizing variants
  &--sm {
    width: $semantic-sizing-icon-button;
    height: $semantic-sizing-icon-button;
  }

  &--md {
    width: $semantic-sizing-icon-navigation;
    height: $semantic-sizing-icon-navigation;
  }

  &--lg {
    width: $semantic-sizing-icon-header;
    height: $semantic-sizing-icon-header;
  }

  &--xl {
    width: $semantic-sizing-icon-feature;
    height: $semantic-sizing-icon-feature;
  }

  // Color variants
  &--primary {
    .ui-progress-circle__progress {
      stroke: $semantic-color-primary;
    }
  }

  &--secondary {
    .ui-progress-circle__progress {
      stroke: $semantic-color-secondary;
    }
  }

  &--success {
    .ui-progress-circle__progress {
      stroke: $semantic-color-success;
    }
  }

  &--warning {
    .ui-progress-circle__progress {
      stroke: $semantic-color-warning;
    }
  }

  &--danger {
    .ui-progress-circle__progress {
      stroke: $semantic-color-danger;
    }
  }

  &--info {
    .ui-progress-circle__progress {
      stroke: $semantic-color-info;
    }
  }

  // State variants
  &--disabled {
    opacity: 0.38;
    cursor: not-allowed;
  }

  &--indeterminate {
    .ui-progress-circle__progress {
      animation: progress-circle-spin $semantic-motion-duration-slow 
                 $semantic-easing-standard infinite linear;
      stroke-dasharray: 85, 85;
      stroke-dashoffset: 0;
    }
  }

  // SVG elements
  &__svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg); // Start progress from top
    overflow: visible;
  }

  &__track {
    fill: none;
    stroke: $semantic-color-border-subtle;
    stroke-width: 2;
  }

  &__progress {
    fill: none;
    stroke: $semantic-color-primary;
    stroke-width: 2;
    stroke-linecap: round;
    transition: stroke-dashoffset $semantic-motion-duration-normal 
                $semantic-easing-standard;
  }

  // Label content
  &__label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: $semantic-color-text-primary;
    font-size: $semantic-typography-font-size-xs;
    font-weight: $semantic-typography-font-weight-medium;
    text-align: center;
    line-height: 1;

    &--sm {
      font-size: $semantic-typography-font-size-xs;
    }

    &--md {
      font-size: $semantic-typography-font-size-xs;
    }

    &--lg {
      font-size: $semantic-typography-font-size-sm;
    }

    &--xl {
      font-size: $semantic-typography-font-size-sm;
    }

    &--disabled {
      opacity: 0.38;
    }
  }

  // Stroke width variants
  &--thin {
    .ui-progress-circle__track,
    .ui-progress-circle__progress {
      stroke-width: 1;
    }
  }

  &--thick {
    .ui-progress-circle__track,
    .ui-progress-circle__progress {
      stroke-width: 3;
    }
  }

  &--extra-thick {
    .ui-progress-circle__track,
    .ui-progress-circle__progress {
      stroke-width: 4;
    }
  }

  // Dark mode support
  :host-context(.dark-theme) & {
    .ui-progress-circle__track {
      stroke: $semantic-color-border-primary;
    }

    .ui-progress-circle__label {
      color: $semantic-color-text-primary;
    }
  }
}

// Keyframe animations
@keyframes progress-circle-spin {
  0% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(180deg);
    stroke-dasharray: 1, 200;
    stroke-dashoffset: -35;
  }
  100% {
    transform: rotate(360deg);
    stroke-dasharray: 85, 85;
    stroke-dashoffset: -124;
  }
}

// Responsive design
@media (max-width: 480px) {
  .ui-progress-circle {
    &--xl {
      width: $semantic-sizing-icon-header;
      height: $semantic-sizing-icon-header;
    }
  }
}