/* app/static/css/ui/loaders.css */
/* Стили для загрузчиков, спиннеров и прогресс-баров */

/* ==========================================================================
   1. БАЗОВЫЕ СПИННЕРЫ (КРУГОВЫЕ)
   ========================================================================== */

/* Основной спиннер */
.app-spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid color-mix(in srgb, var(--app-color-primary) 20%, transparent);
    border-radius: 50%;
    border-top-color: var(--app-color-primary);
    animation: app-spinner-rotate 0.8s linear infinite;
    vertical-align: middle;
}

/* Размеры спиннеров */
.app-spinner-xs {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

.app-spinner-sm {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 2.5px;
}

.app-spinner-lg {
    width: 3rem;
    height: 3rem;
    border-width: 4px;
}

.app-spinner-xl {
    width: 4rem;
    height: 4rem;
    border-width: 5px;
}

/* Цветовые варианты */
.app-spinner-primary {
    border-top-color: var(--app-color-primary);
    border-color: color-mix(in srgb, var(--app-color-primary) 20%, transparent);
}

.app-spinner-secondary {
    border-top-color: var(--app-color-secondary);
    border-color: color-mix(in srgb, var(--app-color-secondary) 20%, transparent);
}

.app-spinner-success {
    border-top-color: var(--app-color-success);
    border-color: color-mix(in srgb, var(--app-color-success) 20%, transparent);
}

.app-spinner-danger {
    border-top-color: var(--app-color-danger);
    border-color: color-mix(in srgb, var(--app-color-danger) 20%, transparent);
}

.app-spinner-warning {
    border-top-color: var(--app-color-warning);
    border-color: color-mix(in srgb, var(--app-color-warning) 20%, transparent);
}

.app-spinner-info {
    border-top-color: var(--app-color-info);
    border-color: color-mix(in srgb, var(--app-color-info) 20%, transparent);
}

/* Белый спиннер для темных фонов */
.app-spinner-white {
    border-top-color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Быстрая и медленная анимация */
.app-spinner-fast {
    animation: app-spinner-rotate 0.5s linear infinite;
}

.app-spinner-slow {
    animation: app-spinner-rotate 1.2s linear infinite;
}

/* Анимация вращения */
@keyframes app-spinner-rotate {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   2. СПИННЕРЫ С ТОЧКАМИ
   ========================================================================== */

/* Точковый спиннер */
.app-dot-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.app-dot-spinner .dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: var(--app-color-primary);
    animation: app-dot-bounce 1.4s ease-in-out infinite both;
}

.app-dot-spinner .dot:nth-child(1) { animation-delay: -0.32s; }
.app-dot-spinner .dot:nth-child(2) { animation-delay: -0.16s; }

/* Размеры точечных спиннеров */
.app-dot-spinner-xs .dot { width: 0.25rem; height: 0.25rem; }
.app-dot-spinner-sm .dot { width: 0.375rem; height: 0.375rem; }
.app-dot-spinner-lg .dot { width: 0.75rem; height: 0.75rem; }
.app-dot-spinner-xl .dot { width: 1rem; height: 1rem; }

/* Цветовые варианты */
.app-dot-spinner-primary .dot { background-color: var(--app-color-primary); }
.app-dot-spinner-success .dot { background-color: var(--app-color-success); }
.app-dot-spinner-danger .dot { background-color: var(--app-color-danger); }
.app-dot-spinner-warning .dot { background-color: var(--app-color-warning); }
.app-dot-spinner-white .dot { background-color: white; }

@keyframes app-dot-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ==========================================================================
   3. ПРОГРЕСС-БАРЫ (ЛИНЕЙНЫЕ)
   ========================================================================== */

/* Контейнер прогресс-бара */
.app-progress {
    width: 100%;
    height: 0.75rem;
    background-color: var(--app-color-bg-tertiary);
    border-radius: var(--app-radius-full);
    overflow: hidden;
    position: relative;
}

/* Полоса прогресса */
.app-progress-bar {
    height: 100%;
    background-color: var(--app-color-primary);
    border-radius: var(--app-radius-full);
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Анимированная полоса прогресса */
.app-progress-bar-animated {
    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;
    animation: app-progress-stripes 1s linear infinite;
}

@keyframes app-progress-stripes {
    from { background-position: 1rem 0; }
    to { background-position: 0 0; }
}

/* Размеры прогресс-баров */
.app-progress-xs { height: 0.25rem; }
.app-progress-sm { height: 0.5rem; }
.app-progress-lg { height: 1rem; }
.app-progress-xl { height: 1.5rem; }

/* Цветовые варианты */
.app-progress-primary .app-progress-bar { background-color: var(--app-color-primary); }
.app-progress-success .app-progress-bar { background-color: var(--app-color-success); }
.app-progress-danger .app-progress-bar { background-color: var(--app-color-danger); }
.app-progress-warning .app-progress-bar { background-color: var(--app-color-warning); }
.app-progress-info .app-progress-bar { background-color: var(--app-color-info); }

/* Прогресс-бар с текстом */
.app-progress-with-label {
    position: relative;
}

.app-progress-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--app-font-size-xs);
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

/* ==========================================================================
   4. КРУГОВЫЕ ПРОГРЕСС-БАРЫ
   ========================================================================== */

/* Контейнер кругового прогресса */
.app-circle-progress {
    position: relative;
    width: 5rem;
    height: 5rem;
}

/* SVG круг */
.app-circle-progress-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.app-circle-progress-track {
    fill: none;
    stroke: var(--app-color-bg-tertiary);
    stroke-width: 6;
}

.app-circle-progress-fill {
    fill: none;
    stroke: var(--app-color-primary);
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s ease;
}

/* Размеры круговых прогресс-баров */
.app-circle-progress-xs { width: 2.5rem; height: 2.5rem; }
.app-circle-progress-xs .app-circle-progress-track,
.app-circle-progress-xs .app-circle-progress-fill { stroke-width: 4; }

.app-circle-progress-sm { width: 3.5rem; height: 3.5rem; }
.app-circle-progress-sm .app-circle-progress-track,
.app-circle-progress-sm .app-circle-progress-fill { stroke-width: 5; }

.app-circle-progress-lg { width: 7rem; height: 7rem; }
.app-circle-progress-lg .app-circle-progress-track,
.app-circle-progress-lg .app-circle-progress-fill { stroke-width: 8; }

.app-circle-progress-xl { width: 10rem; height: 10rem; }
.app-circle-progress-xl .app-circle-progress-track,
.app-circle-progress-xl .app-circle-progress-fill { stroke-width: 10; }

/* Текст внутри круга */
.app-circle-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--app-font-size-sm);
    font-weight: 600;
    color: var(--app-color-text-primary);
    text-align: center;
}

/* Цветовые варианты */
.app-circle-progress-primary .app-circle-progress-fill { stroke: var(--app-color-primary); }
.app-circle-progress-success .app-circle-progress-fill { stroke: var(--app-color-success); }
.app-circle-progress-danger .app-circle-progress-fill { stroke: var(--app-color-danger); }
.app-circle-progress-warning .app-circle-progress-fill { stroke: var(--app-color-warning); }

/* ==========================================================================
   5. СКЕЛЕТОНЫ (SKELETON LOADERS)
   ========================================================================== */

/* Базовый скелетон */
.app-skeleton {
    background: linear-gradient(
        90deg,
        var(--app-color-bg-tertiary) 25%,
        var(--app-color-bg-secondary) 50%,
        var(--app-color-bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: app-skeleton-loading 2.5s ease-in-out infinite;
    border-radius: var(--app-radius-md);
}

/* Размеры скелетонов */
.app-skeleton-xs { height: 0.5rem; }
.app-skeleton-sm { height: 1rem; }
.app-skeleton-md { height: 1.5rem; }
.app-skeleton-lg { height: 2rem; }
.app-skeleton-xl { height: 3rem; }

/* Скелетон для текста */
.app-skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.app-skeleton-text:last-child {
    margin-bottom: 0;
    width: 80%;
}

/* Скелетон для изображений */
.app-skeleton-image {
    width: 100%;
    height: 0;
    padding-bottom: 75%;
    border-radius: var(--app-radius-md);
}

/* Скелетон для аватаров */
.app-skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

.app-skeleton-avatar-xs { width: 1.5rem; height: 1.5rem; }
.app-skeleton-avatar-sm { width: 2.5rem; height: 2.5rem; }
.app-skeleton-avatar-lg { width: 4rem; height: 4rem; }
.app-skeleton-avatar-xl { width: 6rem; height: 6rem; }

/* Анимация скелетона */
@keyframes app-skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.app-skeleton-full {
    position: relative;
    overflow: hidden;
    background-color: var(--app-color-bg-tertiary);
    border-radius: inherit;
}

.app-skeleton-full::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: app-skeleton-shimmer 2.5s infinite;
    pointer-events: none;
}

/* ==========================================================================
   6. ЗАГРУЗОЧНЫЕ ОБОЛОЧКИ
   ========================================================================== */

/* Контейнер с загрузкой */
.app-loading-container {
    position: relative;
}

/* Наложение загрузки */
.app-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--app-z-fixed);
    border-radius: inherit;
}

[data-theme="dark"] .app-loading-overlay {
    background-color: rgba(33, 37, 41, 0.8);
}

/* Загрузка кнопки */
.app-btn-loading {
    position: relative;
    pointer-events: none;
}

.app-btn-loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-top: -0.5rem;
    margin-left: -0.5rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-right-color: transparent;
    border-radius: 50%;
    animation: app-spinner-rotate 0.8s linear infinite;
    opacity: 0.7;
}

/* Загрузка таблицы */
.app-table-loading {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--app-color-bg-tertiary);
    border-radius: var(--app-radius-md);
}

/* ==========================================================================
   7. ИНДИКАТОРЫ ЗАГРУЗКИ СТРАНИЦЫ
   ========================================================================== */

/* Прогресс загрузки страницы (вверху) */
.app-page-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--app-color-bg-tertiary);
    z-index: var(--app-z-modal);
    display: none;
}

.app-page-progress-bar {
    height: 100%;
    background-color: var(--app-color-primary);
    width: 0%;
    transition: width 0.3s ease;
}

.app-page-progress-visible {
    display: block;
}

/* Полноэкранный загрузчик */
.app-fullscreen-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--app-color-bg-body);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: var(--app-z-modal);
}

.app-fullscreen-loader-content {
    text-align: center;
    max-width: 300px;
}

.app-fullscreen-loader-text {
    margin-top: var(--app-spacing-md);
    color: var(--app-color-text-secondary);
    font-size: var(--app-font-size-sm);
}

/* ==========================================================================
   8. ТЕМНАЯ ТЕМА
   ========================================================================== */

[data-theme="dark"] .app-progress {
    background-color: var(--app-color-bg-tertiary);
}

[data-theme="dark"] .app-circle-progress-track {
    stroke: var(--app-color-bg-secondary);
}

[data-theme="dark"] .app-skeleton {
    background: linear-gradient(
        90deg,
        var(--app-color-bg-secondary) 25%,
        var(--app-color-bg-tertiary) 50%,
        var(--app-color-bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: app-skeleton-loading 2.5s ease-in-out infinite;
}

[data-theme="dark"] .app-skeleton-full::after {
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    animation: app-skeleton-shimmer 2.5s infinite;
}

/* Анимация для темной темы */
@keyframes app-skeleton-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}


/* ==========================================================================
   9. АДАПТИВНОСТЬ
   ========================================================================== */

@media (max-width: 768px) {
    .app-spinner-lg {
        width: 2.5rem;
        height: 2.5rem;
        border-width: 3px;
    }

    .app-spinner-xl {
        width: 3rem;
        height: 3rem;
        border-width: 4px;
    }

    .app-circle-progress {
        width: 4rem;
        height: 4rem;
    }

    .app-circle-progress-lg {
        width: 5rem;
        height: 5rem;
    }

    .app-circle-progress-xl {
        width: 6rem;
        height: 6rem;
    }
}

@media (max-width: 576px) {
    .app-progress-with-label .app-progress-label {
        font-size: 0.65rem;
    }

    .app-circle-progress-text {
        font-size: var(--app-font-size-xs);
    }

    .app-fullscreen-loader-content {
        max-width: 250px;
    }
}

/* ==========================================================================
   10. УТИЛИТЫ ДЛЯ JS-КОНТРОЛЯ
   ========================================================================== */

/* Состояния видимости */
.app-loader-visible { display: block !important; }
.app-loader-hidden { display: none !important; }

/* Анимация появления */
@keyframes app-loader-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.app-loader-fade {
    animation: app-loader-fade-in var(--app-transition-normal) ease-out;
}

/* ==========================================================================
   11. ДОПОЛНИТЕЛЬНЫЕ КОМПОНЕНТЫ
   ========================================================================== */

/* Загрузчик с иконкой */
.app-loader-with-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--app-spacing-md);
}

.app-loader-icon {
    font-size: var(--app-font-size-3xl);
    color: var(--app-color-primary);
}

/* Прогресс-бар с шагами */
.app-step-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    position: relative;
}

.app-step-progress::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--app-color-bg-tertiary);
    transform: translateY(-50%);
    z-index: 0;
}

.app-step {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background-color: var(--app-color-bg-tertiary);
    border: 2px solid var(--app-color-bg-tertiary);
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--app-color-text-muted);
    font-size: var(--app-font-size-xs);
    font-weight: 600;
}

.app-step-active {
    background-color: var(--app-color-primary);
    border-color: var(--app-color-primary);
    color: white;
}

.app-step-completed {
    background-color: var(--app-color-success);
    border-color: var(--app-color-success);
    color: white;
}