/* ===== AUTH MODAL STYLES ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    overflow: hidden;
}

.modal.active {
    display: flex;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: -1;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-2xl);
    animation: modalSlideIn 0.3s ease;
    /* Hide scrollbar but keep scrolling functionality */
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
    margin: auto;
}

@supports (-webkit-touch-callout: none) {
    /* iOS specific fix */
    .modal-content {
        margin: auto;
        max-height: calc(100vh - 40px);
    }
}

/* Hide scrollbar for Chrome, Safari and Opera */
.modal-content::-webkit-scrollbar {
    display: none;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: white;
    border: 1px solid var(--gray-200);
    color: var(--gray-600);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    z-index: 100;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: auto;
}

.modal-close:hover {
    background: var(--gray-50);
    color: var(--gray-900);
    border-color: var(--gray-300);
}

.modal-close:active {
    transform: scale(0.95);
}

.modal-close:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: var(--spacing-lg);
}

.auth-tab {
    flex: 1;
    padding: var(--spacing-md) var(--spacing-lg);
    background: none;
    border: none;
    color: var(--gray-600);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast);
}

.auth-tab:hover {
    color: var(--primary-600);
}

.auth-tab.active {
    color: var(--primary-600);
}

.auth-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-600);
}

/* Auth Forms */
.auth-form {
    display: none;
    overflow-y: visible; /* Убираем прокрутку внутри формы */
}

.auth-form.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.form-group {
    margin-bottom: var(--spacing-md);
}

/* Prevent autoscroll to input when focused in modal */
.modal input:focus,
.modal textarea:focus,
.modal select:focus {
    scroll-behavior: auto;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
    font-weight: 500;
    font-size: 0.875rem;
}

.input-with-icon {
    position: relative;
}

.input-with-icon i:first-child {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 1rem;
    z-index: 2;
}

.input-with-icon .password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: color var(--transition-fast);
    z-index: 2;
}

.input-with-icon .password-toggle:hover {
    color: var(--gray-600);
}

.input-with-icon input {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 2.75rem; /* Правильные отступы */
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    background: white;
    position: relative;
}

.input-with-icon input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
    background: white;
}

.input-with-icon input.error {
    border-color: var(--error);
}

.input-with-icon input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Form Options */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    font-size: 0.875rem;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--gray-600);
}

.checkbox input {
    width: 1rem;
    height: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-300);
    cursor: pointer;
}

.text-link {
    background: none;
    border: none;
    color: var(--primary-600);
    text-decoration: none;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0;
    transition: color var(--transition-fast);
}

.text-link:hover {
    color: var(--primary-700);
    text-decoration: underline;
}

/* Auth Switch */
.auth-switch {
    text-align: center;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--gray-200);
    color: var(--gray-600);
    font-size: 0.875rem;
}

.auth-switch button {
    margin-left: 0.5rem;
}

/* Demo Login */
.demo-login {
    margin-top: var(--spacing-xl);
    padding: var(--spacing-md);
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.demo-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: var(--spacing-sm);
    color: var(--gray-600);
    font-size: 0.875rem;
}

.demo-info i {
    color: var(--warning);
}

#demo-login-btn {
    width: 100%;
}

/* Error Messages */
.error-message {
    color: var(--error);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: none;
}

.error-message.active {
    display: block;
}

/* Success Message */
.success-message {
    background: var(--success);
    color: white;
    padding: var(--spacing-md);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-md);
    display: none;
}

.success-message.active {
    display: block;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Добавим отдельный класс для полей с паролем */
.password-field .input-with-icon input {
    padding-right: 3.5rem; /* Больше места для иконки глаза */
}

/* Prevent iOS zoom and form jumping */
input,
textarea,
select {
    font-size: 16px !important;
    line-height: 1.5;
    min-height: 44px;
}