/* --- 1. ПЕРЕМЕННЫЕ И СБРОС --- */
:root {
    --slate-50: #f8fafc;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-700: #334155;
    --slate-900: #0f172a;
    --white: #ffffff;
    
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --primary-shadow: rgba(14, 165, 233, 0.3);
    --error: #ef4444;

    --radius-xl: 0.75rem;
    --radius-3xl: 1.5rem;

    --font-stack: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-stack);
    background-color: var(--slate-50);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    color: var(--slate-900);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- 2. КНОПКА "НА ГЛАВНУЮ" --- */
.back-link {
    position: absolute;
    top: 1rem; left: 1rem;
    display: flex; align-items: center; gap: 0.5rem;
    color: var(--slate-500); text-decoration: none;
    font-weight: 600; font-size: 0.875rem;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    padding: 0.5rem 0.75rem; border-radius: 0.5rem;
    z-index: 50; transition: color 0.2s;
}
.back-link:hover { color: var(--primary); }
@media (min-width: 640px) { .back-link { top: 2rem; left: 2rem; } }

/* --- 3. ОСНОВНОЙ КОНТЕЙНЕР --- */
.auth-card {
    background: var(--white);
    width: 100%; max-width: 64rem;
    height: 85vh;
    border-radius: var(--radius-3xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex; position: relative;
}
@media (min-width: 640px) { .auth-card { height: auto; min-height: 600px; } }

/* --- 4. ЛЕВАЯ ЧАСТЬ --- */
.hero-section {
    display: none; width: 50%;
    position: relative; background-color: var(--slate-900);
}
@media (min-width: 768px) { .hero-section { display: block; } }

.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.8; }
.hero-gradient { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.9), rgba(0,0,0,0.4), transparent); }
.hero-content { position: absolute; bottom: 0; left: 0; padding: 3rem; color: var(--white); z-index: 10; }
.logo-badge { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.logo-icon { width: 2.5rem; height: 2.5rem; background-color: var(--primary); border-radius: 0.75rem; display: flex; align-items: center; justify-content: center; color: white; }
.logo-text { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; }
.hero-title { font-size: 2.25rem; font-weight: 700; line-height: 1.1; margin-bottom: 1rem; letter-spacing: -0.025em; }
.hero-desc { color: var(--slate-300); font-size: 1.125rem; line-height: 1.5; }

/* --- 5. ПРАВАЯ ЧАСТЬ --- */
.form-section {
    width: 100%; padding: 2rem;
    display: flex; flex-direction: column; justify-content: center;
    overflow-y: auto;
}
@media (min-width: 640px) { .form-section { padding: 3rem; } }
@media (min-width: 768px) { .form-section { width: 50%; } }
@media (min-width: 1024px) { .form-section { padding: 4rem; } }

.header-text { text-align: center; margin-bottom: 2rem; }
.header-text h1 { font-size: 1.875rem; font-weight: 800; color: var(--slate-900); margin-bottom: 0.5rem; letter-spacing: -0.025em; }
.header-text p { color: var(--slate-500); }

.social-grid { display: flex; justify-content:space-between; gap: 0.75rem; margin-bottom: 2rem; }
.social-btn {
    display: flex; align-items: center; justify-content: center;
    padding: 0.75rem; border: 1px solid var(--slate-200);
    border-radius: var(--radius-xl); background: transparent; cursor: pointer; transition: all 0.2s;
}
.social-btn:hover { background-color: var(--slate-50); border-color: var(--slate-300); transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }

.divider { display: flex; align-items: center; margin-bottom: 1.5rem; padding: 0.5rem 0; }
.divider-line { flex-grow: 1; height: 1px; background-color: var(--slate-200); }
.divider-text { margin: 0 1rem; color: var(--slate-400); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

.form-wrapper { display: flex; flex-direction: column; gap: 1rem; }
.input-group label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--slate-700); margin-bottom: 0.35rem; }
.input-field {
    width: 100%; background-color: var(--slate-50); border: 1px solid var(--slate-200);
    border-radius: var(--radius-xl); padding: 0.75rem 1rem; font-size: 1rem; font-weight: 400; 
    color: var(--slate-900); font-family: inherit; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.input-field:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background-color: var(--white); }

.input-field.error { border-color: var(--error); background-color: #fef2f2; }
.input-field.error:focus { box-shadow: 0 0 0 1px var(--error); }
.error-message { display: none; color: var(--error); font-size: 0.75rem; margin-top: 0.25rem; font-weight: 500; }
.input-group.has-error .error-message { display: block; }

.label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.35rem; }
.link-primary { color: var(--primary); font-size: 0.875rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.link-primary:hover { color: var(--primary-hover); }

.btn-submit {
    width: 100%; background-color: var(--primary); color: white; font-weight: 700;
    padding: 1rem; border: none; border-radius: var(--radius-xl); cursor: pointer;
    font-size: 1rem; font-family: inherit; box-shadow: 0 10px 15px -3px var(--primary-shadow);
    transition: background-color 0.2s, transform 0.1s; margin-top: 0.5rem;
}
.btn-submit:hover { background-color: var(--primary-hover); }
.btn-submit:active { transform: scale(0.98); }

.switch-text { text-align: center; font-size: 0.875rem; color: var(--slate-500); margin-top: 1rem; }
.switch-btn { background: none; border: none; color: var(--primary); font-weight: 700; cursor: pointer; padding: 0; font-family: inherit; font-size: inherit; text-decoration: none;}
.switch-btn:hover { text-decoration: underline; }

.checkbox-wrapper { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.checkbox-label { font-size: 0.875rem; color: var(--slate-500); }
.checkbox-label a { color: inherit; text-decoration: underline; }
input[type="checkbox"] { accent-color: var(--primary); width: 1rem; height: 1rem; }

.form-enter { animation: slideIn 0.3s ease-out forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Toast */
.toast-container { position: fixed; top: 2rem; right: 2rem; z-index: 1000; display: flex; flex-direction: column; gap: 0.75rem; }
.toast {
    background: var(--white); padding: 1rem 1.5rem; border-radius: var(--radius-xl);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--primary); font-size: 0.875rem; font-weight: 500;
    display: flex; align-items: center; gap: 0.75rem; animation: toastEnter 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 300px; color:#fff;
}
.toast.error { border-left-color: var(--error); background-color:var(--error); }
.toast.success { border-left-color: #22c55e;  background-color:#22c55e; }

@keyframes toastEnter { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastExit { to { transform: translateX(100%); opacity: 0; } }


.checkbox-group {
    /* Убираем лишние отступы, чтобы чекбокс стоял плотно */
    margin-bottom: 0.5rem; 
}

.checkbox-group .error-message {
    /* Небольшой отступ для текста ошибки под галочкой */
    margin-top: 0.2rem;
    margin-left: 0.2rem; 
}


/* === МОБИЛЬНАЯ АДАПТАЦИЯ (ДОБАВИТЬ В КОНЕЦ ФАЙЛА) === */
@media (max-width: 900px) {
    body {
        display: block; /* Отключаем Flex-центрирование */
        height: auto;
        min-height: 100vh;
        padding: 0; /* Убираем отступы от краев экрана */
        background-color: var(--white);
    }

    .auth-card {
        width: 100%;
        max-width: 100%;
        height: auto !important; /* Карточка растягивается по контенту */
        min-height: 100vh; /* Занимает минимум весь экран */
        border-radius: 0; /* Убираем скругления */
        box-shadow: none; /* Убираем тень, она не нужна на весь экран */
        display: flex;
        flex-direction: column;
        position: static; /* Статичное позиционирование */
    }

    /* Делаем красивую узкую шапку из картинки */
    .hero-section {
        display: block !important; /* Принудительно показываем */
        width: 100%;
        height: 160px; /* Фиксированная высота шапки */
        flex: none; /* Запрещаем сжиматься/растягиваться */
        min-height: auto;
    }
    
    /* Скрываем лишний текст в шапке на мобильном, оставляем только лого */
    .hero-content {
        padding: 1.5rem;
        bottom: 0;
    }
    .hero-title, .hero-desc {
        display: none; 
    }
    .logo-badge {
        margin-bottom: 0; /* Логотип по центру высоты шапки */
    }

    /* Настройки формы */
    .form-section {
        width: 100%;
        padding: 2rem 1.5rem; /* Комфортные отступы */
        overflow-y: visible; /* Разрешаем скролл всей страницы */
        flex: 1; /* Занимает все оставшееся место */
    }

    /* Кнопку "На главную" делаем компактнее и заметнее на фоне картинки */
    .back-link {
        top: 15px;
        left: 15px;
        background: rgba(255, 255, 255, 0.9);
        padding: 6px 12px;
        font-size: 0.8rem;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }
}