/* ============================================================================
   MascotAI v3.2 — ЕДИНЫЙ ЧИСТЫЙ CSS (без дублей и конфликтов)
   Размер: 40×60px | Чат: компактный | Анимации: плавные
   ============================================================================ */

:root {
    --mascot-w: 40px;
    --mascot-h: 60px;
    --primary: #667eea;
    --accent: #00d9ff;
    --bg-dark: #1a1a2e;
    --text-light: #e2e8f0;
    --shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Обертка */
.mascot-wrapper {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: var(--mascot-w);
    height: var(--mascot-h);
    z-index: 99999;
    pointer-events: none;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 11px;
}
.mascot-wrapper * { pointer-events: auto; box-sizing: border-box; }

/* Тело маскота */
.mascot {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
    transition: transform 0.2s ease;
}
.mascot:hover { transform: scale(1.05); }
.mascot:active { transform: scale(0.95); }

.mascot-body {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary), #764ba2);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.mascot-face {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 22px;
    background: var(--bg-dark);
    border-radius: 4px;
    border: 1px solid #4a5568;
}

.mascot-eyes {
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
}

.eye {
    width: 5px;
    height: 7px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--accent);
    animation: blink 4s infinite;
}
@keyframes blink {
    0%, 94%, 100% { transform: scaleY(1); }
    97% { transform: scaleY(0.1); }
}

.mascot-mouth {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 4px 4px;
    transition: all 0.2s ease;
}

/* Статус */
.mascot-status {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #48bb78;
    box-shadow: 0 0 3px #48bb78;
    animation: pulse 2s infinite;
    z-index: 1;
}
.mascot-status.offline {
    background: #e53e3e;
    box-shadow: 0 0 3px #e53e3e;
    animation: none;
    z-index: 1;
}
@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:0.5 } }

/* Пузырь чата */
.mascot-bubble {
    position: absolute;
    bottom: calc(var(--mascot-h) + 12px);
    right: 0;
    width: 240px;
    max-width: 85vw;
    background: rgba(26, 32, 44, 0.98);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    padding: 8px;
    color: var(--text-light);
    display: none; /* JS переключает на block/none */
    z-index: 100000;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    animation: popIn 0.2s ease;
}
.mascot-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 14px;
    border: 6px solid transparent;
    border-top-color: rgba(26, 32, 44, 0.98);
}
@keyframes popIn { from { opacity:0; transform:translateY(6px) } to { opacity:1; transform:translateY(0) } }

/* История сообщений */
.mascot-messages {
    max-height: 160px;
    overflow-y: auto;
    margin-bottom: 6px;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    scrollbar-width: thin;
    scrollbar-color: #4a5568 transparent;
}
.mascot-messages::-webkit-scrollbar { width: 3px; }
.mascot-messages::-webkit-scrollbar-thumb { background: #4a5568; border-radius: 2px; }

.msg {
    padding: 5px 7px;
    border-radius: 6px;
    max-width: 85%;
    line-height: 1.35;
    word-break: break-word;
}
.msg.user {
    background: var(--primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}
.msg.mascot {
    background: rgba(255,255,255,0.08);
    color: var(--text-light);
    align-self: flex-start;
    border: 1px solid rgba(255,255,255,0.1);
    border-bottom-left-radius: 2px;
}

/* Поле ввода */
.mascot-input-area {
    display: flex;
    gap: 4px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 6px;
}
.mascot-input-area input {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    padding: 5px 6px;
    color: var(--text-light);
    font-size: 11px;
    outline: none;
    transition: border-color 0.2s;
}
.mascot-input-area input:focus { border-color: var(--accent); }
.mascot-input-area input::placeholder { color: #718096; }
.mascot-input-area button {
    background: var(--primary);
    border: none;
    border-radius: 4px;
    color: #fff;
    padding: 0 10px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}
.mascot-input-area button:hover { background: #764ba2; }
.mascot-input-area button:active { transform: scale(0.95); }

/* Индикатор набора */
.typing {
    align-self: flex-start;
    background: rgba(255,255,255,0.08);
    padding: 4px 8px;
    border-radius: 6px;
    display: flex;
    gap: 2px;
}
.typing span {
    width: 4px; height: 4px;
    background: #a0aec0;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.typing span:nth-child(1) { animation-delay: -0.32s; }
.typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%,80%,100% { transform:scale(0) } 40% { transform:scale(1) } }

/* Эмоции */
.mascot.emotion-happy .mascot-mouth { height: 4px; border-radius: 0 0 6px 6px; background: linear-gradient(90deg, var(--accent), #00ff88); }
.mascot.emotion-thinking .eye { animation: think 1.5s infinite; }
@keyframes think { 0%,100% { opacity:1 } 50% { opacity:0.4 } }
.mascot.emotion-excited .eye { animation: excited 0.3s infinite alternate; box-shadow: 0 0 8px var(--accent); }
@keyframes excited { from { transform:scale(1) } to { transform:scale(1.3) } }
.mascot.emotion-sad .mascot-mouth { border-radius: 4px 4px 0 0; height: 3px; background: #fc8181; }

/* Действия */
.mascot.action-wave { animation: wave 0.8s ease infinite; }
@keyframes wave { 0%,100% { transform:rotate(0) } 50% { transform:rotate(6deg) } }
.mascot.action-look { animation: look 2s ease-in-out infinite; }
@keyframes look { 0%,100% { transform:translateX(0) } 50% { transform:translateX(2px) } }
.mascot.action-bounce { animation: bounceMascot 0.5s ease; }
@keyframes bounceMascot { 0%,100% { transform:translateY(0) } 50% { transform:translateY(-3px) } }

/* Адаптив */
@media (max-width: 480px) {
    .mascot-wrapper { bottom: 6px; right: 6px; }
    .mascot-bubble { width: 200px; bottom: calc(var(--mascot-h) + 10px); }
}

/* Кнопки-подсказки */
.mascot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 6px 0;
    padding: 4px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.mascot-action {
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid rgba(102, 126, 234, 0.4);
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 10px;
    color: var(--accent);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.mascot-action:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-1px);
}

.mascot-action:active {
    transform: scale(0.98);
}


/* === EMOJI-ПУЗЫРЬ ЭМОЦИЙ === */
.emoji-bubble {
    position: absolute;
    bottom: calc(var(--mascot-h) + 8px);
    right: 50%;
    transform: translateX(50%);
    background: rgba(255,255,255,0.95);
    border: 2px solid var(--accent);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    z-index: 100001;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: none;
    transition: transform 0.15s ease;
}
.emoji-bubble.pop {
    animation: popEmoji 0.3s ease;
}
@keyframes popEmoji {
    0% { transform: translateX(50%) scale(0.5); opacity: 0; }
    50% { transform: translateX(50%) scale(1.2); }
    100% { transform: translateX(50%) scale(1); opacity: 1; }
}

/* === АНИМАЦИИ ЭМОЦИЙ === */
.mascot.emotion-happy .mascot-mouth {
    height: 4px; border-radius: 0 0 6px 6px;
    background: linear-gradient(90deg, var(--accent), #00ff88);
}
.mascot.emotion-excited .mascot-mouth {
    height: 5px; border-radius: 0 0 8px 8px;
    background: linear-gradient(90deg, #ff6b6b, #ffa502);
    animation: excitedMouth 0.4s infinite alternate;
}
@keyframes excitedMouth {
    from { height: 5px; } to { height: 7px; }
}
.mascot.emotion-thinking .eye {
    animation: think 1.2s infinite;
}
@keyframes think { 0%,100%{opacity:1} 50%{opacity:0.4} }
.mascot.emotion-sad .mascot-mouth {
    border-radius: 4px 4px 0 0; height: 3px; background: #fc8181;
}
.mascot.emotion-angry .eye {
    transform: rotate(15deg); background: #ff6b6b;
}

/* === АНИМАЦИИ ДЕЙСТВИЙ === */
.mascot.action-wave { animation: wave 0.7s ease infinite; }
@keyframes wave { 0%,100%{transform:rotate(0)} 50%{transform:rotate(7deg)} }
.mascot.action-look { animation: look 1.5s ease-in-out infinite; }
@keyframes look { 0%,100%{transform:translateX(0)} 50%{transform:translateX(2px)} }
.mascot.action-bounce { animation: bounce 0.4s ease; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }

/* === КНОПКИ-ПОДСКАЗКИ === */
.mascot-actions {
    display: flex; flex-wrap: wrap; gap: 4px;
    margin: 6px 0; padding: 4px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.mascot-action {
    background: rgba(102,126,234,0.2);
    border: 1px solid rgba(102,126,234,0.4);
    border-radius: 12px; padding: 4px 10px;
    font-size: 10px; color: var(--accent);
    cursor: pointer; transition: all 0.15s;
    white-space: nowrap;
}
.mascot-action:hover {
    background: var(--primary); color: #fff;
    transform: translateY(-1px);
}
