/* CSS Reset и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:root {
    /* Современная цветовая палитра с градиентами */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-surface: rgba(30, 30, 42, 0.85);
    --bg-card: rgba(36, 36, 50, 0.95);
    --bg-hover: rgba(42, 42, 58, 0.9);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-tertiary: #6a6a7a;
    --border-color: rgba(45, 45, 58, 0.5);
    --accent-primary: #4a6fff;
    --accent-secondary: #7b61ff;
    --accent-gradient: linear-gradient(135deg, #4a6fff 0%, #7b61ff 50%, #aa00ff 100%);
    --accent-gradient-hover: linear-gradient(135deg, #5a7fff 0%, #8b71ff 50%, #ba10ff 100%);
    --success: #00d68f;
    --warning: #ffaa00;
    --danger: #ff3d71;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.12);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(74, 111, 255, 0.3);
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-full: 999px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #0a0a0f 0%, #12121a 50%, #1a1a24 100%);
    color: var(--text-primary);
    line-height: 1.5;
    font-weight: 400;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Эффект частиц на фоне */
.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0.1;
    animation: float 20s infinite linear;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(100px, 100px); }
    50% { transform: translate(0, 200px); }
    75% { transform: translate(-100px, 100px); }
}

/* Контейнер для страниц */
.pages-container {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 1;
}

/* Скрываем все страницы по умолчанию */
.page {
    display: none;
    width: 100%;
    max-width: 400px;
}

.page.active {
    display: block;
    animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Карточка аутентификации */
.auth-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
}

/* Эффект свечения вокруг карточки */
.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--accent-gradient);
    opacity: 0.5;
}

.auth-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(74, 111, 255, 0.1) 0%, transparent 70%);
    z-index: -1;
}

/* Логотип */
.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 32px;
    position: relative;
}

.logo-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-glow);
    animation: pulse 2s infinite;
}

.logo-icon.logo-image {
    background: var(--bg-card);
    overflow: hidden;
}

.logo-icon.logo-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(74, 111, 255, 0.4); }
    50% { box-shadow: 0 0 40px rgba(74, 111, 255, 0.6); }
}

.logo-text {
    font-size: 32px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.logo-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Заголовки форм */
.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #b0b0c0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Подсветка блока заголовка по типу входа: клиент — светло-зелёный, мастер — светло-оранжевый */
.auth-card.role-client .auth-header {
    background: rgba(0, 214, 143, 0.12);
    border: 1px solid rgba(0, 214, 143, 0.45);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 28px;
    transition: background 0.25s ease, border-color 0.25s ease;
}
.auth-card.role-client .auth-subtitle {
    color: rgba(180, 255, 230, 0.95);
    font-weight: 500;
}

.auth-card.role-master .auth-header {
    background: rgba(255, 170, 0, 0.12);
    border: 1px solid rgba(255, 170, 0, 0.5);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 28px;
    transition: background 0.25s ease, border-color 0.25s ease;
}
.auth-card.role-master .auth-subtitle {
    color: rgba(255, 230, 180, 0.95);
    font-weight: 500;
}

/* Формы */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Группы полей ввода */
.input-group {
    position: relative;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-left: 4px;
}

.form-input-wrapper {
    position: relative;
}

.form-input {
    width: 100%;
    height: 56px;
    padding: 0 16px 0 52px;
    background: var(--bg-surface);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-hover);
    box-shadow: var(--shadow-glow);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 18px;
    transition: var(--transition);
    z-index: 1;
}

.form-input:focus + .input-icon {
    color: var(--accent-primary);
}

/* Показать/скрыть пароль */
.toggle-password {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.toggle-password:hover {
    color: var(--accent-primary);
}

/* Кнопки */
.auth-btn {
    width: 100%;
    height: 56px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    margin-top: 8px;
}

.auth-btn:hover {
    background: var(--accent-gradient-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.auth-btn:active { transform: translateY(0); }

.auth-btn-outline {
    background: transparent;
    border: 2px solid var(--accent-primary);
}

/* Эффект нажатия на кнопку */
.auth-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.auth-btn:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% { transform: scale(0, 0); opacity: 0.5; }
    100% { transform: scale(20, 20); opacity: 0; }
}

/* Кнопка "Назад" */
.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    z-index: 100;
    backdrop-filter: blur(10px);
}

.back-btn:hover {
    background: var(--bg-hover);
    transform: translateX(-2px);
}

/* Выбор типа пользователя */
.user-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.user-type-btn {
    padding: 16px 12px;
    background: var(--bg-surface);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    text-align: center;
}

.user-type-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.user-type-btn.active {
    background: rgba(74, 111, 255, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.user-type-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.user-type-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* Разделитель */
.divider {
    display: flex;
    align-items: center;
    margin: 6px 0;
    color: var(--text-tertiary);
    font-size: 13px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.divider span { padding: 0 12px; }

/* Альтернативные способы входа */
.social-auth {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 8px;
}

.social-btn {
    height: 50px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.social-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.social-btn.vk:hover { color: #4C75A3; }
.social-btn.telegram:hover { color: #2ca5e0; }

/* Ссылки */
.auth-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
    text-align: center;
}

.auth-links-row {
    flex-direction: row;
    justify-content: space-between;
}

.auth-links-center {
    justify-content: center;
}

.auth-link {
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
    transition: var(--transition);
    padding: 4px;
}

.auth-link:hover { color: var(--accent-primary); }

.auth-link.primary {
    color: var(--accent-primary);
    font-weight: 600;
}

.auth-link.primary:hover { text-decoration: underline; }

.form-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 6px;
    padding-left: 4px;
}

.terms-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Футер */
.auth-footer {
    text-align: center;
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* Уведомления */
.notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    max-width: 90%;
    text-align: center;
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.notification.success { border-left: 4px solid var(--success); }
.notification.error { border-left: 4px solid var(--danger); }

.notification-icon { font-size: 18px; }
.notification.success .notification-icon { color: var(--success); }
.notification.error .notification-icon { color: var(--danger); }

/* Адаптивность для мобильных */
@media (max-width: 480px) {
    .pages-container {
        padding: 16px;
        padding-top: calc(16px + env(safe-area-inset-top));
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .auth-card {
        padding: 24px 16px;
        border-radius: var(--radius-md);
    }

    .logo-icon { width: 56px; height: 56px; font-size: 20px; }
    .logo-text { font-size: 28px; }
    .auth-title { font-size: 20px; }
    .form-input { height: 52px; padding: 0 16px 0 48px; font-size: 15px; }
    .auth-btn { height: 52px; font-size: 15px; }
    .user-type-selector { grid-template-columns: 1fr; }
    .back-btn { top: 12px; left: 12px; width: 40px; height: 40px; }
}

@media (max-width: 360px) {
    .auth-card { padding: 20px 12px; }
    .logo-text { font-size: 24px; }
    .auth-title { font-size: 18px; }
    .form-input { height: 48px; font-size: 14px; }
    .auth-btn { height: 48px; font-size: 14px; }
    .user-type-btn { padding: 12px 10px; }
    .auth-links-row {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    .divider { margin: 16px 0; }
    .auth-footer { font-size: 11px; }
}

/* Специальные стили для очень маленьких экранов */
@media (max-height: 700px) {
    .auth-card { padding: 20px 16px; }
    .auth-logo { margin-bottom: 24px; }
    .auth-header { margin-bottom: 20px; }
}

/* Анимация перехода между страницами */
.page.exit { animation: fadeOutDown 0.4s ease forwards; }

@keyframes fadeOutDown {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(30px); }
}

/* Спиннер загрузки */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


