:root {
    --primary: #FF5722;
    --primary-dark: #E64A19;
    --primary-light: #FFCCBC;
    --bg: #FAFAFA;
    --card: #FFFFFF;
    --text: #212121;
    --text-muted: #666666;
    --border: #E0E0E0;
    --border-light: #EEEEEE;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 10px 40px rgba(255, 87, 34, 0.1);
    --shadow-hover: 0 15px 50px rgba(255, 87, 34, 0.2);
    --success: #4CAF50;
    --danger: #F44336;
    --warning: #FF9800;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Open Sans', sans-serif;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Обертка */
.wrap {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Карточка */
.card {
    background: var(--card);
    padding: 45px 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 440px;
    animation: fadeIn 0.6s ease;
    position: relative;
    overflow: hidden;
}

/* Декоративная линия сверху */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}

/* Бренд и логотип (уменьшил лого) */
.brand {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 32px;
}

.logo {
    width: 48px; /* Уменьшил с 60px */
    height: 48px; /* Уменьшил с 60px */
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 20px; /* Уменьшил с 24px */
    font-family: 'Montserrat', sans-serif;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(255, 87, 34, 0.2);
}

.brand div {
    flex: 1;
}

h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 26px; /* Немного уменьшил */
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.2;
}

p.lead {
    color: var(--text-muted);
    font-size: 14px; /* Уменьшил */
    margin-top: 4px;
}

/* Переключатель ролей - улучшенный */
.role-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
    background: var(--border-light);
    padding: 6px;
    border-radius: 10px;
}

.role-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    position: relative;
    overflow: hidden;
}

.role-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.role-btn span {
    position: relative;
    z-index: 2;
}

.role-btn:hover:not(.active) {
    color: var(--primary);
}

.role-btn.active {
    background: var(--card);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.role-btn.active::before {
    opacity: 0.1;
}

/* Иконка роли */
.role-btn::after {
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-right: 8px;
}

.role-btn[data-role="teacher"]::after {
    content: '\f501'; /* Иконка преподавателя */
}

.role-btn[data-role="student"]::after {
    content: '\f19d'; /* Иконка студента */
}

/* Форма */
form {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.field {
    display: flex;
    flex-direction: column;
}

label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

label i {
    color: var(--primary);
    font-size: 12px;
}

/* Поля ввода */
.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text);
    transition: all 0.3s ease;
    line-height: 1.5;
}

.input-wrap input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 87, 34, 0.15);
}

/* Важно: серые рамки при загрузке */
.input-wrap input:not(:focus):not(.error):not(.success) {
    border-color: var(--border) !important;
}

/* Иконки в полях */
.icon {
    position: absolute;
    color: var(--text-muted);
    font-size: 16px; /* Немного уменьшил */
    pointer-events: none;
    transition: color 0.3s ease;
}

.icon.left {
    left: 16px;
}

.icon.right {
    right: 16px;
    pointer-events: auto;
    cursor: pointer;
}

.icon.right:hover {
    color: var(--primary);
}

/* Эффект фокуса для иконок */
.input-wrap input:focus + .icon.left {
    color: var(--primary);
}

/* Ссылка "Забыли пароль?" */
.row {
    text-align: right;
    margin-top: -8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
}

.remember-me input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    position: relative;
    padding-bottom: 2px;
}

.link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--primary);
    transition: width 0.3s ease;
}

.link:hover {
    color: var(--primary-dark);
}

.link:hover::after {
    width: 100%;
}

/* Кнопка отправки - улучшенная */
.submit {
    margin-top: 10px;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.5px;
}

.submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s ease;
}

.submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.submit:hover:not(:disabled)::before {
    left: 100%;
}

.submit:active:not(:disabled) {
    transform: translateY(0);
}

.submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.submit.loading {
    position: relative;
    color: transparent;
}

.submit.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid white;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Сообщения об ошибках */
.error {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: rgba(244, 67, 54, 0.1);
    border-left: 4px solid var(--danger);
    color: var(--danger);
    font-weight: 500;
    font-size: 14px;
    display: none;
    animation: slideDown 0.4s ease;
    position: relative;
    padding-right: 40px;
}

.error.show {
    display: block;
}

.error .close-error {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--danger);
    font-size: 16px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.error .close-error:hover {
    opacity: 1;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Сообщение об успехе */
.success-message {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: rgba(76, 175, 80, 0.1);
    border-left: 4px solid var(--success);
    color: var(--success);
    font-weight: 500;
    font-size: 14px;
    display: none;
    animation: slideDown 0.4s ease;
}

.success-message.show {
    display: block;
}

/* Футер - улучшенный */
.footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer .link {
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.footer .link i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.footer .link:hover i {
    transform: translateX(3px);
}

/* Иконки социальных сетей (опционально) */
.social-login {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 10px;
}

.social-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--border-light);
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

/* Анимация появления */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Анимация тряски */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Пульсация для активного поля */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 87, 34, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(255, 87, 34, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 87, 34, 0); }
}

.input-wrap input:focus {
    animation: pulse 1.5s infinite;
}

/* Адаптивность */
@media (max-width: 640px) {
    .card {
        padding: 35px 25px;
    }
    
    .brand {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }
    
    .logo {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    h1 {
        font-size: 22px;
    }
    
    .role-selector {
        flex-direction: column;
    }
    
    .row {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 30px 20px;
        border-radius: 12px;
    }
    
    .wrap {
        padding: 15px;
    }
    
    .submit {
        padding: 14px;
    }
}

/* Темная тема 
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121212;
        --card: #1e1e1e;
        --text: #ffffff;
        --text-muted: #aaaaaa;
        --border: #333333;
        --border-light: #2a2a2a;
        --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
        --shadow-hover: 0 15px 50px rgba(0, 0, 0, 0.4);
    }
    
    body {
        background: linear-gradient(135deg, #ff7043, #d84315);
    }
    
    .input-wrap input {
        background: #2a2a2a;
        color: white;
    }
    
    .role-btn {
        background: transparent;
        color: #cccccc;
    }
    
    .role-selector {
        background: #333;
    }
    
    .role-btn.active {
        background: #2a2a2a;
    }
    
    .social-btn {
        background: #333;
    }
}
*/

/* Production polish */
:root {
    --primary: #F97316;
    --primary-dark: #C2410C;
    --primary-light: #FFEDD5;
    --bg: #F8FAFC;
    --card: #FFFFFF;
    --text: #111827;
    --text-muted: #5B6475;
    --border: #E5E7EB;
    --border-light: #F1F5F9;
    --radius: 8px;
    --radius-sm: 8px;
    --shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
    --shadow-hover: 0 18px 40px rgba(249, 115, 22, 0.24);
}

body {
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.22), rgba(16, 185, 129, 0.12)),
        #111827;
}

.wrap {
    padding: 28px;
}

.card {
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
}

.card::before {
    height: 5px;
    background: linear-gradient(90deg, #2563EB, #10B981, var(--primary));
}

.logo,
.submit,
.role-selector,
.role-btn,
.input-wrap {
    border-radius: 8px;
}

.role-selector {
    background: #EEF2F7;
}

.footer {
    padding-top: 18px;
    border-top: 1px solid var(--border);
}
