/* ========== МОДАЛЬНОЕ ОКНО ПОКУПКИ КРИСТАЛЛИКОВ GEM ========== */

.modal-gem {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalFadeIn 0.3s ease;
}

.modal-gem.active {
    display: flex;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-gem-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.modal-gem-container {
    position: relative;
    width: 100%;
    max-width: 500px; /* Уменьшили ширину */
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 2;
    animation: modalSlideIn 0.3s ease;
    border: 1px solid var(--border-light);
    overflow: hidden;
    max-height: 85vh; /* Ограничиваем высоту */
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-gem-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--light-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    z-index: 3;
}

.modal-gem-close:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.modal-gem-content {
    padding: 40px;
    text-align: center;
    overflow-y: auto; /* Включаем скролл */
    flex: 1;
}

.modal-gem-content::-webkit-scrollbar {
    width: 6px;
}

.modal-gem-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-gem-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

.modal-gem-icon {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 28px;
    color: var(--white);
}

.modal-gem-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px; /* Уменьшили отступ */
    font-family: 'Playfair Display', serif;
}

.modal-gem-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 25px; /* Уменьшили отступ */
}

/* Выбор количества GEM - КОМПАКТНЕЕ */
.modal-gem-amounts {
    margin-bottom: 25px;
}

.modal-gem-amounts-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-align: left;
}

.modal-gem-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); /* Уменьшили минимальную ширину */
    gap: 10px;
    margin-bottom: 0;
}

.modal-gem-option {
    background: var(--light-bg);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 16px 10px; /* Уменьшили отступы */
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    position: relative;
    min-height: 85px; /* Уменьшили высоту */
}

.modal-gem-option:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.modal-gem-option.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.modal-gem-option.selected .modal-gem-option-amount,
.modal-gem-option.selected .modal-gem-option-price {
    color: var(--white);
}

.modal-gem-option-amount {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.modal-gem-option-gem {
    color: #FFD700;
    font-size: 16px;
    transition: color 0.3s ease;
}

.modal-gem-option.selected .modal-gem-option-gem {
    color: var(--white);
}

.modal-gem-option-price {
    font-size: 13px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

/* Лучшее предложение - ПРАВИЛЬНОЕ ПОЛОЖЕНИЕ */
.modal-gem-best {
    position: absolute;
    top: 2px;
    right: 8px;
    background: var(--accent);
    color: var(--white);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 3px;
    line-height: 1;
}

/* Стоимость покупки - КОМПАКТНЕЕ */
.modal-gem-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--light-bg);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 25px;
    border: 1px solid var(--border-light);
}

.modal-gem-total-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-gem-total-amount {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

/* Выбор способа оплаты - КОМПАКТНЕЕ */
.modal-gem-methods {
    margin-bottom: 25px;
}

.modal-gem-methods-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-align: left;
}

.modal-gem-methods-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 10px;
}

.modal-gem-method {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px; /* Уменьшили отступы */
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--light-bg);
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
    overflow: visible;
}

.modal-gem-method:hover {
    border-color: var(--primary-light);
    background: var(--card-hover);
}

.modal-gem-method.selected {
    border-color: var(--primary);
    background: var(--primary);
}

.modal-gem-method.selected .modal-gem-method-name,
.modal-gem-method.selected .modal-gem-method-description {
    color: var(--white);
}

.modal-gem-method.unavailable {
    cursor: not-allowed;
    opacity: 0.6;
}

.modal-gem-method.unavailable:hover {
    border-color: var(--border-light);
    background: var(--light-bg);
    transform: none;
}

.modal-gem-unavailable-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--warning);
    color: var(--white);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
    z-index: 1;
    white-space: nowrap;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.modal-gem-unavailable-badge i {
    font-size: 8px;
}

.modal-gem-method-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 16px;
    flex-shrink: 0;
    border: 1px solid var(--border-light);
}

.modal-gem-method.unavailable .modal-gem-method-icon {
    background: var(--light-bg);
    color: var(--text-tertiary);
    border-color: var(--border);
}

.modal-gem-method.selected .modal-gem-method-icon {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.5);
}

.modal-gem-method-info {
    flex: 1;
    min-width: 0;
}

.modal-gem-method-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    transition: color 0.3s ease;
}

.modal-gem-method.unavailable .modal-gem-method-name {
    color: var(--text-tertiary);
}

.modal-gem-method-description {
    font-size: 12px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.modal-gem-method.unavailable .modal-gem-method-description {
    color: var(--text-tertiary);
}

.modal-gem-method-check {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.modal-gem-method.selected .modal-gem-method-check {
    background: var(--white);
    border-color: var(--white);
    color: var(--primary);
}

.modal-gem-method.unavailable .modal-gem-method-check {
    background: var(--light-bg);
    border-color: var(--border);
    color: var(--text-tertiary);
}

/* Соглашение - КОМПАКТНЕЕ */
.modal-gem-agreement {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.modal-gem-agreement-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
}

.modal-gem-agreement-checkbox input {
    display: none;
}

.modal-gem-agreement-checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
    transition: var(--transition-fast);
}

.modal-gem-agreement-checkbox input:checked + .modal-gem-agreement-checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.modal-gem-agreement-checkbox input:checked + .modal-gem-agreement-checkmark::after {
    content: '✓';
    color: var(--white);
    font-size: 10px;
    font-weight: bold;
}

.modal-gem-agreement-text {
    color: var(--text-primary);
    line-height: 1.4;
}

.modal-gem-agreement-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.modal-gem-agreement-link:hover {
    text-decoration: underline;
}

/* Кнопка покупки */
.modal-gem-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--white);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.modal-gem-btn:hover {
    background: var(--primary-dark);
}

.modal-gem-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Адаптивность */
@media (max-width: 768px) {
    .modal-gem-container {
        max-width: 90%;
    }

    .modal-gem-content {
        padding: 32px 24px;
    }

    .modal-gem-title {
        font-size: 22px;
    }

    .modal-gem-grid {
        grid-template-columns: repeat(2, 1fr); /* На мобильных 2 колонки */
    }
}

@media (max-width: 480px) {
    .modal-gem {
        padding: 10px;
    }

    .modal-gem-container {
        max-width: 100%;
        max-height: 90vh;
    }

    .modal-gem-content {
        padding: 28px 20px;
    }

    .modal-gem-title {
        font-size: 20px;
    }

    .modal-gem-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .modal-gem-option {
        padding: 14px 8px;
        min-height: 80px;
    }

    .modal-gem-option-amount {
        font-size: 16px;
    }

    .modal-gem-total {
        padding: 14px 16px;
    }

    .modal-gem-total-label {
        font-size: 14px;
    }

    .modal-gem-total-amount {
        font-size: 18px;
    }
}

/* Для темной темы - ИСПРАВЛЕН ЦВЕТ ВЫБРАННОГО ПУНКТА */
.dark-theme .modal-gem-overlay {
    background: rgba(0, 0, 0, 0.7);
}

.dark-theme .modal-gem-option {
    background: var(--card-hover);
    border-color: var(--border);
}

.dark-theme .modal-gem-option:hover {
    border-color: var(--primary);
}

.dark-theme .modal-gem-option.selected {
    border-color: var(--primary);
    background: var(--primary);
}

.dark-theme .modal-gem-total {
    background: var(--card-hover);
    border-color: var(--border);
}

.dark-theme .modal-gem-method {
    background: var(--card-hover);
    border-color: var(--border);
}

.dark-theme .modal-gem-method.selected {
    border-color: var(--primary);
    background: var(--primary);
}

.dark-theme .modal-gem-agreement-checkmark {
    background: var(--card-bg);
    border-color: var(--border);
}