/* Стилі сторінки логіну */

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --background-color: #0f172a;
    --card-background: #1e293b;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --error-color: #ef4444;

    /* Кольори робота */
    --robot-body: #64748b;
    --robot-body-light: #94a3b8;
    --robot-body-dark: #475569;
    --robot-screen: #0f172a;
    --robot-eye: #22d3ee;
    --robot-eye-glow: rgba(34, 211, 238, 0.5);
    --robot-accent: #6366f1;
}

/* Кнопка повернення на головну сторінку порталу */
.back-home {
    position: fixed;
    top: 1.25rem;
    left: 1.25rem;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1.05rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: color 0.25s ease, border-color 0.25s ease,
                background 0.25s ease, transform 0.25s ease;
}

.back-home:hover {
    color: var(--text-color);
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.18);
    transform: translateX(-2px);
}

.back-home__arrow {
    font-size: 1.05rem;
    line-height: 1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--background-color) 0%, #1e1b4b 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* ===== РОБОТ ===== */
.character-container {
    position: relative;
    width: 200px;
    height: 200px;
}

.character {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Антена */
.antenna {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 20px;
    background: var(--robot-body-dark);
    z-index: 3;
}

.antenna-ball {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: var(--robot-accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--robot-accent);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--robot-accent); }
    50% { opacity: 0.7; box-shadow: 0 0 20px var(--robot-accent); }
}

/* Голова */
.head {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 90px;
    background: linear-gradient(180deg, var(--robot-body-light) 0%, var(--robot-body) 100%);
    border-radius: 20px 20px 30px 30px;
    z-index: 2;
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,0.2),
        0 4px 8px rgba(0,0,0,0.3);
}

/* Бокові панелі (вуха робота) */
.side-panel {
    position: absolute;
    width: 15px;
    height: 40px;
    background: var(--robot-body-dark);
    top: 25px;
    border-radius: 5px;
}

.side-panel-left {
    left: -8px;
}

.side-panel-right {
    right: -8px;
}

.side-panel::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--robot-accent);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 5px var(--robot-accent);
}

/* Екран обличчя */
.face-screen {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 55px;
    background: var(--robot-screen);
    border-radius: 10px;
    border: 3px solid var(--robot-body-dark);
    overflow: hidden;
}

/* Очі робота */
.eyes {
    display: flex;
    justify-content: space-around;
    padding: 10px 10px 0;
}

.eye {
    width: 24px;
    height: 24px;
    background: var(--robot-eye);
    border-radius: 5px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px var(--robot-eye-glow);
}

.pupil {
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 3px;
    position: relative;
    transition: all 0.2s ease;
}

/* Закриті очі (горизонтальна лінія) */
.eye.closed {
    height: 4px;
    border-radius: 2px;
    background: var(--robot-eye);
    box-shadow: 0 0 10px var(--robot-eye-glow);
}

.eye.closed .pupil {
    display: none;
}

/* Напівзакрите око (сканування) */
.eye.peeking {
    height: 12px;
    animation: scan 0.5s ease-in-out infinite alternate;
}

@keyframes scan {
    0% { box-shadow: 0 0 10px var(--robot-eye-glow); }
    100% { box-shadow: 0 0 20px var(--robot-eye), 0 0 30px var(--robot-eye-glow); }
}

.eye.peeking .pupil {
    width: 8px;
    height: 6px;
}

/* Рот робота (лінії еквалайзера) */
.mouth {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 4px;
    margin-top: 8px;
    height: 15px;
    transition: all 0.3s ease;
}

.mouth-line {
    width: 6px;
    height: 8px;
    background: var(--robot-eye);
    border-radius: 2px;
    transition: all 0.3s ease;
    box-shadow: 0 0 5px var(--robot-eye-glow);
}

.mouth-line:nth-child(1) { height: 6px; }
.mouth-line:nth-child(2) { height: 10px; }
.mouth-line:nth-child(3) { height: 6px; }

/* Стурбований рот */
.mouth.worried .mouth-line {
    background: #f59e0b;
    box-shadow: 0 0 5px rgba(245, 158, 11, 0.5);
    animation: worried-blink 0.3s ease-in-out infinite alternate;
}

@keyframes worried-blink {
    0% { opacity: 1; }
    100% { opacity: 0.5; }
}

.mouth.worried .mouth-line:nth-child(1) { height: 4px; }
.mouth.worried .mouth-line:nth-child(2) { height: 4px; }
.mouth.worried .mouth-line:nth-child(3) { height: 4px; }

/* Руки робота */
.hands {
    position: absolute;
    top: 105px;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    display: flex;
    justify-content: space-between;
    z-index: 3;
}

.hand {
    width: 28px;
    height: 45px;
    background: linear-gradient(180deg, var(--robot-body) 0%, var(--robot-body-dark) 100%);
    border-radius: 8px;
    position: relative;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Клешня (ладонь) */
.hand-clamp {
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 15px;
    background: var(--robot-body-dark);
    border-radius: 0 0 8px 8px;
}

.hand-clamp::before,
.hand-clamp::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 10px;
    background: var(--robot-body-dark);
    bottom: -8px;
    border-radius: 0 0 4px 4px;
}

.hand-clamp::before {
    left: 0;
}

.hand-clamp::after {
    right: 0;
}

/* Руки закривають очі - перевертаються долонями до обличчя */
.hand.covering {
    transform: translateY(-35px) rotate(180deg);
}

/* Ліва рука йде вправо (закриває праве око) */
.hand-left.covering {
    transform: translateY(-35px) translateX(25px) rotate(170deg);
    z-index: 5;
}

/* Права рука йде вліво (закриває ліве око) */
.hand-right.covering {
    transform: translateY(-35px) translateX(-25px) rotate(190deg);
    z-index: 4;
}

/* Рука підглядає - трохи відводиться */
.hand.peeking {
    transform: translateY(-25px) rotate(180deg);
}

.hand-left.peeking {
    transform: translateY(-25px) translateX(20px) rotate(165deg);
    z-index: 5;
}

.hand-right.peeking {
    transform: translateY(-25px) translateX(-20px) rotate(195deg);
    z-index: 4;
}

/* Тіло робота */
.body {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 70px;
    background: linear-gradient(180deg, var(--robot-body) 0%, var(--robot-body-dark) 100%);
    border-radius: 15px 15px 25px 25px;
    z-index: 1;
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,0.1),
        0 4px 8px rgba(0,0,0,0.3);
}

/* Індикатор на тілі */
.body-light {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 10px #22c55e;
    animation: body-pulse 1.5s ease-in-out infinite;
}

@keyframes body-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Панель на тілі */
.body-panel {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 25px;
    background: var(--robot-body-dark);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.body-panel::before {
    content: '';
    width: 35px;
    height: 3px;
    background: var(--robot-body-light);
    border-radius: 2px;
}

/* ===== ФОРМА ЛОГІНУ ===== */
.login-box {
    background: var(--card-background);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 380px;
    border: 1px solid var(--border-color);
}

.login-box h1 {
    color: var(--text-color);
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    color: var(--text-color);
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* Обгортка пароля */
.password-wrapper {
    position: relative;
}

.password-wrapper .form-input {
    padding-right: 3rem;
}

.toggle-password {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-muted);
    transition: color 0.2s;
}

.toggle-password:hover {
    color: var(--text-color);
}

.eye-icon {
    width: 20px;
    height: 20px;
}

.eye-icon.hidden {
    display: none;
}

/* Помилки */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    text-align: center;
}

.field-error {
    color: var(--error-color);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: block;
}

/* Кнопка входу */
.btn-login {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--primary-color);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-login:hover {
    background: var(--primary-hover);
}

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

/* ===== РУКА З МОРОЗИВОМ (рандомна подія) ===== */
.icecream-hand {
    position: fixed;
    left: -200px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    transition: left 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    display: flex;
    flex-direction: row;
    align-items: center;
}

.icecream-hand.visible {
    left: 10px;
}

.icecream-hand.from-right {
    left: auto;
    right: -200px;
    flex-direction: row-reverse;
    transition: right 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icecream-hand.visible.from-right {
    left: auto;
    right: 10px;
}

/* Передпліччя (горизонтальне) */
.hand-arm {
    width: 80px;
    height: 32px;
    background: linear-gradient(180deg, #f5d0b5 0%, #e0b89d 50%, #d4a787 100%);
    border-radius: 8px 15px 15px 8px;
    position: relative;
    box-shadow: inset 0 -2px 4px rgba(0,0,0,0.1);
}

/* Рукав сорочки */
.hand-arm::before {
    content: '';
    position: absolute;
    left: 0;
    top: -5px;
    width: 30px;
    height: 42px;
    background: linear-gradient(90deg, #334155 0%, #475569 100%);
    border-radius: 8px 0 0 8px;
    box-shadow: 2px 0 4px rgba(0,0,0,0.2);
}

/* ===== КУЛАК З ПАЛЬЦЯМИ (вид збоку) ===== */
.fist {
    position: relative;
    width: 40px;
    height: 50px;
    margin-left: -5px;
}

/* Долоня (основа кулака) */
.fist::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 0;
    width: 35px;
    height: 40px;
    background: linear-gradient(90deg, #e0b89d 0%, #f5d0b5 50%, #e8c4a4 100%);
    border-radius: 8px 12px 12px 8px;
    z-index: 2;
    box-shadow: inset -2px 0 4px rgba(0,0,0,0.1);
}

/* Пальці (зігнуті, вид збоку) */
.fingers {
    position: absolute;
    top: 8px;
    right: -8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 10;
}

.finger {
    width: 22px;
    height: 9px;
    background: linear-gradient(180deg, #f5d0b5 0%, #dda882 100%);
    border-radius: 4px 6px 6px 4px;
    box-shadow: inset 0 -1px 2px rgba(0,0,0,0.15);
}

.finger-1 { width: 18px; }
.finger-2 { width: 22px; }
.finger-3 { width: 21px; }
.finger-4 { width: 17px; }

/* Великий палець (зверху кулака) */
.thumb {
    position: absolute;
    top: -5px;
    left: 8px;
    width: 28px;
    height: 14px;
    background: linear-gradient(180deg, #f5d0b5 0%, #e0b89d 100%);
    border-radius: 7px 7px 4px 4px;
    z-index: 11;
    box-shadow: inset 0 2px 3px rgba(255,255,255,0.2);
}

/* Морозиво (виходить з кулака вгору) */
.fist .icecream {
    position: absolute;
    top: -58px;
    left: 12px;
    z-index: 5;
}

/* Ріжок морозива */
.fist .icecream-cone {
    width: 0;
    height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-top: 50px solid #d97706;
    position: absolute;
    top: 34px;
    left: 5px;
    border-radius: 0 0 4px 4px;
    z-index: 1;
}

/* Текстура ріжка */
.fist .icecream-cone::before {
    content: '';
    position: absolute;
    top: -48px;
    left: -10px;
    width: 20px;
    height: 46px;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 4px,
        rgba(139, 90, 43, 0.3) 4px,
        rgba(139, 90, 43, 0.3) 8px
    );
    border-radius: 2px;
}

.fist .icecream-scoop {
    width: 26px;
    height: 24px;
    border-radius: 50%;
    position: absolute;
}

/* Верхня кулька (рожева) - на вершині піраміди */
.fist .scoop-1 {
    background: radial-gradient(circle at 30% 30%, #fcd5e5, #f472b6);
    top: 0;
    left: 5px;
    z-index: 3;
    animation: icecream-wobble 2s ease-in-out infinite;
}

/* Ліва нижня кулька (м'ятна) */
.fist .scoop-2 {
    background: radial-gradient(circle at 30% 30%, #a7f3d0, #34d399);
    top: 18px;
    left: -8px;
    z-index: 2;
    animation: icecream-wobble 2s ease-in-out infinite 0.2s;
}

/* Права нижня кулька (жовта) */
.fist .scoop-3 {
    background: radial-gradient(circle at 30% 30%, #fef9c3, #fbbf24);
    top: 18px;
    left: 18px;
    z-index: 2;
    animation: icecream-wobble 2s ease-in-out infinite 0.4s;
}

@keyframes icecream-wobble {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

/* ===== БУЛЬБАШКА З ТЕКСТОМ ===== */
.speech-bubble {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: var(--card-background);
    border: 2px solid var(--robot-eye);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    z-index: 100;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    box-shadow: 0 0 20px var(--robot-eye-glow);
}

.speech-bubble.visible {
    transform: translateX(-50%) scale(1);
    opacity: 1;
    top: -15px;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid var(--robot-eye);
}

.speech-bubble span {
    color: var(--robot-eye);
    font-weight: 600;
    font-size: 0.9rem;
    text-shadow: 0 0 10px var(--robot-eye-glow);
}

/* Стан "тягнеться за морозивом" */
.character.reaching-left {
    animation: reach-left 0.5s ease-out forwards;
}

.character.reaching-right {
    animation: reach-right 0.5s ease-out forwards;
}

@keyframes reach-left {
    0% { transform: translateX(0) rotate(0); }
    100% { transform: translateX(-20px) rotate(-10deg); }
}

@keyframes reach-right {
    0% { transform: translateX(0) rotate(0); }
    100% { transform: translateX(20px) rotate(10deg); }
}

/* Стан "засмучений" */
.character.sad {
    animation: sad-shake 0.5s ease-out;
}

@keyframes sad-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Очі "хочу" - великі та блискучі */
.eye.wanting {
    transform: scale(1.2);
    box-shadow: 0 0 25px var(--robot-eye-glow), 0 0 40px var(--robot-eye-glow);
}

.eye.wanting .pupil {
    transform: scale(1.3);
}

/* Сумні очі */
.eye.sad-eye {
    height: 16px;
    border-radius: 0 0 12px 12px;
    background: linear-gradient(180deg, transparent 30%, var(--robot-eye) 30%);
}

/* Сумний рот */
.mouth.sad .mouth-line {
    background: #60a5fa;
    height: 4px !important;
    box-shadow: 0 0 5px rgba(96, 165, 250, 0.5);
}

/* Адаптивність */
@media (max-width: 480px) {
    .login-box {
        padding: 1.5rem;
    }

    .character-container {
        transform: scale(0.85);
    }

    .icecream-hand {
        display: none;
    }
}
