/* AUTH MODALS STYLES */

.modal {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    display: none; /* Скрыто по умолчанию */
}

.modal.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fefefe;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    /* Плавный скролл на iOS */
    -webkit-overflow-scrolling: touch;
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

.modal-content h2 {
    margin-top: 0;
    color: #333;
}

.stats-block, .benefits-block, .subscription-offer {
    margin: 20px 0;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 8px;
}

.attempts-info {
    margin: 10px 0;
}

.attempt-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #ddd;
}

.benefits-list, .benefits-block ul {
    list-style: none;
    padding: 0;
}

.benefits-list li, .benefits-block li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn-secondary {
    background: #999;
    color: white;
}

.btn-secondary:hover {
    background: #777;
}

.method-selection {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.method-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
}

.method-btn.active {
    border-color: #667eea;
    background: #e8eeff;
}


.registration-form label, .login-form label {
    display: block;
    margin-top: 15px;
    margin-bottom: 5px;
    font-weight: 500;
}

.registration-form input, .login-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    /* Минимум 16px — иначе iOS делает авто-зум при фокусе */
    font-size: 16px;
    /* Чтобы padding не ломал width: 100% */
    box-sizing: border-box;
}

.code-input {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.code-digit {
    width: 50px !important;
    height: 50px;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    border: 2px solid #ddd;
    border-radius: 8px;
}

.code-digit:focus {
    border-color: #667eea;
    outline: none;
}

.consent-block {
    margin: 15px 0;
}

.consent-block label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.error-message {
    color: #f44336;
    padding: 10px;
    background: #ffebee;
    border-radius: 4px;
    margin-top: 10px;
}

.login-links {
    display: flex;
    justify-content: space-between;
    margin: 15px 0;
    font-size: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.login-links a {
    color: #667eea;
    text-decoration: none;
}

.login-links a:hover {
    text-decoration: underline;
}

.divider {
    text-align: center;
    margin: 20px 0;
    color: #999;
}

.session-info {
    background: #fff3cd;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.warning {
    color: #856404;
    background: #fff3cd;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
}

.global-attempts-info {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.global-attempts-info ul {
    margin: 10px 0;
    padding-left: 20px;
}

.hint {
    font-size: 14px;
    color: #666;
    text-align: center;
}

/* ===== МОБИЛЬНЫЕ УСТРОЙСТВА ===== */
@media (max-width: 480px) {
    .modal-content {
        /* На мобиле — занимаем больше экрана */
        width: 95%;
        padding: 20px 16px;
        /* Когда открывается клавиатура, modal не уходит за экран */
        max-height: 85vh;
        margin-bottom: env(safe-area-inset-bottom);
    }

    /* Кнопки в столбик на маленьком экране */
    .modal-buttons {
        flex-direction: column;
    }

    /* Кнопки авторизации на всю ширину */
    .btn-primary, .btn-secondary {
        width: 100%;
        /* Увеличиваем тач-зону */
        padding: 14px;
        font-size: 16px;
    }

    /* Выбор метода (телефон/email) в столбик если не влезает */
    .method-selection {
        flex-direction: column;
    }

    /* Цифровые поля кода — чуть меньше чтобы влезли на экран */
    .code-digit {
        width: 40px !important;
        height: 44px;
        font-size: 20px;
    }

    /* Заголовок модалки поменьше */
    .modal-content h2 {
        font-size: 20px;
    }

    /* Ссылки "забыли пароль" и "не помню логин" — каждая на своей строке */
    .login-links {
        flex-direction: column;
        gap: 10px;
    }
}