/* ============================================
   Модальные окна авторизации - StormHosting UA
   ============================================ */

/* Основные модальные стили */
.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
}

.auth-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.auth-modal-content {
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 24px;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    padding: 40px;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-modal.show .auth-modal-content {
    transform: scale(1) translateY(0);
}

/* Кнопка закрытия */
.auth-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.auth-modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #495057;
    transform: rotate(90deg);
}

/* Заголовок модального окна */
.auth-modal-header {
    text-align: center;
    margin-bottom: 30px;
    padding-right: 40px;
}

.auth-modal-header h2 {
    color: #2d3748;
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-modal-header p {
    color: #718096;
    font-size: 16px;
    margin: 0;
}

/* Форма */
.auth-form {
    display: block;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-label i {
    color: #667eea;
    width: 16px;
}

/* Input Groups */
.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #6b7280;
    text-align: center;
    white-space: nowrap;
    background-color: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 12px 0 0 12px;
    border-right: none;
}

.input-group .form-control {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
    border-left: none;
    border-radius: 0;
}

/* Password toggle button */
.input-group .btn-outline-secondary {
    border-left: none;
    border-radius: 0 12px 12px 0;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    border-color: #d1d5db;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 3;
}

.input-group .btn-outline-secondary:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

.input-group .btn-outline-secondary:focus,
.input-group .btn-outline-secondary:active {
    box-shadow: none !important;
    outline: none !important;
    background: #e5e7eb;
    border-color: #6b7280;
}

/* Form Controls */
.form-control {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #374151;
    background-color: #ffffff;
    background-image: none;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    color: #374151;
    background-color: #ffffff;
    border-color: #667eea;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control::placeholder {
    color: #9ca3af;
    opacity: 1;
}

/* Validation States */
.form-control.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-control.is-valid {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #ef4444;
}

.invalid-feedback.show,
.form-control.is-invalid ~ .invalid-feedback {
    display: block;
}

.form-text {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #6b7280;
}

/* Checkbox */
.form-check {
    display: block;
    min-height: 1.5rem;
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.form-check-input {
    width: 1rem;
    height: 1rem;
    margin-top: 0.25rem;
    margin-left: -1.5rem;
    vertical-align: top;
    background-color: #ffffff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    transition: all 0.15s ease-in-out;
}

.form-check-input:checked {
    background-color: #667eea;
    border-color: #667eea;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}

.form-check-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-check-label {
    color: #374151;
    font-size: 0.95rem;
    cursor: pointer;
}

.form-check-label a {
    color: #667eea;
    text-decoration: none;
}

.form-check-label a:hover {
    text-decoration: underline;
}

/* Auth Button */
.btn-auth {
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    color: #ffffff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-auth:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

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

.btn-auth:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Loading Spinner */
.loading-spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Auth Switch */
.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.auth-switch p {
    margin: 0;
    color: #6b7280;
    font-size: 0.95rem;
}

.auth-switch a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Forgot Password */
.forgot-password {
    text-align: center;
    margin-top: 1rem;
}

.forgot-password a {
    color: #667eea;
    text-decoration: none;
    font-size: 0.95rem;
}

.forgot-password a:hover {
    text-decoration: underline;
}

/* Alert Styles */
.alert {
    position: relative;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 12px;
    display: flex;
    align-items: center;
}

.alert-success {
    color: #065f46;
    background-color: #d1fae5;
    border-color: #a7f3d0;
}

.alert-danger {
    color: #991b1b;
    background-color: #fee2e2;
    border-color: #fecaca;
}

.alert-dismissible .btn-close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    padding: 1.25rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
}

.alert-dismissible .btn-close:hover {
    opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .auth-modal-content {
        padding: 30px 20px;
        margin: 20px;
        max-width: calc(100% - 40px);
    }
    
    .auth-modal-header {
        padding-right: 30px;
    }
    
    .auth-modal-header h2 {
        font-size: 1.75rem;
    }
    
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .btn-auth {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .auth-modal-content {
        padding: 25px 15px;
        margin: 15px;
        max-width: calc(100% - 30px);
    }
    
    .input-group-text,
    .form-control,
    .btn-outline-secondary {
        padding: 0.625rem 0.75rem;
        font-size: 0.95rem;
    }
}

/* Улучшения для accessibility */
.form-control:focus,
.btn-auth:focus,
.form-check-input:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

/* Анимации появления */
.auth-modal {
    animation: fadeInBackdrop 0.3s ease;
}

.auth-modal.show .auth-modal-content {
    animation: slideInUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Дополнительные улучшения для лучшего UX */
.form-control:disabled,
.form-control[readonly] {
    background-color: #f9fafb;
    opacity: 1;
}

.input-group .form-control:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .form-control:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Стили для корректного отображения иконок */
.bi {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    fill: currentcolor;
}

/* Убираем outline по умолчанию */
button:focus {
    outline: none;
}

/* Исправления для кнопки показа пароля */
.input-group .btn-outline-secondary {
    position: relative;
    z-index: 2;
    min-width: 48px;
}

.input-group .btn-outline-secondary i {
    font-size: 1rem;
    line-height: 1;
}

/* Убираем стандартные стили кнопки в Firefox */
.input-group .btn-outline-secondary::-moz-focus-inner {
    border: 0;
    padding: 0;
}

/* Обеспечиваем корректное выравнивание */
.input-group > .form-control,
.input-group > .input-group-text,
.input-group > .btn {
    display: flex;
    align-items: center;
}

/* Исправляем z-index для корректного отображения границ */
.input-group > .form-control:focus {
    z-index: 3;
}

.input-group > .form-control:not(:first-child) {
    margin-left: -1px;
}

.input-group > .btn:not(:first-child) {
    margin-left: -1px;
}