/* Стили для страниц авторизации в стиле калькулятора */

/* Базовые стили */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Разрешаем выделение для полей ввода и редактируемых элементов */
input,
textarea,
select,
[contenteditable="true"],
[contenteditable="true"] * {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    font-family: "Unbounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    font-weight: 400;
    min-height: 100vh;
    /* Фон вынесен в common.css */
    color: #333;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

/* Контейнер */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Заголовок */
.header {
    text-align: center;
    padding: 0 0 40px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    width: 100%;
    z-index: 1;
}

.logo {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    z-index: 10;
}

.header-title-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    font-size: 16px;
    padding: 14px 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-weight: 500;
    position: relative;
    z-index: 11;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.back-link i {
    display: inline-block;
    line-height: 1;
}

.back-link-text {
    display: inline;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateX(-5px);
}

.main-title {
    font-family: "Unbounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 48px;
    color: white;
    margin: 0;
    letter-spacing: 2px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.subtitle {
    color: rgba(255, 255, 255, 0.85);
    font-size: 16px;
    font-weight: 300;
    margin: 0;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Карточка формы */
.auth-card {
    background: white;
    border-radius: 30px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    position: relative;
    z-index: 1;
    color: #333;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Убеждаемся, что все элементы внутри карточки имеют темный цвет */
.auth-card * {
    color: inherit;
}

.auth-card input,
.auth-card select,
.auth-card textarea {
    color: #333;
}

/* Форма */
#login-form,
#register-form,
#password-reset-request-form,
#password-reset-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 0;
}

/* Для форм сброса пароля увеличиваем gap для лучшей читаемости */
#password-reset-request-form {
    gap: 24px;
}

#password-reset-form {
    gap: 20px;
}

/* Для форм с меньшим количеством полей уменьшаем gap */
#password-reset-request-form {
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

/* Улучшаем отступы для кнопки в form-group */
.form-group .btn-primary {
    margin-top: 0;
}

/* Улучшаем отступы для подсказок под полями */
.form-group .text-muted {
    margin-top: 6px;
}

.form-group label {
    font-weight: 500;
    color: #555;
    font-size: 13px;
}

.form-control {
    padding: 14px 18px;
    border: 2px solid #E0DDEB;
    border-radius: 15px;
    font-family: inherit;
    font-size: 14px;
    background: #FAFAFA;
    color: #333;
    transition: all 0.3s ease;
    outline: none;
    width: 100%;
}

.form-control:focus {
    border-color: #7231FF;
    background: white;
}

/* Подсветка полей при валидации - всегда видна */
.form-control.invalid {
    border-color: #D32F2F !important;
    background-color: #fff5f5;
}

.form-control.invalid:focus {
    border-color: #D32F2F !important;
    background-color: #fff5f5;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

/* Обертка для поля пароля с кнопкой показа */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper .form-control {
    padding-right: 50px;
}

.password-toggle {
    position: absolute;
    right: 15px;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    z-index: 1;
}

.password-toggle:hover {
    color: #7231FF;
}

.password-toggle:focus {
    outline: none;
    color: #7231FF;
}

/* Обертка для поля телефона с кодом страны */
.phone-input-wrapper {
    position: relative;
    display: flex;
    align-items: stretch;
}

.phone-country-code {
    padding: 14px 16px;
    border: 2px solid #E0DDEB;
    border-right: none;
    border-radius: 15px 0 0 15px;
    font-family: inherit;
    font-size: 14px;
    background: #FAFAFA;
    color: #333;
    transition: all 0.3s ease;
    outline: none;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    min-width: 80px;
}

.phone-country-code svg {
    display: inline-block;
    vertical-align: middle;
    width: 20px;
    height: 14px;
    flex-shrink: 0;
}

.phone-country-code:hover {
    background-color: white;
    border-color: #7231FF;
}

.phone-country-code:focus {
    background-color: white;
    border-color: #7231FF;
    box-shadow: 0 0 0 3px rgba(114, 49, 255, 0.1);
}

/* Стрелка убрана, так как теперь используется флаг страны */

.phone-input-wrapper .phone-input {
    border-left: none;
    border-radius: 0 15px 15px 0;
    flex: 1;
    color: #333;
}

/* Placeholder должен быть серым */
.phone-input-wrapper .phone-input::placeholder {
    color: rgba(136, 136, 136, 0.6);
    opacity: 1;
}

.phone-input-wrapper .phone-input:focus {
    border-left: 2px solid #7231FF;
}

.phone-input-wrapper:focus-within .phone-country-code {
    border-color: #7231FF;
    background-color: white;
}

/* Выпадающий список кодов стран */
.phone-country-dropdown {
    position: absolute; /* Будет изменено на fixed через JS */
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 2px solid #E0DDEB;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10010 !important; /* Выше всех select и других элементов */
    min-width: 100px;
    overflow: hidden;
}

/* Когда dropdown перемещен в body (position: fixed) */
body > .phone-country-dropdown {
    z-index: 10010 !important;
    position: fixed !important;
}

.phone-country-option {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.phone-country-option svg {
    display: inline-block;
    vertical-align: middle;
    width: 20px;
    height: 14px;
    flex-shrink: 0;
}

.phone-country-option:hover {
    background-color: #FAFAFA;
    color: #7231FF;
}

.phone-country-option:first-child {
    border-radius: 13px 13px 0 0;
}

.phone-country-option:last-child {
    border-radius: 0 0 13px 13px;
}

.form-control::placeholder {
    color: rgba(136, 136, 136, 0.4);
    opacity: 1;
}

.text-muted {
    color: #888;
    font-size: 12px;
    font-weight: 400;
    margin: 6px 0 0 0;
    line-height: 1.4;
    display: block;
}

.text-danger {
    color: #D32F2F;
}

/* Кнопка */
.btn-primary {
    background: linear-gradient(135deg, #FFE343 0%, #FFD600 100%);
    color: #333;
    border: none;
    padding: 18px 30px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(114, 49, 255, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Ссылки */
.auth-link {
    text-align: center;
    margin: 0;
    padding-top: 16px;
    color: #333;
    font-size: 14px;
}

.auth-link a {
    color: #7231FF;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.auth-link a:hover {
    color: #5a20e0;
    text-decoration: underline;
}

/* Стили для нескольких ссылок в auth-link */
.auth-link p {
    margin: 8px 0;
}

.auth-link p:first-child {
    margin-top: 0;
}

.auth-link p:last-child {
    margin-bottom: 0;
}

/* =============================================
   Единая система уведомлений
   ============================================= */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 12px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    animation: slideInNotification 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: fit-content;
    max-width: 400px;
    word-wrap: break-word;
}

/* Успешные операции */
.notification.success {
    background: #4CAF50;
}

/* Ошибки */
.notification.error {
    background: #F44336;
}

/* Предупреждения */
.notification.warning {
    background: #FFC107;
    color: #333;
}

@keyframes slideInNotification {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 12px;
        min-height: 100vh;
    }
    
    .header {
        padding: 10px 0 20px;
        gap: 0;
        width: 100%;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        position: relative;
        flex-wrap: nowrap;
    }
    
    .logo {
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        margin-bottom: 0;
        text-align: left;
        width: auto;
        display: flex;
        justify-content: flex-start;
        align-items: center;
    }
    
    .back-link {
        font-size: 0;
        padding: 0;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-shrink: 0;
        background: rgba(255, 255, 255, 0.25);
        backdrop-filter: blur(10px);
        transition: all 0.3s ease;
        position: relative;
        margin: 0;
    }
    
    .back-link i {
        font-size: 20px;
        color: white;
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 0;
    }
    
    .back-link-text {
        display: none;
    }
    
    .back-link:active {
        background: rgba(255, 255, 255, 0.35);
        transform: scale(0.95);
    }
    
    .header-title-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        flex-wrap: nowrap;
        flex-shrink: 0;
    }
    
    .main-title {
        margin: 0;
        font-size: 32px;
        letter-spacing: 1px;
        line-height: 1.2;
        white-space: nowrap;
    }
    
    .subtitle {
        font-size: 16px;
        line-height: 1.4;
        margin: 0;
        white-space: nowrap;
    }
    
    .auth-card {
        padding: 25px 20px;
        border-radius: 20px;
        gap: 18px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .form-group {
        gap: 6px;
    }
    
    .form-group label {
        font-size: 13px;
    }
    
    .form-control {
        padding: 14px 16px;
        font-size: 16px; /* Предотвращает зум на iOS */
        min-height: 44px;
        box-sizing: border-box;
    }
    
    .password-toggle {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
    }
    
    .phone-input-wrapper {
        width: 100%;
    }
    
    .phone-country-code {
        padding: 14px 10px;
        font-size: 14px;
        min-width: 60px;
        min-height: 44px;
        box-sizing: border-box;
    }
    
    .phone-country-dropdown {
        min-width: 80px;
        max-width: calc(100vw - 24px);
    }
    
    .phone-country-option {
        padding: 12px 14px;
        font-size: 14px;
        min-height: 44px;
        box-sizing: border-box;
    }
    
    .btn-primary {
        padding: 16px;
        font-size: 16px;
        min-height: 50px;
        box-sizing: border-box;
    }
    
    .auth-link {
        font-size: 13px;
        padding-top: 6px;
    }
    
    .text-muted {
        font-size: 11px;
    }
    
    /* Уведомления на мобильных - сверху по центру */
    .notification {
        top: 20px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        max-width: calc(100vw - 24px);
        width: auto;
        min-width: 280px;
    }
    
    @keyframes slideInNotification {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(-20px);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }
    }
}

/* Маленькие мобильные устройства */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .header {
        padding: 8px 0 16px;
        gap: 6px;
    }
    
    .back-link {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .back-link i {
        font-size: 18px;
    }
    
    .header-title-wrapper {
        gap: 6px;
    }
    
    .main-title {
        font-size: 28px;
        letter-spacing: 0.5px;
    }
    
    .subtitle {
        font-size: 15px;
    }
    
    .auth-card {
        padding: 20px 16px;
        border-radius: 18px;
        gap: 16px;
    }
    
    .form-group {
        gap: 5px;
    }
    
    .form-group label {
        font-size: 12px;
    }
    
    .form-control {
        padding: 12px 14px;
        font-size: 16px; /* Важно: 16px для предотвращения зума на iOS */
        min-height: 44px;
    }
    
    .phone-country-code {
        padding: 12px 8px;
        font-size: 13px;
        min-width: 55px;
    }
    
    .phone-country-dropdown {
        min-width: 70px;
        max-width: calc(100vw - 20px);
    }
    
    .phone-country-option {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .btn-primary {
        padding: 14px;
        font-size: 15px;
        min-height: 48px;
    }
    
    .auth-link {
        font-size: 12px;
    }
    
    .text-muted {
        font-size: 10px;
    }
    
    .notification {
        top: 16px;
        max-width: calc(100vw - 20px);
        min-width: 260px;
        padding: 12px 20px;
        font-size: 13px;
    }
}

/* Экстремально маленькие экраны */
@media (max-width: 400px) {
    .container {
        padding: 8px;
    }
    
    .header {
        padding: 6px 0 12px;
    }
    
    .back-link {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
    }
    
    .back-link i {
        font-size: 16px;
    }
    
    .header-title-wrapper {
        gap: 6px;
    }
    
    .main-title {
        font-size: 24px;
        letter-spacing: 0;
    }
    
    .subtitle {
        font-size: 14px;
    }
    
    .auth-card {
        padding: 16px 12px;
        border-radius: 16px;
        gap: 14px;
    }
    
    .form-group {
        gap: 4px;
    }
    
    .form-group label {
        font-size: 11px;
    }
    
    .form-control {
        padding: 12px;
        font-size: 16px; /* Важно: 16px для предотвращения зума на iOS */
        min-height: 44px;
    }
    
    .phone-country-code {
        padding: 12px 6px;
        font-size: 12px;
        min-width: 50px;
    }
    
    .phone-country-dropdown {
        min-width: 60px;
        max-width: calc(100vw - 16px);
    }
    
    .phone-country-option {
        padding: 10px;
        font-size: 12px;
    }
    
    .btn-primary {
        padding: 12px;
        font-size: 14px;
        min-height: 44px;
    }
    
    .auth-link {
        font-size: 11px;
    }
    
    .text-muted {
        font-size: 9px;
    }
    
    .notification {
        top: 12px;
        max-width: calc(100vw - 16px);
        min-width: 240px;
        padding: 10px 16px;
        font-size: 12px;
    }
}

