/* Компонент загрузки с прогресс-баром */

/* Контейнер загрузки */
.loading-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    padding-top: max(16px, var(--safe-area-inset-top, 0px));
    padding-bottom: max(16px, var(--safe-area-inset-bottom, 0px));
    padding-left: max(16px, var(--safe-area-inset-left, 0px));
    padding-right: max(16px, var(--safe-area-inset-right, 0px));
    box-sizing: border-box;
    overflow: hidden;
    animation: fadeInLoading 0.3s ease-out;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    contain: layout style paint;
}

/* Фон с блюром */
.loading-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 10, 20, 0.9);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 0;
}

/* Основной контейнер */
.loading-container {
    position: relative;
    z-index: 1;
    max-width: 560px;
    width: 100%;
    max-height: calc(100dvh - 32px);
    background: linear-gradient(145deg, rgba(18, 24, 38, 0.96) 0%, rgba(12, 18, 32, 0.98) 100%);
    border: 1px solid var(--placeholder-purple-rgba-25, rgba(139, 92, 246, 0.25));
    border-radius: 24px;
    padding: 36px 32px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px var(--placeholder-purple-rgba-20, rgba(139, 92, 246, 0.2)) inset;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: slideUpLoading 0.3s ease-out;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    contain: layout style;
}

/* Заголовок */
.loading-title {
    font-family: var(--font-family-serif, 'Cormorant Garamond', serif);
    font-size: clamp(22px, 4.2vw, 28px);
    font-weight: 600;
    text-align: center;
    margin: 0 0 32px 0;
    padding: 0;
    background: linear-gradient(135deg, 
        #E8C547 0%, 
        #F5D76E 30%,
        #E8C547 60%,
        #D4AF37 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.4px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.35;
    box-sizing: border-box;
}

/* Информация о пользователе */
.loading-user-info {
    text-align: center;
    margin-bottom: 32px;
    padding: 16px 20px;
    background: var(--placeholder-bg-dark, rgba(15, 23, 42, 0.5));
    border: 1px solid var(--placeholder-purple-rgba-25, rgba(139, 92, 246, 0.25));
    border-radius: 14px;
    box-sizing: border-box;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.loading-user-info p {
    margin: 0;
    line-height: 1.6;
}

/* Дата рождения и возраст */
.loading-user-birthdate-line,
.loading-user-age-line {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: clamp(14px, 2.8vw, 16px);
    color: var(--color-text, #e8eef3);
    font-weight: 500;
    letter-spacing: 0.4px;
    width: auto;
}

.loading-user-birthdate-line span,
.loading-user-age-line span {
    margin-left: 6px;
    color: var(--placeholder-gold, #F5D76E);
    font-weight: 600;
}

.loading-user-birthdate-line {
    margin-bottom: 0;
}

.loading-user-birthdate-line::before,
.loading-user-age-line::before {
    content: '✨';
    margin-right: 6px;
    font-size: 14px;
    filter: drop-shadow(0 0 3px rgba(251, 191, 36, 0.4));
    flex-shrink: 0;
}

/* Десктоп: в две строки по центру */
@media (min-width: 1025px) {
    .loading-user-info {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 20px 28px;
    }
    
    .loading-user-birthdate-line,
    .loading-user-age-line {
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        width: auto;
    }
    
    .loading-user-birthdate-line {
        margin-bottom: 0;
    }
    
    .loading-user-birthdate-line::before,
    .loading-user-age-line::before {
        content: '✨';
        margin-right: 8px;
        font-size: 16px;
        filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.4));
        flex-shrink: 0;
    }
}

/* Список шагов */
.loading-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 48px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
}

/* Шаг */
.loading-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--placeholder-bg-dark, rgba(15, 23, 42, 0.45));
    border: 1px solid var(--placeholder-purple-rgba-20, rgba(139, 92, 246, 0.2));
    border-radius: 12px;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                background 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                border-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.65;
    box-sizing: border-box;
    min-height: 48px;
}

.loading-step.active {
    opacity: 1;
    background: linear-gradient(135deg, var(--placeholder-purple-rgba-15, rgba(139, 92, 246, 0.15)) 0%, var(--placeholder-gold-rgba-10, rgba(251, 191, 36, 0.1)) 100%);
    border-color: var(--placeholder-gold-rgba-40, rgba(251, 191, 36, 0.4));
    box-shadow: 
        0 2px 12px var(--placeholder-purple-rgba-20, rgba(139, 92, 246, 0.2)),
        0 0 20px var(--placeholder-gold-rgba-10, rgba(251, 191, 36, 0.1));
}

/* Иконка шага */
.step-icon {
    font-size: 22px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-step.active .step-icon {
    opacity: 1;
    transform: scale(1.05);
}

/* Текст шага */
.step-text {
    font-size: clamp(14px, 2.9vw, 16px);
    font-weight: 500;
    color: var(--color-text, #e8eef3);
    letter-spacing: 0.25px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.45;
}

.loading-step.active .step-text {
    color: var(--placeholder-gold, #F5D76E);
    font-weight: 600;
}

/* Контейнер прогресса */
.loading-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
    padding: 0 5%;
}

/* Полоса прогресса */
.progress-bar {
    position: relative;
    width: 100%;
    height: 8px;
    background: var(--placeholder-bg-darker, rgba(15, 23, 42, 0.65));
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 
        inset 0 2px 4px var(--placeholder-shadow-dark, rgba(0, 0, 0, 0.3)),
        0 1px 2px var(--placeholder-shadow-dark, rgba(0, 0, 0, 0.2));
    box-sizing: border-box;
}

/* Заполнение прогресса */
.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, 
        var(--placeholder-purple, #8B5CF6) 0%, 
        var(--placeholder-purple-light, #A78BFA) 25%,
        var(--placeholder-gold, #F5D76E) 70%,
        var(--placeholder-gold-hover, #FBBF24) 100%);
    border-radius: 12px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 0 12px var(--placeholder-purple-rgba-40, rgba(139, 92, 246, 0.4)),
        0 0 20px var(--placeholder-gold-rgba-20, rgba(251, 191, 36, 0.2));
    box-sizing: border-box;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: width, background;
}

/* Золотой градиент при 100% */
.progress-fill.complete {
    background: linear-gradient(90deg, var(--placeholder-gold, #F5D76E) 0%, var(--placeholder-gold-hover, #FBBF24) 50%, var(--placeholder-gold, #F5D76E) 100%);
    box-shadow: 0 0 15px var(--placeholder-gold-rgba-50, rgba(251, 191, 36, 0.5)), 0 0 25px var(--placeholder-gold-rgba-30, rgba(245, 215, 110, 0.3));
}

/* Текст процента */
.progress-text {
    font-size: clamp(17px, 3.6vw, 20px);
    font-weight: 700;
    color: var(--placeholder-gold, #F5D76E);
    text-align: center;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
    min-height: 1.3em;
    text-shadow: 0 0 10px var(--placeholder-gold-rgba-30, rgba(245, 215, 110, 0.3));
}

/* Анимации */
@keyframes fadeInLoading {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUpLoading {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Планшеты (769px-1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .loading-container {
        max-width: 416px;
        padding: 32px 28px;
    }
    
    .loading-title {
        margin-bottom: 28px;
    }
    
    .loading-user-info {
        margin-bottom: 28px;
        padding: 13px 17px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    
    .loading-steps {
        gap: 12px;
        margin-bottom: 44px;
    }
    
    .loading-step {
        padding: 13px 17px;
        gap: 13px;
    }
    
    .step-icon {
        font-size: 20px;
        width: 28px;
        height: 28px;
    }
    
    .progress-bar {
        height: 6px;
    }
}

/* Мобильные (≤768px) */
@media (max-width: 768px) {
    .loading-section {
        padding: 8px 20px;
        padding-top: max(8px, var(--safe-area-inset-top, 0px));
        padding-bottom: max(8px, var(--safe-area-inset-bottom, 0px));
        padding-left: max(20px, var(--safe-area-inset-left, 0px));
        padding-right: max(20px, var(--safe-area-inset-right, 0px));
    }
    
    .loading-container {
        max-width: 85%;
        padding: 22px 16px;
        border-radius: 18px;
        max-height: calc(100dvh - 16px);
    }
    
    .loading-title {
        font-size: clamp(20px, 3.8vw, 24px);
        margin-bottom: 20px;
        line-height: 1.25;
    }
    
    .loading-user-info {
        margin-bottom: 20px;
        padding: 14px 16px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        text-align: center;
        border-radius: 14px;
    }
    
    .loading-user-birthdate-line,
    .loading-user-age-line {
        font-size: clamp(12px, 2.4vw, 14px);
        line-height: 1.5;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        width: auto;
    }
    
    .loading-user-birthdate-line::before,
    .loading-user-age-line::before {
        content: '✨';
        margin-right: 5px;
        font-size: 13px;
        filter: drop-shadow(0 0 3px rgba(251, 191, 36, 0.4));
        flex-shrink: 0;
    }
    
    .loading-user-birthdate-line span,
    .loading-user-age-line span {
        margin-left: 6px;
        color: var(--placeholder-gold, #F5D76E);
        font-weight: 600;
    }
    
    .loading-user-birthdate-line {
        margin-bottom: 0;
    }
    
    .loading-steps {
        gap: 8px;
        margin-bottom: 24px;
    }
    
    .loading-step {
        padding: 10px 12px;
        gap: 10px;
        min-height: 40px;
    }
    
    .step-icon {
        font-size: 18px;
        width: 24px;
        height: 24px;
    }
    
    .step-text {
        font-size: clamp(12px, 2.6vw, 14px);
        line-height: 1.35;
    }
    
    .progress-bar {
        height: 5px;
    }
    
    .loading-progress {
        gap: 8px;
    }
    
    .progress-text {
        font-size: clamp(16px, 3.2vw, 18px);
    }
}

/* Маленькие мобильные (≤480px) */
@media (max-width: 480px) {
    .loading-section {
        padding: 6px 16px;
        padding-top: max(6px, var(--safe-area-inset-top, 0px));
        padding-bottom: max(6px, var(--safe-area-inset-bottom, 0px));
        padding-left: max(16px, var(--safe-area-inset-left, 0px));
        padding-right: max(16px, var(--safe-area-inset-right, 0px));
    }
    
    .loading-container {
        padding: 18px 14px;
        border-radius: 16px;
        max-height: calc(100dvh - 12px);
    }
    
    .loading-title {
        font-size: clamp(19px, 3.8vw, 22px);
        margin-bottom: 16px;
        line-height: 1.25;
    }
    
    .loading-user-info {
        margin-bottom: 16px;
        padding: 12px 14px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        text-align: center;
        border-radius: 12px;
    }
    
    .loading-user-birthdate-line,
    .loading-user-age-line {
        font-size: clamp(12px, 2.4vw, 13px);
        line-height: 1.5;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        width: auto;
    }
    
    .loading-user-birthdate-line::before,
    .loading-user-age-line::before {
        content: '✨';
        margin-right: 5px;
        font-size: 13px;
        filter: drop-shadow(0 0 3px rgba(251, 191, 36, 0.4));
        flex-shrink: 0;
    }
    
    .loading-user-birthdate-line span,
    .loading-user-age-line span {
        margin-left: 6px;
        color: var(--placeholder-gold, #F5D76E);
        font-weight: 600;
    }
    
    .loading-user-birthdate-line {
        margin-bottom: 0;
    }
    
    .loading-steps {
        gap: 6px;
        margin-bottom: 18px;
    }
    
    .loading-step {
        padding: 9px 11px;
        gap: 9px;
        min-height: 38px;
    }
    
    .step-icon {
        font-size: 17px;
        width: 22px;
        height: 22px;
    }
    
    .step-text {
        font-size: clamp(12px, 2.5vw, 13px);
        line-height: 1.35;
    }
    
    .progress-bar {
        height: 5px;
    }
    
    .loading-progress {
        gap: 6px;
    }
    
    .progress-text {
        font-size: clamp(15px, 3vw, 17px);
    }
}

/* Очень маленькие (≤360px) */
@media (max-width: 360px) {
    .loading-container {
        padding: 16px 12px;
        border-radius: 14px;
    }
    
    .loading-title {
        font-size: clamp(18px, 3.5vw, 20px);
        margin-bottom: 14px;
    }
    
    .loading-user-info {
        margin-bottom: 14px;
        padding: 10px 12px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        text-align: center;
        border-radius: 12px;
    }
    
    .loading-user-birthdate-line,
    .loading-user-age-line {
        font-size: clamp(11px, 2.3vw, 12px);
        line-height: 1.5;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        width: auto;
    }
    
    .loading-user-birthdate-line::before,
    .loading-user-age-line::before {
        content: '✨';
        margin-right: 4px;
        font-size: 11px;
        filter: drop-shadow(0 0 2px rgba(251, 191, 36, 0.4));
        flex-shrink: 0;
    }
    
    .loading-user-birthdate-line span,
    .loading-user-age-line span {
        margin-left: 6px;
        color: var(--placeholder-gold, #F5D76E);
        font-weight: 600;
    }
    
    .loading-user-birthdate-line {
        margin-bottom: 0;
    }
    
    .loading-steps {
        gap: 5px;
        margin-bottom: 16px;
    }
    
    .loading-step {
        padding: 8px 10px;
        gap: 8px;
        min-height: 36px;
    }
    
    .step-icon {
        font-size: 16px;
        width: 20px;
        height: 20px;
    }
    
    .progress-bar {
        height: 4px;
    }
    
    .progress-text {
        font-size: clamp(14px, 2.8vw, 16px);
    }
}

/* Отключение анимаций для prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .loading-section,
    .loading-container {
        animation: none;
    }
    
    .loading-step {
        transition: opacity 0.2s ease;
    }
    
    .progress-fill {
        transition: width 0.2s linear;
    }
}

/* Fallback для backdrop-filter */
@supports not (backdrop-filter: blur(6px)) {
    .loading-backdrop {
        background: rgba(8, 10, 20, 0.95);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    
    .loading-container {
        background: rgba(18, 24, 38, 0.98);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}
