/* ===== WELCOME POPUP СТИЛИ (ИСПРАВЛЕННЫЕ) ===== */

/* Определяем CSS переменную --vh для мобильных устройств */
:root {
    --vh: 1vh;
}

/* Основной контейнер - ИЗНАЧАЛЬНО СКРЫТ */
#welcomeInfoPopup {
    position: fixed;
    inset: 0;
    display: none; /* ← ИСПРАВЛЕНО: изначально полностью скрыт */
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    height: 100vh; /* Fallback */
    height: calc(var(--vh, 1vh) * 100); /* Для iOS */
}

/* Класс для показа popup */
#welcomeInfoPopup.show {
    display: flex !important; /* ← При показе включаем flex */
    opacity: 1;
}

/* Фон (backdrop) */
.welcome-popup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

/* Основной контейнер popup */
.welcome-popup-container {
    position: relative;
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 16px;
    max-width: 380px;
    width: 100%;
    max-height: 90vh;
    max-height: calc(var(--vh, 1vh) * 90); /* Для iOS */
    overflow-y: auto;
    box-shadow:
            0 20px 40px rgba(0, 0, 0, 0.4),
            0 0 0 1px rgba(139, 92, 246, 0.1);
    transform: scale(0.9) translateY(30px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#welcomeInfoPopup.show .welcome-popup-container {
    transform: scale(1) translateY(0);
}

/* Кнопка закрытия */
.welcome-popup-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.welcome-popup-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Заголовок */
.welcome-popup-header {
    padding: 24px 20px 16px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
}

.welcome-popup-logo {
    width: 50px;
    height: 50px;
    margin: 0 auto 12px;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.welcome-popup-logo svg {
    width: 24px;
    height: 24px;
}

.welcome-popup-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 6px 0;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-popup-desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

/* Контент */
.welcome-popup-body {
    padding: 18px 20px;
}

.welcome-popup-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}

.welcome-feature-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.1);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.welcome-feature-item:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.2);
}

.welcome-feature-emoji {
    font-size: 16px;
    line-height: 1;
    margin-top: 1px;
    flex-shrink: 0;
}

.welcome-feature-info {
    flex: 1;
    font-size: 13px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
}

.welcome-feature-info strong {
    color: #8b5cf6;
    font-weight: 600;
}

/* Уведомление */
.welcome-popup-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    margin-bottom: 18px;
}

.welcome-notice-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.welcome-notice-text {
    flex: 1;
    font-size: 12px;
    line-height: 1.3;
    color: rgba(255, 255, 255, 0.9);
}

.welcome-notice-warning {
    color: #f59e0b;
    font-weight: 600;
}

/* Футер */
.welcome-popup-footer {
    padding: 0 20px 20px 20px;
}

.welcome-popup-action-btn {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.welcome-popup-action-btn:before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #a855f7 0%, #2563eb 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.welcome-popup-action-btn:hover:before {
    opacity: 1;
}

.welcome-popup-action-btn span,
.welcome-popup-action-btn svg {
    position: relative;
    z-index: 1;
}

.welcome-popup-action-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
}

.welcome-popup-action-btn:hover svg {
    transform: translateX(4px);
}

/* Блокировка скролла при открытом popup */
body.popup-open {
    overflow: hidden;
}

/* Мобильные устройства */
body.mobile-device {
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Адаптивность */
@media (max-width: 768px) {
    #welcomeInfoPopup {
        padding: 12px;
    }

    .welcome-popup-container {
        margin: 0;
        max-width: none;
        width: calc(100vw - 24px);
        max-height: 85vh;
        max-height: calc(var(--vh, 1vh) * 85);
        border-radius: 12px;
    }

    .welcome-popup-header {
        padding: 20px 16px 12px 16px;
    }

    .welcome-popup-body {
        padding: 14px 16px;
    }

    .welcome-popup-footer {
        padding: 0 16px 16px 16px;
    }

    .welcome-popup-title {
        font-size: 18px;
    }

    .welcome-popup-logo {
        width: 45px;
        height: 45px;
        margin-bottom: 10px;
    }

    .welcome-popup-logo svg {
        width: 22px;
        height: 22px;
    }

    .welcome-feature-item {
        padding: 10px;
        gap: 8px;
    }

    .welcome-feature-info {
        font-size: 12px;
    }

    .welcome-feature-emoji {
        font-size: 14px;
    }

    .welcome-popup-notice {
        padding: 10px;
        gap: 8px;
    }

    .welcome-notice-text {
        font-size: 11px;
    }

    .welcome-popup-action-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    #welcomeInfoPopup {
        padding: 8px;
    }

    .welcome-popup-container {
        width: calc(100vw - 16px);
        max-height: 80vh;
        max-height: calc(var(--vh, 1vh) * 80);
    }

    .welcome-popup-header {
        padding: 16px 12px 10px 12px;
    }

    .welcome-popup-body {
        padding: 12px;
    }

    .welcome-popup-footer {
        padding: 0 12px 12px 12px;
    }

    .welcome-popup-features {
        gap: 8px;
        margin-bottom: 12px;
    }

    .welcome-popup-notice {
        margin-bottom: 12px;
    }

    .welcome-popup-close-btn {
        top: 12px;
        right: 12px;
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

@media (max-width: 360px) {
    .welcome-popup-container {
        width: calc(100vw - 12px);
        max-height: 75vh;
        max-height: calc(var(--vh, 1vh) * 75);
    }

    .welcome-popup-title {
        font-size: 16px;
    }

    .welcome-popup-logo {
        width: 40px;
        height: 40px;
    }

    .welcome-popup-logo svg {
        width: 20px;
        height: 20px;
    }
}

/* Ландшафтная ориентация на мобильных */
@media (max-height: 500px) and (orientation: landscape) {
    .welcome-popup-container {
        max-height: 90vh;
        max-height: calc(var(--vh, 1vh) * 90);
    }

    .welcome-popup-header {
        padding: 12px 16px 8px 16px;
    }

    .welcome-popup-body {
        padding: 10px 16px;
    }

    .welcome-popup-footer {
        padding: 0 16px 12px 16px;
    }

    .welcome-popup-features {
        gap: 6px;
        margin-bottom: 10px;
    }

    .welcome-popup-notice {
        margin-bottom: 10px;
    }

    .welcome-feature-item {
        padding: 8px;
    }
}

/* ДОПОЛНИТЕЛЬНЫЕ МОБИЛЬНЫЕ ИСПРАВЛЕНИЯ ДЛЯ КАЛЬКУЛЯТОРА */

/* Определяем переменные для spacing если их нет */
:root {
    --vh: 1vh;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-12: 48px;
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 18px;
}

/* Исправления для очень маленьких экранов */
@media (max-width: 480px) {
    /* Дополнительные компактные стили для balance-input */
    .balance-input.compact {
        width: 100% !important;
        max-width: 240px !important;
        height: 48px !important;
        font-size: var(--text-sm) !important;
    }

    /* Компактнее slider wrapper */
    .balance-slider-wrapper.compact {
        margin-bottom: var(--space-3) !important;
        max-width: 260px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* Уменьшаем labels */
    .slider-labels .slider-label {
        font-size: 10px !important;
    }

    /* Tier grid в одну колонку */
    .tier-grid.compact {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: var(--space-2) !important;
    }

    /* Earnings grid в 2 колонки */
    .earnings-grid.compact {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--space-2) !important;
    }

    /* Более компактные earning cards */
    .earning-card.compact {
        padding: var(--space-2) !important;
    }

    .earning-card.compact .earning-value {
        font-size: var(--text-base) !important;
    }

    .earning-card.compact .earning-label {
        font-size: 9px !important;
    }

    .earning-card.compact .earning-period {
        font-size: 8px !important;
    }
}

/* Исправления для экстра маленьких экранов */
@media (max-width: 360px) {
    .calculator-wrapper.compact {
        padding: var(--space-3) !important;
        margin: var(--space-2) 0 !important;
    }

    .calculator-main.compact {
        gap: var(--space-3) !important;
        margin-bottom: var(--space-3) !important;
    }

    .balance-input.compact {
        max-width: 200px !important;
        height: 44px !important;
    }

    .balance-slider-wrapper.compact {
        max-width: 220px !important;
    }

    .slider-labels .slider-label {
        font-size: 8px !important;
    }

    /* Earnings в одну колонку на очень маленьких экранах */
    .earnings-grid.compact {
        grid-template-columns: 1fr !important;
    }

    .earning-card.compact .earning-value {
        font-size: var(--text-sm) !important;
    }

    .earning-card.compact .earning-label {
        font-size: 8px !important;
    }

    .earning-card.compact .earning-period {
        font-size: 7px !important;
    }
}

/* Landscape ориентация на мобильных */
@media (max-width: 767px) and (orientation: landscape) {
    .calculator-section.compact {
        padding: var(--space-6) 0 !important;
    }

    .calculator-main.compact {
        grid-template-columns: 1fr 1fr !important;
        gap: var(--space-4) !important;
    }

    .earnings-grid.compact {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: var(--space-1) !important;
    }

    .earning-card.compact {
        padding: var(--space-1) !important;
    }

    .earning-card.compact .earning-label {
        font-size: 8px !important;
    }

    .earning-card.compact .earning-value {
        font-size: var(--text-xs) !important;
    }

    .earning-card.compact .earning-period {
        font-size: 7px !important;
    }
}

/* Исправления для коротких экранов (высота) */
@media (max-height: 600px) {
    .calculator-section.compact {
        padding: var(--space-4) 0 var(--space-6) 0 !important;
    }

    .section-header.compact {
        margin-bottom: var(--space-4) !important;
    }

    .calculator-wrapper.compact {
        margin: var(--space-2) 0 !important;
    }
}

/* Для очень коротких экранов */
@media (max-height: 500px) {
    .calculator-section.compact {
        padding: var(--space-3) 0 var(--space-4) 0 !important;
    }

    .section-header.compact {
        margin-bottom: var(--space-3) !important;
    }

    .section-title.compact {
        font-size: var(--text-lg) !important;
        margin-bottom: var(--space-2) !important;
    }

    .calculator-wrapper.compact {
        padding: var(--space-2) !important;
        margin: var(--space-1) 0 !important;
    }

    .calculator-main.compact {
        gap: var(--space-2) !important;
        margin-bottom: var(--space-2) !important;
    }

    .wallet-balance-section.compact {
        margin-bottom: var(--space-3) !important;
    }

    .balance-input-wrapper.compact {
        margin-bottom: var(--space-2) !important;
    }

    .balance-slider-wrapper.compact {
        margin-bottom: var(--space-2) !important;
    }

    .tier-selection.compact {
        margin-bottom: var(--space-3) !important;
    }

    .calculator-results.compact {
        padding-top: var(--space-2) !important;
    }

    .earnings-grid.compact {
        margin-bottom: var(--space-2) !important;
        gap: var(--space-1) !important;
    }
}

/* Специальные исправления для iPhone SE и подобных (375×667) */
@media (max-width: 375px) and (max-height: 667px) {
    .earnings-grid.compact {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 3px !important;
    }

    .earning-card.compact {
        padding: 6px !important;
    }

    .earning-card.compact .earning-label {
        font-size: 7px !important;
        margin-bottom: 2px !important;
    }

    .earning-card.compact .earning-value {
        font-size: 11px !important;
        margin-bottom: 2px !important;
    }

    .earning-card.compact .earning-period {
        font-size: 6px !important;
    }
}

/* Исправления для предотвращения обрезания снизу */
.calculator-section {
    overflow: visible !important;
}

.calculator-wrapper {
    overflow: visible !important;
}

.calculator-results {
    overflow: visible !important;
}

.earnings-grid {
    overflow: visible !important;
}

/* Дополнительные отступы снизу для предотвращения перекрытия с Active Users */
@media (max-width: 767px) {
    .calculator-section .container {
        padding-bottom: var(--space-12) !important;
    }
}

/* Исправления для Active Users panel перекрытия */
@media (max-width: 767px) {
    .active-users-section {
        bottom: var(--space-4) !important;
        left: var(--space-4) !important;
        right: var(--space-4) !important;
        z-index: 100 !important;
    }

    .active-users-button {
        width: 100% !important;
        padding: var(--space-2) var(--space-3) !important;
        font-size: var(--text-xs) !important;
    }

    .users-info {
        font-size: var(--text-xs) !important;
    }

    .users-count {
        font-size: var(--text-xs) !important;
    }
}

/* Ultra-compact класс для экстремально маленьких экранов */
.calculator-section.ultra-compact {
    padding: 8px 0 20px 0 !important;
}

.calculator-section.ultra-compact .section-header.compact {
    margin-bottom: 8px !important;
}

.calculator-section.ultra-compact .section-title.compact {
    font-size: 14px !important;
    line-height: 1.2 !important;
    margin-bottom: 4px !important;
}

.calculator-section.ultra-compact .calculator-wrapper.compact {
    padding: 8px !important;
    margin: 4px 0 !important;
}

.calculator-section.ultra-compact .calculator-main.compact {
    gap: 6px !important;
    margin-bottom: 6px !important;
}

.calculator-section.ultra-compact .earning-card.compact {
    padding: 4px !important;
}

.calculator-section.ultra-compact .earning-card.compact .earning-label {
    font-size: 6px !important;
    margin-bottom: 1px !important;
}

.calculator-section.ultra-compact .earning-card.compact .earning-value {
    font-size: 9px !important;
    margin-bottom: 1px !important;
}

.calculator-section.ultra-compact .earning-card.compact .earning-period {
    font-size: 5px !important;
}

.calculator-section.ultra-compact .tier-card.compact {
    padding: 6px !important;
}

.calculator-section.ultra-compact .tier-card.compact .tier-name {
    font-size: 9px !important;
}

.calculator-section.ultra-compact .tier-card.compact .tier-rate {
    font-size: 9px !important;
}

.calculator-section.ultra-compact .tier-card.compact .tier-requirement {
    font-size: 7px !important;
}

/* Исправления для input focus на мобильных */
@media (max-width: 767px) {
    .balance-input:focus {
        font-size: 16px !important; /* Предотвращает зум в Safari */
        transform: scale(1) !important;
    }
}

/* Обеспечиваем что все элементы видны */
.calculator-section *,
.calculator-wrapper *,
.calculator-main *,
.calculator-results * {
    overflow: visible !important;
}

/* Исправления для скролла */
@media (max-width: 767px) {
    body.calculator-focus {
        overflow: hidden;
    }

    .calculator-section.in-focus {
        position: relative;
        z-index: 10;
    }
}

/* JavaScript для установки --vh переменной */
/* Добавь этот JavaScript код в конец файла или в отдельный скрипт:

// Устанавливаем правильную --vh переменную для мобильных устройств
function setVH() {
    const vh = window.innerHeight * 0.01;
    document.documentElement.style.setProperty('--vh', `${vh}px`);
}

// Устанавливаем при загрузке
setVH();

// Обновляем при изменении размера экрана
window.addEventListener('resize', setVH);
window.addEventListener('orientationchange', setVH);

*/