/* ============================================
   RSL Progress Bar Component
   Version: 1.0.0
   Description: Powerful, flexible progress bars with
   multiple shapes, animations, thresholds, milestones,
   and full accessibility support.
   ============================================ */

/* ============================================
   BASE STYLES
   ============================================ */

.rsl-progress {
    --rsl-progress-height: 1rem;
    --rsl-progress-bg: #e9ecef;
    --rsl-progress-fill: #6E7BFF;
    --rsl-progress-radius: 0.5rem;
    --rsl-progress-transition: width 0.6s ease, background-color 0.3s ease;
    --rsl-progress-label-color: #fff;
    --rsl-progress-stripe-color: rgba(255, 255, 255, 0.15);

    position: relative;
    width: 100%;
    height: var(--rsl-progress-height);
    background-color: var(--rsl-progress-bg);
    border-radius: var(--rsl-progress-radius);
    overflow: hidden;
    font-size: 0.75rem;
    line-height: 1;
}

/* Progress fill/bar */
.rsl-progress-bar {
    position: relative;
    height: 100%;
    background-color: var(--rsl-progress-fill);
    border-radius: inherit;
    transition: var(--rsl-progress-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--rsl-progress-label-color);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
}

/* Buffer track (for streaming/video style) */
.rsl-progress-buffer {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: rgba(110, 123, 255, 0.3);
    border-radius: inherit;
    transition: width 0.3s ease;
    z-index: 0;
}

.rsl-progress-bar {
    z-index: 1;
}

/* ============================================
   SIZE VARIANTS
   ============================================ */

.rsl-progress-xs {
    --rsl-progress-height: 0.25rem;
    font-size: 0;
}

.rsl-progress-sm {
    --rsl-progress-height: 0.5rem;
    font-size: 0.625rem;
}

.rsl-progress-md {
    --rsl-progress-height: 1rem;
}

.rsl-progress-lg {
    --rsl-progress-height: 1.5rem;
    font-size: 0.875rem;
}

.rsl-progress-xl {
    --rsl-progress-height: 2rem;
    font-size: 1rem;
}

/* ============================================
   COLOR VARIANTS
   ============================================ */

.rsl-progress-primary {
    --rsl-progress-fill: #6E7BFF;
}

.rsl-progress-secondary {
    --rsl-progress-fill: #6c757d;
}

.rsl-progress-success {
    --rsl-progress-fill: #28a745;
}

.rsl-progress-warning {
    --rsl-progress-fill: #ffc107;
    --rsl-progress-label-color: #212529;
}

.rsl-progress-danger {
    --rsl-progress-fill: #dc3545;
}

.rsl-progress-info {
    --rsl-progress-fill: #17a2b8;
}

.rsl-progress-dark {
    --rsl-progress-fill: #343a40;
}

.rsl-progress-light {
    --rsl-progress-fill: #f8f9fa;
    --rsl-progress-label-color: #212529;
}

/* ============================================
   GRADIENT VARIANTS
   ============================================ */

.rsl-progress-gradient-primary {
    --rsl-progress-fill: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.rsl-progress-gradient-success {
    --rsl-progress-fill: linear-gradient(90deg, #11998e 0%, #38ef7d 100%);
}

.rsl-progress-gradient-warning {
    --rsl-progress-fill: linear-gradient(90deg, #f2994a 0%, #f2c94c 100%);
    --rsl-progress-label-color: #212529;
}

.rsl-progress-gradient-danger {
    --rsl-progress-fill: linear-gradient(90deg, #ed213a 0%, #93291e 100%);
}

.rsl-progress-gradient-info {
    --rsl-progress-fill: linear-gradient(90deg, #2193b0 0%, #6dd5ed 100%);
}

.rsl-progress-gradient-rainbow {
    --rsl-progress-fill: linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8f00ff);
}

.rsl-progress-gradient-ocean {
    --rsl-progress-fill: linear-gradient(90deg, #2E3192 0%, #1BFFFF 100%);
}

.rsl-progress-gradient-fire {
    --rsl-progress-fill: linear-gradient(90deg, #f12711 0%, #f5af19 100%);
}

.rsl-progress-gradient-purple {
    --rsl-progress-fill: linear-gradient(90deg, #8E2DE2 0%, #4A00E0 100%);
}

/* Apply gradient backgrounds */
.rsl-progress[class*="gradient-"] .rsl-progress-bar {
    background: var(--rsl-progress-fill);
}

/* ============================================
   STRIPED PATTERN
   ============================================ */

.rsl-progress-striped .rsl-progress-bar {
    background-image: linear-gradient(
        45deg,
        var(--rsl-progress-stripe-color) 25%,
        transparent 25%,
        transparent 50%,
        var(--rsl-progress-stripe-color) 50%,
        var(--rsl-progress-stripe-color) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
}

/* Animated stripes */
.rsl-progress-striped.rsl-progress-animated .rsl-progress-bar {
    animation: rsl-progress-stripes 1s linear infinite;
}

@keyframes rsl-progress-stripes {
    0% {
        background-position: 1rem 0;
    }
    100% {
        background-position: 0 0;
    }
}

/* ============================================
   INDETERMINATE STATE
   ============================================ */

.rsl-progress-indeterminate .rsl-progress-bar {
    width: 30% !important;
    animation: rsl-progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes rsl-progress-indeterminate {
    0% {
        left: -30%;
    }
    100% {
        left: 100%;
    }
}

.rsl-progress-indeterminate .rsl-progress-bar {
    position: absolute;
    left: -30%;
}

/* Alternative shimmer indeterminate */
.rsl-progress-indeterminate.rsl-progress-shimmer .rsl-progress-bar {
    width: 100% !important;
    left: 0 !important;
    animation: none;
    background: linear-gradient(
        90deg,
        var(--rsl-progress-bg) 0%,
        var(--rsl-progress-fill) 50%,
        var(--rsl-progress-bg) 100%
    );
    background-size: 200% 100%;
    animation: rsl-progress-shimmer 1.5s ease-in-out infinite;
}

@keyframes rsl-progress-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   LABEL POSITIONS
   ============================================ */

/* Label inside bar (default) */
.rsl-progress-label-inside .rsl-progress-bar {
    justify-content: center;
}

/* Label outside (right) */
.rsl-progress-label-outside {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: auto;
    background: transparent;
    overflow: visible;
}

.rsl-progress-label-outside .rsl-progress-track {
    flex: 1;
    height: var(--rsl-progress-height);
    background-color: var(--rsl-progress-bg);
    border-radius: var(--rsl-progress-radius);
    overflow: hidden;
    position: relative;
}

.rsl-progress-label-outside .rsl-progress-bar {
    height: 100%;
}

.rsl-progress-label-outside .rsl-progress-label {
    color: #333;
    font-weight: 600;
    min-width: 3rem;
    text-align: right;
}

[data-theme="dark"] .rsl-progress-label-outside .rsl-progress-label {
    color: #e0e0e0;
}

/* Label floating above */
.rsl-progress-label-floating {
    overflow: visible;
    padding-top: 1.5rem;
}

.rsl-progress-label-floating .rsl-progress-label {
    position: absolute;
    top: -1.25rem;
    transform: translateX(-50%);
    background: var(--rsl-progress-fill);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 10;
}

.rsl-progress-label-floating .rsl-progress-label::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--rsl-progress-fill);
}

/* Hidden label (for screen readers only) */
.rsl-progress-label-hidden .rsl-progress-bar {
    font-size: 0;
}

.rsl-progress-label-hidden .rsl-progress-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   MILESTONES / MARKERS
   ============================================ */

.rsl-progress-milestones {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.rsl-progress-milestone {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 0.75rem;
    height: 0.75rem;
    background: white;
    border: 2px solid #6E7BFF;
    border-radius: 50%;
    z-index: 6;
    transition: all 0.3s ease;
}

.rsl-progress-milestone.completed {
    background: #6E7BFF;
    border-color: #6E7BFF;
}

.rsl-progress-milestone.completed::after {
    content: '\2713';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.5rem;
    font-weight: bold;
}

/* Milestone labels */
.rsl-progress-milestone-label {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.625rem;
    color: #666;
    white-space: nowrap;
}

[data-theme="dark"] .rsl-progress-milestone-label {
    color: #aaa;
}

/* ============================================
   STEP PROGRESS (Discrete Steps)
   ============================================ */

.rsl-progress-steps {
    display: flex;
    align-items: center;
    gap: 0;
    height: auto;
    background: transparent;
    overflow: visible;
}

.rsl-progress-step {
    flex: 1;
    height: var(--rsl-progress-height);
    background: var(--rsl-progress-bg);
    position: relative;
    transition: background-color 0.3s ease;
}

.rsl-progress-step:first-child {
    border-radius: var(--rsl-progress-radius) 0 0 var(--rsl-progress-radius);
}

.rsl-progress-step:last-child {
    border-radius: 0 var(--rsl-progress-radius) var(--rsl-progress-radius) 0;
}

.rsl-progress-step:not(:last-child) {
    margin-right: 2px;
}

.rsl-progress-step.completed {
    background: var(--rsl-progress-fill);
}

.rsl-progress-step.active {
    background: var(--rsl-progress-fill);
    animation: rsl-progress-pulse 1.5s ease-in-out infinite;
}

/* Step with numbers/icons */
.rsl-progress-step-marker {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    width: 1.5rem;
    height: 1.5rem;
    background: var(--rsl-progress-bg);
    border: 2px solid var(--rsl-progress-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: 700;
    color: #666;
    transition: all 0.3s ease;
}

.rsl-progress-step.completed .rsl-progress-step-marker {
    background: var(--rsl-progress-fill);
    border-color: var(--rsl-progress-fill);
    color: white;
}

.rsl-progress-step.active .rsl-progress-step-marker {
    border-color: var(--rsl-progress-fill);
    color: var(--rsl-progress-fill);
}

/* ============================================
   SEGMENTED / STACKED PROGRESS
   ============================================ */

.rsl-progress-stacked {
    display: flex;
    overflow: hidden;
}

.rsl-progress-stacked .rsl-progress-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

/* ============================================
   COMPARISON BAR (Dual Values)
   ============================================ */

.rsl-progress-comparison .rsl-progress-bar-secondary {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    border-radius: inherit;
    z-index: 0;
}

.rsl-progress-comparison .rsl-progress-bar {
    z-index: 1;
}

/* ============================================
   CIRCULAR / RADIAL PROGRESS
   ============================================ */

.rsl-progress-circular {
    --rsl-progress-size: 120px;
    --rsl-progress-stroke: 8px;

    width: var(--rsl-progress-size);
    height: var(--rsl-progress-size);
    border-radius: 50%;
    background: transparent;
    position: relative;
    overflow: visible;
}

.rsl-progress-circular svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.rsl-progress-circular .progress-track {
    fill: none;
    stroke: var(--rsl-progress-bg);
    stroke-width: var(--rsl-progress-stroke);
}

.rsl-progress-circular .progress-fill {
    fill: none;
    stroke: var(--rsl-progress-fill);
    stroke-width: var(--rsl-progress-stroke);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease;
}

.rsl-progress-circular .rsl-progress-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

[data-theme="dark"] .rsl-progress-circular .rsl-progress-label {
    color: #e0e0e0;
}

/* Circular sizes */
.rsl-progress-circular.rsl-progress-sm {
    --rsl-progress-size: 60px;
    --rsl-progress-stroke: 4px;
}

.rsl-progress-circular.rsl-progress-sm .rsl-progress-label {
    font-size: 0.875rem;
}

.rsl-progress-circular.rsl-progress-md {
    --rsl-progress-size: 100px;
    --rsl-progress-stroke: 6px;
}

.rsl-progress-circular.rsl-progress-md .rsl-progress-label {
    font-size: 1.25rem;
}

.rsl-progress-circular.rsl-progress-lg {
    --rsl-progress-size: 150px;
    --rsl-progress-stroke: 10px;
}

.rsl-progress-circular.rsl-progress-lg .rsl-progress-label {
    font-size: 2rem;
}

.rsl-progress-circular.rsl-progress-xl {
    --rsl-progress-size: 200px;
    --rsl-progress-stroke: 12px;
}

.rsl-progress-circular.rsl-progress-xl .rsl-progress-label {
    font-size: 2.5rem;
}

/* ============================================
   SEMI-CIRCULAR / GAUGE
   ============================================ */

.rsl-progress-gauge {
    --rsl-progress-size: 200px;
    --rsl-progress-stroke: 12px;

    width: var(--rsl-progress-size);
    height: calc(var(--rsl-progress-size) / 2 + 20px);
    position: relative;
    overflow: visible;
}

.rsl-progress-gauge svg {
    width: 100%;
    overflow: visible;
}

.rsl-progress-gauge .progress-track,
.rsl-progress-gauge .progress-fill {
    fill: none;
    stroke-width: var(--rsl-progress-stroke);
    stroke-linecap: round;
}

.rsl-progress-gauge .progress-track {
    stroke: var(--rsl-progress-bg);
}

.rsl-progress-gauge .progress-fill {
    stroke: var(--rsl-progress-fill);
    transition: stroke-dashoffset 0.6s ease;
}

.rsl-progress-gauge .rsl-progress-label {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.75rem;
    font-weight: 700;
    color: #333;
}

[data-theme="dark"] .rsl-progress-gauge .rsl-progress-label {
    color: #e0e0e0;
}

/* Gauge tick marks */
.rsl-progress-gauge .gauge-ticks {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.rsl-progress-gauge .gauge-tick {
    position: absolute;
    width: 2px;
    height: 8px;
    background: #ccc;
    transform-origin: center calc(var(--rsl-progress-size) / 2);
}

/* ============================================
   VERTICAL PROGRESS
   ============================================ */

.rsl-progress-vertical {
    --rsl-progress-width: 1rem;

    width: var(--rsl-progress-width);
    height: 200px;
    display: flex;
    flex-direction: column-reverse;
}

.rsl-progress-vertical .rsl-progress-bar {
    width: 100%;
    height: 0;
    transition: height 0.6s ease;
}

/* Vertical sizes */
.rsl-progress-vertical.rsl-progress-sm {
    --rsl-progress-width: 0.5rem;
}

.rsl-progress-vertical.rsl-progress-lg {
    --rsl-progress-width: 1.5rem;
}

.rsl-progress-vertical.rsl-progress-xl {
    --rsl-progress-width: 2rem;
}

/* ============================================
   ANIMATIONS & EFFECTS
   ============================================ */

/* Pulse effect */
.rsl-progress-pulse .rsl-progress-bar {
    animation: rsl-progress-pulse 2s ease-in-out infinite;
}

@keyframes rsl-progress-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Glow effect */
.rsl-progress-glow .rsl-progress-bar {
    box-shadow: 0 0 10px var(--rsl-progress-fill),
                0 0 20px var(--rsl-progress-fill);
}

/* Gradient animation */
.rsl-progress-gradient-animated .rsl-progress-bar {
    background-size: 200% 100%;
    animation: rsl-progress-gradient-shift 3s ease infinite;
}

@keyframes rsl-progress-gradient-shift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Value count-up animation class (applied by JS) */
.rsl-progress-counting .rsl-progress-bar {
    transition: width 1.5s ease-out;
}

/* ============================================
   THRESHOLD STATES (Auto-applied by JS)
   ============================================ */

.rsl-progress[data-threshold-state="success"] {
    --rsl-progress-fill: #28a745;
}

.rsl-progress[data-threshold-state="warning"] {
    --rsl-progress-fill: #ffc107;
    --rsl-progress-label-color: #212529;
}

.rsl-progress[data-threshold-state="danger"] {
    --rsl-progress-fill: #dc3545;
}

/* ============================================
   SKILL BAR VARIANT
   ============================================ */

.rsl-progress-skill {
    margin-bottom: 1.5rem;
}

.rsl-progress-skill-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.rsl-progress-skill-name {
    font-weight: 600;
    color: #333;
}

.rsl-progress-skill-value {
    font-weight: 700;
    color: var(--rsl-progress-fill);
}

[data-theme="dark"] .rsl-progress-skill-name {
    color: #e0e0e0;
}

/* ============================================
   DARK MODE
   ============================================ */

[data-theme="dark"] .rsl-progress {
    --rsl-progress-bg: #374151;
}

[data-theme="dark"] .rsl-progress-milestone {
    background: #1f2937;
    border-color: #6E7BFF;
}

[data-theme="dark"] .rsl-progress-milestone.completed {
    background: #6E7BFF;
}

[data-theme="dark"] .rsl-progress-step-marker {
    background: #374151;
    color: #9ca3af;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .rsl-progress-bar,
    .rsl-progress-buffer,
    .rsl-progress-milestone,
    .rsl-progress-step {
        transition: none;
    }

    .rsl-progress-striped.rsl-progress-animated .rsl-progress-bar,
    .rsl-progress-indeterminate .rsl-progress-bar,
    .rsl-progress-pulse .rsl-progress-bar,
    .rsl-progress-gradient-animated .rsl-progress-bar {
        animation: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .rsl-progress {
        border: 2px solid currentColor;
    }

    .rsl-progress-bar {
        background: currentColor;
    }
}

/* Focus visible for interactive progress */
.rsl-progress:focus-visible {
    outline: 2px solid #6E7BFF;
    outline-offset: 2px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .rsl-progress-circular {
        --rsl-progress-size: 100px;
    }

    .rsl-progress-gauge {
        --rsl-progress-size: 160px;
    }

    .rsl-progress-label-floating .rsl-progress-label {
        font-size: 0.625rem;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Quick height overrides */
.rsl-progress-thin {
    --rsl-progress-height: 0.25rem;
}

.rsl-progress-thick {
    --rsl-progress-height: 1.5rem;
}

/* Remove border radius */
.rsl-progress-square {
    --rsl-progress-radius: 0;
}

/* Full border radius */
.rsl-progress-rounded {
    --rsl-progress-radius: 9999px;
}
