/* ========================================
   МОБИЛЬНОЕ НИЖНЕЕ МЕНЮ (Bottom Navigation)
   ======================================== */

/* Основной контейнер - оптимизирован для производительности */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.98) 0%, rgba(10, 5, 20, 0.97) 100%);
    /* backdrop-filter убран для производительности на Android */
    border-top: 1px solid rgba(139, 92, 246, 0.3);
    padding-bottom: env(safe-area-inset-bottom, 0);
    display: none;
    transition: transform 0.25s ease-out;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.6);
    will-change: transform;
}

/* Показывать только на мобильных */
@media (max-width: 991.98px) {
    .mobile-bottom-nav {
        display: block;
    }
}

/* Скрытое состояние (при скролле вниз) */
.mobile-bottom-nav.hidden {
    transform: translateY(100%);
}

/* Открыта экранная клавиатура: убираем меню полностью (display:none, а не
   transform), иначе при сжатии viewport клавиатурой fixed-меню «переезжает»
   вверх и ложится поверх поля ввода промта. */
.mobile-bottom-nav.kb-hidden {
    display: none !important;
}

.mobile-bottom-nav.hidden .mobile-nav-create-inner {
    transform: translateY(50px);
    opacity: 0;
    transition: all 0.2s ease;
}

/* Контент меню */
.mobile-nav-content {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 8px 12px;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

/* Пункты меню */
.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    padding: 8px 4px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.3s ease;
    position: relative;
    min-height: 56px;
    border: none;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Иконки */
.mobile-nav-icon {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    transition: all 0.3s ease;
}

/* Лейблы */
.mobile-nav-label {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
    text-align: center;
}

/* Баланс */
.mobile-nav-balance {
    font-size: 11px;
    font-weight: 600;
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Активное состояние */
.mobile-nav-item.active {
    color: rgba(255, 255, 255, 1);
}

.mobile-nav-item.active .mobile-nav-icon {
    stroke: url(#mobile-nav-gradient);
    filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.6));
}

/* Hover состояние (для планшетов) */
@media (hover: hover) {
    .mobile-nav-item:hover {
        color: rgba(255, 255, 255, 0.9);
    }
    
    .mobile-nav-item:hover .mobile-nav-icon {
        transform: translateY(-2px);
    }
}

/* ========================================
   ЦЕНТРАЛЬНАЯ КНОПКА "СОЗДАТЬ"
   ======================================== */

.mobile-nav-create {
    position: relative;
    margin: 0 8px;
}

.mobile-nav-create-inner {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    margin-top: -20px;
    overflow: visible;
}

/* Gradient Glow - static background (premium dark, не arcade neon) */
.mobile-nav-create-inner::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(139, 92, 246, 0.32) 0%,
        rgba(236, 72, 153, 0.16) 50%,
        transparent 70%
    );
    opacity: 0.75;
    z-index: 0;
}

.mobile-nav-create .mobile-nav-icon {
    width: 28px;
    height: 28px;
    stroke: white;
    position: relative;
    z-index: 1;
}

/* CSS-сфера вместо lottie: анимируются только transform/opacity —
   рендер на GPU, не грузит главный поток на слабых устройствах/WebView. */
.css-sphere {
    width: 60px;
    height: 60px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -30px 0 0 -30px;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 28%,
        #c4b5fd 0%,
        #8b5cf6 38%,
        #a855f7 62%,
        #ec4899 100%);
    box-shadow:
        0 0 16px rgba(139, 92, 246, 0.55),
        0 0 34px rgba(236, 72, 153, 0.3),
        inset 0 -6px 14px rgba(0, 0, 0, 0.28);
    animation: css-sphere-spin 7s linear infinite;
    will-change: transform;
    pointer-events: none;
    z-index: 1;
}

.css-sphere-glow {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(196, 181, 253, 0.5) 0%,
        rgba(139, 92, 246, 0.22) 45%,
        transparent 70%);
    animation: css-sphere-pulse 2.8s ease-in-out infinite;
}

@keyframes css-sphere-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes css-sphere-pulse {
    0%, 100% { opacity: 0.55; transform: scale(1); }
    50%      { opacity: 1;    transform: scale(1.12); }
}

/* prefers-reduced-motion здесь сознательно НЕ отключает анимацию сферы:
   на Android режим экономии батареи / «убрать анимации» включает
   reduced-motion, и кнопка выглядела «сломанной» (жалобы «пропала анимация»).
   Сфера декоративная, 60px, transform/opacity на GPU — нагрузки нет. */

.mobile-nav-plus-icon {
    width: 24px;
    height: 24px;
    stroke: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.mobile-nav-create .mobile-nav-label {
    color: white;
    font-weight: 600;
    margin-top: 4px;
}

/* Нажатие на центральную кнопку */
.mobile-nav-create:active .mobile-nav-create-inner {
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

/* ========================================
   МОДАЛЬНОЕ ОКНО ВЫБОРА ПРОВАЙДЕРА
   ======================================== */

.mobile-create-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    visibility: hidden;
    pointer-events: none;
    display: none;
}

/* Показывать модалку только на мобильных */
@media (max-width: 991.98px) {
    .mobile-create-modal {
        display: block;
    }
}

.mobile-create-modal.active {
    visibility: visible;
    pointer-events: auto;
}

/* Блокировка скролла страницы при открытом меню */
body.modal-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* Оверлей - только opacity для производительности */
.mobile-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    opacity: 0;
    transition: opacity 0.2s ease-out;
    will-change: opacity;
}

.mobile-create-modal.active .mobile-modal-overlay {
    opacity: 1;
}

/* Контент модалки - ТОЛЬКО transform/opacity, без max-height */
.mobile-modal-content {
    position: absolute;
    bottom: 0;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 85vh;
    overflow-y: auto;
    background: linear-gradient(135deg, #1a0b2e 0%, #2d1b4e 100%);
    border-radius: 24px 24px 0 0;
    border: 1px solid rgba(139, 92, 246, 0.3);
    padding-bottom: env(safe-area-inset-bottom, 20px);
    box-shadow: 0 -8px 30px rgba(139, 92, 246, 0.2);
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.15s ease-out;
    will-change: transform, opacity;
    -webkit-transform: translateY(100%);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.mobile-create-modal.active .mobile-modal-content {
    transform: translateY(0);
    opacity: 1;
    -webkit-transform: translateY(0);
}

/* Шапка модалки - оптимизированная */
.mobile-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, rgba(26, 11, 46, 0.99) 0%, rgba(45, 27, 78, 0.99) 100%);
    z-index: 1;
    opacity: 1;
    /* Убрана анимация заголовка для производительности */
}

.mobile-create-modal.active .mobile-modal-header {
    opacity: 1;
}

.mobile-modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mobile-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: rgba(255, 255, 255, 0.7);
}

.mobile-modal-close:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.1);
}

/* Тело модалки */
.mobile-modal-body {
    padding: 12px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Разделитель - упрощённый */
.mobile-modal-divider {
    height: 1px;
    background: rgba(139, 92, 246, 0.3);
    margin: 0.5rem 0;
    opacity: 1;
}

/* Кнопки провайдеров - без анимации для производительности */
.mobile-provider-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 16px;
    text-decoration: none;
    color: white;
    min-height: 72px;
    position: relative;
    overflow: hidden;
    opacity: 1;
    transform: none;
}

/* Убраны staggered delays - все кнопки появляются сразу с модалкой */

.mobile-provider-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(236, 72, 153, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-provider-btn:active {
    transform: scale(0.98);
    border-color: rgba(139, 92, 246, 0.5);
}

.mobile-provider-btn:active::before {
    opacity: 1;
}

/* Иконка провайдера */
.mobile-provider-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(236, 72, 153, 0.2) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

/* Информация о провайдере */
.mobile-provider-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-provider-name {
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.mobile-provider-desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

/* Стрелка */
.mobile-provider-arrow {
    flex-shrink: 0;
    stroke: rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

.mobile-provider-btn:active .mobile-provider-arrow {
    stroke: rgba(255, 255, 255, 0.8);
    transform: translateX(4px);
}

/* ========================================
   SVG ГРАДИЕНТЫ
   ======================================== */

.mobile-nav-gradient-def {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* ========================================
   АДАПТАЦИЯ BODY ДЛЯ МОБИЛЬНОГО МЕНЮ
   ======================================== */

@media (max-width: 991.98px) {
    body:not(.auth-page):not(.login-page):not(.register-page) {
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0));
        overflow-x: hidden;
    }
    
    html {
        overflow-x: hidden;
    }
}

/* ========================================
   СКРЫТИЕ СТАНДАРТНОГО МОБИЛЬНОГО МЕНЮ
   ======================================== */

@media (max-width: 991.98px) {
    /* Скрываем все мобильные элементы из стандартного navbar */
    .navbar .d-lg-none {
        display: none !important;
    }
    
    /* Скрываем кнопку-гамбургер */
    .navbar-toggler {
        display: none !important;
    }
    
    /* Скрываем коллапс на мобильных */
    .navbar-collapse {
        display: none !important;
    }
    
    /* Показываем только лого на мобильных */
    .navbar-brand {
        margin: 0 auto;
    }
}

/* ========================================
   АНИМАЦИИ SWIPE
   ======================================== */

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(100%);
    }
}

/* ========================================
   ОПТИМИЗАЦИИ ДЛЯ WEBVIEW И СЛАБЫХ УСТРОЙСТВ
   ======================================== */

/* Плавная прокрутка внутри модалки */
.mobile-modal-content {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Отключаем анимации для пользователей с настройкой уменьшения движения */
@media (prefers-reduced-motion: reduce) {
    .mobile-modal-content,
    .mobile-modal-overlay {
        transition: none !important;
    }
    
    .mobile-nav-create-inner::before {
        display: none;
    }
}
