/* === Базовый сброс и переменные === */
:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e4e4e7;
    --text-main: #09090b;
    --text-muted: #71717a;
    --primary-color: #09090b;
    --primary-hover: #27272a;
    --primary-fg: #fafafa;
    --ring-color: #a1a1aa;
    --radius-lg: 0.75rem;
    --radius-md: 0.375rem;
    --radius-sm: 0.25rem;
    --transition: 0.3s ease;
    --danger-color: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* === Глобальный загрузчик (проверка при входе) === */
#global-loader {
    position: fixed;
    inset: 0;
    background: var(--bg-color);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition);
}

#global-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* === Всплывающие уведомления (Тосты) === */
#toast-container {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    font-size: 0.875rem;
    line-height: 1.4;
    padding: 0.75rem 1rem;
    border-radius: 0.625rem;
    max-width: 32rem;
    min-width: 20rem;
    width: 100%;

    transform: translateY(120%);
    opacity: 0;
    animation: slideIn 0.3s forwards;
}

.toast h3 {
    font-weight: 500;
    font-size: 0.875rem;
}

.toast.error {
    background-color: #e7000b0d;
    color: #e7000b;
}

.toast.success {
    background-color: #0000000d;
    color: #343434;
}

.toast.fade-out {
    animation: fadeOut 0.3s forwards;
}

@keyframes slideIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-120%);
        opacity: 0;
    }
}

/* === Лейаут === */
.page-wrapper {
    min-height: 100vh;
    display: flex;

    background-color: var(--card-bg);
    align-items: center;
    justify-content: center;
}


.login-card {
    width: 100%;
    background-color: var(--card-bg);
    overflow: hidden;
    flex-direction: row-reverse;
    display: flex;
}

@media (min-width: 768px) {
    .page-wrapper {
        padding: 1rem;
        background-color: transparent;
    }

    .login-card {
        max-width: 980px;
        min-height: 530px;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    }
}

/* === Левая часть (Брендинг) === */
.brand-section {
    background-color: #09090b;
    color: white;
    padding: 2rem;
    display: flex;
    width: 100%;
    position: relative;
    flex-direction: column;
    justify-content: space-between;
}

@media (max-width: 768px) {
    .brand-section {
        display: none;
    }
}

.brand-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.brand-header p {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #a1a1aa;
}

.testimonial p {
    font-size: 0.875rem;
    font-style: italic;
    color: #a1a1aa;
}

.testimonial footer {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #71717a;
}

/* === Правая часть (Формы) === */
.form-section {
    padding: 2rem;
    width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.form-section form {
    max-width: 360px;
    width: 100%;
}

@media (min-width: 1024px) {
    .form-section {
        padding: 2.5rem;
    }
}

@media (max-width: 768px) {
    .form-section {
        padding: 1rem;
    }
}

/* Механика переключения видов */
.auth-view {
    display: none;
    flex-direction: column;
    gap: 1rem;
}

.auth-view.active {
    display: flex;
    animation: viewFadeIn 0.4s ease;
}

@keyframes viewFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-header {
    margin-bottom: 1rem;
}

.form-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.form-header p {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-input {
    height: 2.5rem;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.25rem 0.75rem;
    font-size: 1rem;
    background-color: transparent;
    transition:
        box-shadow var(--transition),
        border-color var(--transition);
    outline: none;
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:focus {
    border-color: var(--ring-color);
    box-shadow: 0 0 0 3px rgba(161, 161, 170, 0.2);
}

/* Спец. стили для OTP */
.otp-input {
    text-align: center;
    letter-spacing: 0.5em;
    font-size: 1.5rem;
    font-weight: 600;
    font-family: monospace;
}

/* Элементы управления */
.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.25rem;
}

.text-link {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
    background: none;
    border: none;
    font-family: inherit;
}

.text-link:hover {
    color: var(--text-main);
}

/* Кнопки */
.btn {
    width: 100%;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    border: 1px solid transparent;
    gap: 0.5rem;
}

.btn-submit {
    background-color: var(--primary-color);
    color: var(--primary-fg);
    margin-top: 0.5rem;
}

.btn-submit:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-google {
    background-color: var(--card-bg);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-google:hover:not(:disabled) {
    background-color: var(--bg-color);
}

.btn-google:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 0.5rem 0;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider span {
    padding: 0 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.bottom-prompt {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.bottom-prompt button {
    color: var(--text-main);
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}

.bottom-prompt button:hover {
    text-decoration: underline;
}


/* Дополнительные стили для пароля и политики */
.label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    width: 100%;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-wrapper .form-input {
    padding-right: 2.5rem;
}

.btn-icon {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    transition: color var(--transition);
    outline: none;
}

.btn-icon:hover {
    color: var(--text-main);
}

.terms-text {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: auto;
    padding-top: 2rem;
}

.terms-text a {
    color: var(--text-muted);
    text-decoration: underline;
}

.terms-text a:hover {
    color: var(--text-main);
}