/* ============================================================
   AI Chat Widget — ai-chat.css
   ============================================================ */

:root {
    --ai-color: #ba5688;
    --ai-color-dark: #9e3d6f;
    --ai-radius: 18px;
    --ai-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

/* ===== Кнопка-пузырь ===== */
#ai-chat-bubble {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ai-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000001;
    box-shadow: var(--ai-shadow);
    transition: transform 0.2s, background 0.2s;
    border: none;
    outline: none;
}
#ai-chat-bubble:hover {
    transform: scale(1.08);
    background: var(--ai-color-dark);
}
#ai-chat-bubble::after {
    content: '';
    display: block;
    width: 38px;
    height: 56px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-3 10H7v-2h10v2zm0-3H7V7h10v2z'/%3E%3C/svg%3E") no-repeat center / contain;
    flex-shrink: 0;
}
#ai-chat-bubble .ai-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4444;
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ===== Панель чата ===== */
#ai-chat-panel {
    position: fixed;
    bottom: 84px;
    right: 10px;
    width: calc(100vw - 20px);
    max-width: 560px;
    height: 520px;
    max-height: calc(100vh - 84px - var(--ai-masthead-h, 130px));
    min-height: 280px;
    background: #fff;
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    display: flex;
    flex-direction: column;
    z-index: 1000000;
    overflow: hidden;
    transform: scale(0.85) translateY(30px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s;
}
#ai-chat-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ===== Заголовок ===== */
#ai-chat-header {
    background: var(--ai-color);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
#ai-chat-header .ai-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
#ai-chat-header .ai-info {
    flex: 1;
}
#ai-chat-header .ai-name {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}
#ai-chat-header .ai-status {
    font-size: 11px;
    opacity: 0.85;
}
#ai-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}
#ai-chat-close:hover { opacity: 1; }

/* ===== Область сообщений ===== */
#ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fa;
}
#ai-chat-messages::-webkit-scrollbar { width: 4px; }
#ai-chat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* Сообщения */
.ai-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    animation: aiMsgIn 0.2s ease;
}
@keyframes aiMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ai-msg.bot {
    background: #fff;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    color: #333;
}
.ai-msg.user {
    background: var(--ai-color);
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}
.ai-msg-time {
    font-size: 10px;
    opacity: 0.55;
    margin-top: 3px;
    text-align: right;
}
.ai-msg.bot .ai-msg-time { text-align: left; }

/* Typing индикатор */
.ai-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: 60px;
}
.ai-typing span {
    width: 7px;
    height: 7px;
    background: var(--ai-color);
    border-radius: 50%;
    animation: aiDot 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ===== Quick Replies ===== */
#ai-quick-replies {
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}
.ai-qr-btn {
    background: #fff;
    border: 1.5px solid var(--ai-color);
    color: var(--ai-color);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.ai-qr-btn:hover {
    background: var(--ai-color);
    color: #fff;
}

/* ===== Контактная форма ===== */
#ai-contact-form {
    position: relative;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}
#ai-contact-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    font-size: 14px;
    line-height: 1;
    padding: 2px 5px;
    cursor: pointer;
    color: #aaa;
    border-radius: 4px;
    transition: color 0.15s;
}
#ai-contact-close:hover { color: #555; }
#ai-contact-form p {
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
}
.ai-contact-inputs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ai-contact-inputs input {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}
.ai-contact-inputs input:focus { border-color: var(--ai-color); }
#ai-contact-send {
    margin-top: 6px;
    background: var(--ai-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px;
    width: 100%;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}
#ai-contact-send:hover { background: var(--ai-color-dark); }

/* ===== Поле ввода ===== */
#ai-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}
#ai-chat-input {
    flex: 1;
    border: 1.5px solid #e0e0e0;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.15s;
    font-family: inherit;
}
#ai-chat-input:focus { border-color: var(--ai-color); }
#ai-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ai-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
#ai-chat-send:hover { background: var(--ai-color-dark); transform: scale(1.08); }
#ai-chat-send:active { transform: scale(0.95); }
#ai-chat-send:disabled { background: #ccc; cursor: not-allowed; transform: none; box-shadow: none; }
#ai-chat-send::after {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M3.478 2.405a.75.75 0 00-.926.94l2.432 7.905H13.5a.75.75 0 010 1.5H4.984l-2.432 7.905a.75.75 0 00.926.94 60.519 60.519 0 0018.445-8.986.75.75 0 000-1.218A60.517 60.517 0 003.478 2.405z'/%3E%3C/svg%3E") no-repeat center / contain;
    flex-shrink: 0;
}
#ai-chat-send:disabled::after { opacity: 0.5; }

/* ===== Аватар пользователя в поле ввода ===== */
.ai-user-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    flex-shrink: 0;
}
.ai-user-icon svg {
    width: 18px;
    height: 18px;
}

/* ===== Мобильная адаптация ===== */
@media (max-width: 480px) {
    #ai-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: none;
        min-height: 0;
        border-radius: 0;
    }
}
