/* =====================================================
   MODULE: PROGRESS, SPINNERS & SKELETONS
   Determinate/indeterminate bars, spinners, loading
   dots, skeleton loading placeholders.
   Full per-theme overrides for all 4 themes.
   Toggle: modules.progress in theme-config.json
   ===================================================== */

/* ============= PROGRESS BAR ============= */
.progress {
    width: 100%;
    height: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full, 9999px);
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full, 9999px);
    transition: width var(--duration-slow, 400ms) var(--ease-default);
    min-width: 0;
}

/* Sizes */
.progress-sm { height: 0.25rem; }
.progress-lg { height: 0.75rem; }

/* Color variants */
.progress-bar.success { background: var(--color-success); }
.progress-bar.danger  { background: var(--color-danger); }
.progress-bar.warning { background: var(--color-warning); }
.progress-bar.info    { background: var(--color-info); }

/* Label inside bar */
.progress-bar-label {
    font-size: 0.625rem;
    font-weight: 700;
    color: #fff;
    line-height: 0.75rem;
    padding: 0 0.375rem;
    white-space: nowrap;
}

/* Indeterminate */
.progress-indeterminate .progress-bar {
    width: 30% !important;
    animation: progress-slide 2.2s var(--ease-default) infinite;
}
@keyframes progress-slide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

/* Striped */
.progress-striped .progress-bar {
    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%
    );
    background-size: 1rem 1rem;
}
.progress-striped.progress-animated .progress-bar {
    animation: progress-stripe-move 1s linear infinite;
}
@keyframes progress-stripe-move {
    from { background-position: 1rem 0; }
    to   { background-position: 0 0; }
}

/* ============= PROGRESS WITH LABEL ============= */
.progress-labeled {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.progress-labeled .progress { flex: 1; }
.progress-labeled .progress-text {
    font-size: var(--font-size-xs, 0.75rem);
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 2.5rem;
    text-align: right;
}

/* ============= CIRCULAR PROGRESS ============= */
.progress-circle {
    width: 3rem; height: 3rem;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.progress-circle svg {
    width: 100%; height: 100%;
    transform: rotate(-90deg);
}
.progress-circle-track {
    fill: none;
    stroke: var(--bg-tertiary);
    stroke-width: 4;
}
.progress-circle-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dashoffset var(--duration-slow, 400ms) var(--ease-default);
}
.progress-circle-label {
    position: absolute;
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ============= SPINNER ============= */
.spinner {
    width: 1.5rem; height: 1.5rem;
    border: 2px solid var(--border-secondary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner-sm { width: 1rem; height: 1rem; border-width: 1.5px; }
.spinner-lg { width: 2.5rem; height: 2.5rem; border-width: 3px; }

/* ============= LOADING DOTS ============= */
.loading-dots {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}
.loading-dots span {
    width: 0.375rem; height: 0.375rem;
    background: var(--accent);
    border-radius: 50%;
    animation: dot-pulse 1.4s ease-in-out infinite both;
}
.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes dot-pulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ============= LOADING BAR (top of page) ============= */
.loading-bar {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 3px;
    z-index: var(--z-toast, 1050);
    background: transparent;
    overflow: hidden;
    pointer-events: none;
}
.loading-bar::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    width: 30%;
    background: var(--accent);
    animation: loading-bar-slide 1.5s var(--ease-default) infinite;
}
@keyframes loading-bar-slide {
    0%   { left: -30%; }
    100% { left: 100%; }
}

/* ============= SKELETON ============= */
.skeleton {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md, 0.5rem);
    position: relative;
    overflow: hidden;
}
.skeleton::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.06) 50%,
        transparent 100%
    );
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Skeleton shapes */
.skeleton-text {
    height: 0.875rem;
    width: 100%;
    margin-bottom: 0.5rem;
}
.skeleton-text:last-child { width: 60%; }
.skeleton-heading { height: 1.5rem; width: 40%; margin-bottom: 0.75rem; }
.skeleton-circle { border-radius: 50%; }
.skeleton-avatar { width: 2.5rem; height: 2.5rem; border-radius: 50%; }
.skeleton-image { width: 100%; aspect-ratio: 16/9; }
.skeleton-button { height: 2.25rem; width: 6rem; border-radius: var(--radius-lg, 0.75rem); }
.skeleton-card {
    padding: 1rem;
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg, 0.75rem);
}

/* Pulse variant (no shimmer) */
.skeleton-pulse { animation: skeleton-pulse 2s ease-in-out infinite; }
.skeleton-pulse::after { display: none; }
@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 1; }
}

/* ============= ASCII / TEXT SPINNERS ============= */
.text-spinner {
    display: inline-block;
    font-family: "SF Mono", "Fira Code", "Courier New", monospace;
    font-size: 1.5rem;
    color: var(--accent);
    width: 1.5em;
    min-height: 1.5em;
    line-height: 1.5em;
    text-align: center;
    font-weight: 700;
}
.text-spinner-sm { font-size: 0.875rem; }
.text-spinner-lg { font-size: 2rem; }

/* Braille dots spinner (default for Black Glass) */
.text-spinner-dots { animation: spin-dots 0.8s steps(10, end) infinite; }
@keyframes spin-dots {
    0%   { content: "\2818"; } /* fallback - actual cycling done via JS */
}

/* Line spinner | / - \ */
.text-spinner-line { animation: spin-line 0.5s steps(4, end) infinite; }

/* Bounce bar [=     ] */
.text-spinner-bounce {
    width: auto;
    font-size: 0.875rem;
    letter-spacing: 0;
}

/* Arrow spinner */
.text-spinner-arrow { animation: spin-arrow 0.8s steps(8, end) infinite; }

/* Moon phases */
.text-spinner-moon { animation: spin-moon 1s steps(8, end) infinite; }

/* Clock spinner */
.text-spinner-clock { animation: spin-clock 1s steps(12, end) infinite; }

/* Block fill */
.text-spinner-block { animation: spin-block 0.6s steps(5, end) infinite; }

/* Growing bar */
.text-spinner-grow { animation: spin-grow 0.8s steps(8, end) infinite; }

/* ============= BLACK GLASS ============= */
[data-theme="black-glass"] .progress { background: rgba(255, 255, 255, 0.06); }
[data-theme="black-glass"] .progress-bar { box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.3); }
[data-theme="black-glass"] .spinner { border-color: rgba(255, 255, 255, 0.08); border-top-color: var(--accent); box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.2); }
[data-theme="black-glass"] .skeleton::after {
    background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.06), transparent);
}
[data-theme="black-glass"] .loading-bar::after { box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4); }
[data-theme="black-glass"] .text-spinner {
    color: var(--accent);
    text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.4);
}

/* ============= WHITE GLASS ============= */
[data-theme="white-glass"] .progress { background: rgba(0, 0, 0, 0.06); }
[data-theme="white-glass"] .skeleton { background: rgba(0, 0, 0, 0.06); }
[data-theme="white-glass"] .skeleton::after {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
}
[data-theme="white-glass"] .spinner { border-color: rgba(0, 0, 0, 0.08); border-top-color: var(--accent); }

/* ============= RETRO 95 ============= */
[data-theme="retro"] .progress {
    border-radius: 0;
    background: #fff;
    box-shadow: inset -1px -1px #ffffff, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
    height: 1rem;
    padding: 2px;
}
[data-theme="retro"] .progress-bar {
    border-radius: 0;
    background: #000080;
    /* Chunky segmented style */
    background-image: repeating-linear-gradient(
        90deg,
        #000080 0px, #000080 8px,
        #fff 8px, #fff 10px
    );
}
[data-theme="retro"] .spinner {
    border-color: #808080;
    border-top-color: #000080;
    border-width: 3px;
}
[data-theme="retro"] .skeleton { border-radius: 0; background: #d4d0c8; }
[data-theme="retro"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent); }
[data-theme="retro"] .loading-dots span { background: #000080; border-radius: 0; }
[data-theme="retro"] .text-spinner {
    font-family: "Courier New", monospace;
    color: #000080;
    text-shadow: none;
}

/* ============= HOMEBREW ============= */
[data-theme="homebrew"] .progress {
    border-radius: 0;
    background: rgba(0, 255, 0, 0.06);
    border: 1px solid rgba(0, 255, 0, 0.15);
}
[data-theme="homebrew"] .progress-bar {
    border-radius: 0;
    background: #00ff00;
    box-shadow: 0 0 6px rgba(0, 255, 0, 0.3);
    /* ASCII block style */
    background-image: repeating-linear-gradient(
        90deg,
        #00ff00 0px, #00ff00 6px,
        #0d1117 6px, #0d1117 7px
    );
}
[data-theme="homebrew"] .spinner {
    border-color: rgba(0, 255, 0, 0.15);
    border-top-color: #00ff00;
    box-shadow: 0 0 6px rgba(0, 255, 0, 0.15);
}
[data-theme="homebrew"] .skeleton {
    border-radius: 0;
    background: rgba(0, 255, 0, 0.04);
    border: 1px solid rgba(0, 255, 0, 0.1);
}
[data-theme="homebrew"] .skeleton::after {
    background: linear-gradient(90deg, transparent, rgba(0, 255, 0, 0.06), transparent);
}
[data-theme="homebrew"] .loading-dots span {
    background: #00ff00;
    border-radius: 0;
    box-shadow: 0 0 4px rgba(0, 255, 0, 0.3);
}
[data-theme="homebrew"] .loading-bar::after {
    background: #00ff00;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.4);
}
[data-theme="homebrew"] .text-spinner {
    font-family: "Courier New", monospace;
    color: #00ff00;
    text-shadow: 0 0 6px rgba(0, 255, 0, 0.4);
}

/* ============= SKEUOMORPHIC THEME — glossy candy bar ============= */
[data-theme="skeuomorphic"] .progress {
    background: #e3ddd4;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.1);
}
[data-theme="skeuomorphic"] .progress-bar {
    background: linear-gradient(to bottom, #d42c4d 0%, #c41e3a 50%, #9a1830 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), inset 0 -1px 0 rgba(0,0,0,0.1);
}
