/* ── Chat Widget ─────────────────────────────────────────── */

#chat-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2c5f2e, #4a9e4e);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    z-index: 9999999;
    transition: transform 0.2s, box-shadow 0.2s;
}

#chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(0,0,0,0.32);
}

#chat-bubble .chat-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}

/* ── Chat Window ─────────────────────────────────────────── */

#chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 340px;
    max-width: calc(100vw - 40px);
    height: 480px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
    display: flex;
    flex-direction: column;
    z-index: 9999998;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

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

/* Header */
#chat-header {
    background: linear-gradient(135deg, #2c5f2e, #4a9e4e);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#chat-header .chat-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: 20px;
}

#chat-header .chat-title {
    flex: 1;
}

#chat-header .chat-title strong {
    display: block;
    font-size: 15px;
}

#chat-header .chat-title span {
    font-size: 12px;
    opacity: 0.85;
}

#chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}

#chat-close:hover { opacity: 1; }

/* Messages */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f8fa;
}

.chat-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg.bot {
    background: #fff;
    color: #222;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.chat-msg.user {
    background: linear-gradient(135deg, #2c5f2e, #4a9e4e);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.chat-typing span {
    width: 8px;
    height: 8px;
    background: #aaa;
    border-radius: 50%;
    animation: chatBounce 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%            { transform: translateY(-6px); }
}

/* Input area */
#chat-input-area {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e8e8e8;
    background: #fff;
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 22px;
    padding: 9px 14px;
    font-size: 14px;
    outline: none;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color 0.2s;
}

#chat-input:focus { border-color: #4a9e4e; }

#chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2c5f2e, #4a9e4e);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: transform 0.15s;
}

#chat-send:hover { transform: scale(1.1); }
#chat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Mobile */
@media (max-width: 480px) {
    #chat-window {
        right: 12px;
        bottom: 90px;
        width: calc(100vw - 24px);
    }
    #chat-bubble {
        right: 16px;
        bottom: 20px;
    }
}
