/* ============================================
   ALIAIN SYSTEMS — AI Chatbot Widget
   Подключить в index.html перед </body>:
   <link rel="stylesheet" href="chatbot/chatbot.css">
   ============================================ */

/* --- Floating Button --- */
.ai-chat-trigger {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 9990;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: #9b5de5;
    box-shadow: 0 4px 24px rgba(155, 93, 229, 0.4), 0 2px 8px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    outline: none;
    padding: 0;
    animation: ai-float 3s ease-in-out infinite;
}

@keyframes ai-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-6px); }
}

.ai-chat-trigger:hover {
    transform: translateY(-4px) scale(1.08);
    box-shadow: 0 8px 32px rgba(155, 93, 229, 0.55), 0 4px 16px rgba(0,0,0,0.4);
    animation: none;
}

.ai-chat-trigger:active {
    transform: scale(0.95);
}

.ai-chat-trigger svg {
    width: 28px;
    height: 28px;
    color: #ffffff;
    transition: opacity 0.2s, transform 0.3s;
    position: absolute;
}

.ai-chat-trigger .icon-chat  { opacity: 1;  transform: scale(1) rotate(0deg); }
.ai-chat-trigger .icon-close { opacity: 0;  transform: scale(0.5) rotate(90deg); }

.ai-chat-trigger.is-open .icon-chat  { opacity: 0; transform: scale(0.5) rotate(-90deg); }
.ai-chat-trigger.is-open .icon-close { opacity: 1; transform: scale(1) rotate(0deg); }

/* Notification badge */
.ai-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #e05ba0;
    border-radius: 50%;
    border: 2px solid #0a0e1a;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s, transform 0.3s;
}

.ai-chat-trigger.is-open .ai-chat-badge {
    opacity: 0;
    transform: scale(0);
}

/* --- Chat Window --- */
.ai-chat-window {
    position: fixed;
    bottom: 108px;
    right: 32px;
    z-index: 9989;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 140px);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #0d1117;
    border: 1px solid rgba(155, 93, 229, 0.15);
    box-shadow:
        0 32px 64px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(155, 93, 229, 0.06),
        inset 0 1px 0 rgba(255,255,255,0.05);
    transform-origin: bottom right;
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

.ai-chat-window.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* --- Header --- */
.ai-chat-header {
    padding: 16px 20px;
    background: rgba(155, 93, 229, 0.06);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.ai-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #9b5de5;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    position: relative;
}

.ai-chat-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #0d1117;
    animation: ai-pulse-dot 2s infinite;
}

@keyframes ai-pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
    50%       { box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}

.ai-chat-header-info {
    flex: 1;
    min-width: 0;
}

.ai-chat-header-name {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #f0f6fc;
    line-height: 1.2;
}

.ai-chat-header-name span {
    color: #9b5de5;
}

.ai-chat-header-status {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: #22c55e;
    margin-top: 2px;
}

.ai-chat-header-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.05);
    color: #8b9ab0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.ai-chat-header-close:hover {
    background: rgba(155, 93, 229, 0.12);
    color: #9b5de5;
}

/* --- Messages Area --- */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.ai-chat-messages::-webkit-scrollbar { width: 4px; }
.ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(155, 93, 229, 0.2);
    border-radius: 4px;
}

/* Message bubbles */
.ai-msg {
    display: flex;
    flex-direction: column;
    animation: ai-msg-in 0.3s ease forwards;
    opacity: 0;
}

@keyframes ai-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ai-msg--bot  { align-items: flex-start; }
.ai-msg--user { align-items: flex-end; }

.ai-msg-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-line;
    position: relative;
}

.ai-msg--bot .ai-msg-bubble {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(155, 93, 229, 0.1);
    color: #c9d1d9;
    border-radius: 4px 16px 16px 16px;
}

.ai-msg--user .ai-msg-bubble {
    background: rgba(155, 93, 229, 0.12);
    border: 1px solid rgba(155, 93, 229, 0.2);
    color: #e6edf3;
    border-radius: 16px 4px 16px 16px;
}

.ai-msg-time {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    color: #484f58;
    margin-top: 4px;
    padding: 0 4px;
}

/* CTA button inside chat */
.ai-cta-btn {
    display: block;
    margin-top: 14px;
    padding: 10px 20px;
    background: #9b5de5;
    border: none;
    border-radius: 10px;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    text-decoration: none;
    letter-spacing: 0.01em;
}

.ai-cta-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.ai-cta-btn:active {
    transform: scale(0.97);
}

/* Quick reply chips */
.ai-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.ai-quick-chip {
    padding: 6px 14px;
    border: 1px solid rgba(100, 212, 255, 0.3);
    border-radius: 20px;
    background: transparent;
    color: #64d4ff;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.ai-quick-chip:hover {
    background: rgba(100, 212, 255, 0.1);
    border-color: #64d4ff;
    color: #fff;
}

/* Typing indicator */
.ai-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(155, 93, 229, 0.1);
    border-radius: 4px 16px 16px 16px;
    width: fit-content;
    opacity: 0;
    transition: opacity 0.2s;
}

.ai-typing.show { opacity: 1; }

.ai-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9b5de5;
    animation: ai-typing-bounce 1.2s ease-in-out infinite;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* --- Input Area --- */
.ai-chat-input-wrap {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.ai-chat-textarea {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(155, 93, 229, 0.15);
    border-radius: 12px;
    padding: 10px 14px;
    color: #e6edf3;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
    min-height: 42px;
}

.ai-chat-textarea::placeholder { color: #484f58; }
.ai-chat-textarea:focus { border-color: rgba(155, 93, 229, 0.4); }

.ai-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: #9b5de5;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
}

.ai-chat-send:hover   { transform: scale(1.08); opacity: 0.9; }
.ai-chat-send:active  { transform: scale(0.95); }
.ai-chat-send:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

/* --- Disclaimer --- */
.ai-chat-disclaimer {
    padding: 8px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    color: #484f58;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.04);
    background: rgba(0,0,0,0.1);
    flex-shrink: 0;
}

/* --- Mobile --- */
@media (max-width: 480px) {
    .ai-chat-trigger {
        bottom: 20px;
        right: 20px;
        width: 54px;
        height: 54px;
    }

    /* Скрываем плавающую кнопку когда чат открыт —
       на мобильном она перекрывает поле ввода,
       закрыть можно через кнопку в шапке чата */
    .ai-chat-trigger.is-open {
        display: none;
    }

    .ai-chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }
}