/**
 * Модуль Auth: Современный SaaS стиль (Mobile App Look)
 * Путь: frontend/templates/auth/auth.css
 * Исправленная и финальная версия
 */

:root {
    /* Основная палитра */
    --ps-auth-primary: #4f46e5;
    --ps-auth-primary-hover: #4338ca;
    --ps-auth-bg: #f8fafc;
    --ps-auth-card-bg: #ffffff;
    --ps-auth-text: #0f172a;
    --ps-auth-muted: #64748b;
    --ps-auth-success: #10b981;
    --ps-auth-error: #ef4444;
    --ps-auth-input-bg: #f1f5f9;
    --ps-auth-border: rgba(226, 232, 240, 0.8);
    
    /* Тени */
    --ps-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --ps-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --ps-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Базовые стили корпуса */
.ps-auth-body {
    background: var(--ps-auth-bg); 
    min-height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Контейнер области авторизации */
.ps-auth-area {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    box-sizing: border-box;
    animation: ps-fade-up 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Основная карточка */
.ps-auth-card {
    background: var(--ps-auth-card-bg);
    padding: 40px 32px;
    border-radius: 32px;
    box-shadow: var(--ps-shadow-lg);
    border: 1px solid var(--ps-auth-border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Шапка с логотипом */
.ps-auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.ps-logo-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, #6366f1 0%, var(--ps-auth-primary) 100%);
    color: #fff;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 32px;
    box-shadow: 0 12px 20px -5px rgba(79, 70, 229, 0.4);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ps-logo-icon:hover {
    transform: rotate(5deg) scale(1.05);
}

.ps-auth-header h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--ps-auth-text);
    margin: 0;
    letter-spacing: -0.03em;
}

.ps-auth-header p {
    color: var(--ps-auth-muted);
    font-size: 15px;
    margin-top: 8px;
    font-weight: 500;
}

/* Поля ввода */
.ps-field { 
    margin-bottom: 24px; 
}

.ps-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
    margin-left: 4px;
}

.ps-input-group { 
    position: relative; 
}

.ps-input-group i {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 18px;
    transition: all 0.2s ease;
    pointer-events: none;
}

.ps-input-group input {
    width: 100%;
    padding: 18px 20px 18px 56px;
    background: var(--ps-auth-input-bg);
    border: 2px solid transparent;
    border-radius: 18px;
    font-size: 16px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--ps-auth-text);
    box-sizing: border-box;
    font-weight: 500;
}

.ps-input-group input:focus {
    background: #fff;
    border-color: var(--ps-auth-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    outline: none;
}

.ps-input-group input:focus + i {
    color: var(--ps-auth-primary);
    transform: translateY(-50%) scale(1.1);
}

/* Кнопка входа */
.ps-btn-login {
    width: 100%;
    padding: 18px;
    background: var(--ps-auth-primary);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 32px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.ps-btn-login:hover {
    background: var(--ps-auth-primary-hover);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.35);
    transform: translateY(-2px);
}

.ps-btn-login:active {
    transform: translateY(0) scale(0.98);
}

/* Состояние загрузки */
.ps-btn-login.is-loading {
    color: transparent !important;
    pointer-events: none;
}

.ps-btn-login.is-loading::after {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: ps-spin 0.8s linear infinite;
}

/* Сообщения и ошибки */
#ps-auth-message {
    margin-top: 24px;
    padding: 16px;
    border-radius: 18px;
    font-size: 14px;
    font-weight: 600;
    display: none;
    text-align: center;
}

#ps-auth-message.error {
    display: block;
    background: #fef2f2;
    color: var(--ps-auth-error);
    border: 1px solid #fee2e2;
    animation: ps-shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

#ps-auth-message.success {
    display: block;
    background: #f0fdf4;
    color: var(--ps-auth-success);
    border: 1px solid #dcfce7;
}

#ps-auth-message i {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
}

/* Класс для тряски полей при ошибке */
.ps-field-error {
    animation: ps-shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}
.ps-field-error input {
    border-color: var(--ps-auth-error) !important;
    background: #fff;
}

/* Анимации */
@keyframes ps-spin {
    to { transform: rotate(360deg); }
}

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

@keyframes ps-shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Футер */
.ps-auth-footer {
    text-align: center;
    margin-top: 32px;
    font-size: 14px;
    color: var(--ps-auth-muted);
    font-weight: 500;
}

/* Адаптивность */
@media (max-width: 380px) {
    .ps-auth-card {
        padding: 32px 20px;
    }
    .ps-auth-header h1 {
        font-size: 24px;
    }
}