/* ── Widget wrapper ── */
#ai-chatbot-widget {
    position: fixed;
    bottom: 16px;
    right: 28px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* ── Floating toggle (hidden when chat open) ── */
#chatbot-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #F3FE00;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(243,254,0,0.35);
    transition: transform 0.2s, box-shadow 0.2s;
    color: #0D0D0D;
    flex-shrink: 0;
}
#chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(243,254,0,0.5);
}
#ai-chatbot-widget.chat-open #chatbot-toggle { display: none; }

/* ── Chat box ── */
#chatbot-box {
    display: none;
    width: 380px;
    height: 520px;
    background: #181818;
    border: 1px solid #2e2e2e;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 48px rgba(0,0,0,0.55);
    animation: chatSlideUp 0.25s ease;
    position: relative;
}
#ai-chatbot-widget.chat-open #chatbot-box { display: flex; }

@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Sidebar ── */
#chatbot-sidebar {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 220px;
    background: #111;
    border-right: 1px solid #2e2e2e;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 10;
}
#chatbot-sidebar.open { transform: translateX(0); }

#chatbot-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 10px;
    border-bottom: 1px solid #2e2e2e;
}
#chatbot-sidebar-header span {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}
#chatbot-sidebar-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 2px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}
#chatbot-sidebar-close:hover { color: #fff; }

#chatbot-new-chat-btn {
    margin: 10px 10px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #F3FE00;
    color: #0D0D0D;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    font-family: 'Inter', sans-serif;
}
#chatbot-new-chat-btn:hover { opacity: 0.85; }

#chatbot-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}
.chat-history-item {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    color: #aaa;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s, color 0.15s;
}
.chat-history-item:hover,
.chat-history-item.active {
    background: #252525;
    color: #fff;
}

/* ── Main chat area ── */
#chatbot-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: #111;
    border-bottom: 1px solid #2e2e2e;
    flex-shrink: 0;
}
.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
#chatbot-sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
    flex-shrink: 0;
}
#chatbot-sidebar-toggle:hover { color: #F3FE00; }

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #F3FE00;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0D0D0D;
    flex-shrink: 0;
}
.chatbot-name {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}
.chatbot-status {
    margin: 0;
    font-size: 11px;
    color: #4ade80;
    line-height: 1.3;
}
#chatbot-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}
#chatbot-close-btn:hover { color: #fff; }

/* ── Messages ── */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}
#chatbot-messages::-webkit-scrollbar { width: 4px; }
#chatbot-messages::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.chat-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.55;
}
.chat-msg p { margin: 0; }
.chat-msg.bot {
    background: #252525;
    color: #e0e0e0;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-msg.user {
    background: #F3FE00;
    color: #0D0D0D;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}
.chat-msg.typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    margin: 0 2px;
    animation: typingDot 1.2s infinite;
}
.chat-msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-msg.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ── */
#chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #2e2e2e;
    background: #111;
    flex-shrink: 0;
}
#chatbot-input {
    flex: 1;
    background: #252525;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 9px 12px;
    color: #fff;
    font-size: 13px;
    outline: none;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s;
}
#chatbot-input:focus { border-color: #F3FE00; }
#chatbot-input::placeholder { color: #555; }
#chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #F3FE00;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0D0D0D;
    flex-shrink: 0;
    transition: opacity 0.2s;
}
#chatbot-send:hover { opacity: 0.85; }

@media (max-width: 480px) {
    #ai-chatbot-widget { bottom: 16px; right: 16px; }
    #chatbot-box { width: calc(100vw - 32px); height: 480px; }
    #chatbot-sidebar { width: 200px; }
}

/* ── Links inside bot messages ── */
.chat-msg.bot a {
    color: #F3FE00;
    text-decoration: underline;
    word-break: break-all;
}
.chat-msg.bot a:hover {
    opacity: 0.8;
}
.chat-msg.bot strong {
    color: #fff;
    font-weight: 600;
}

/* ── Inline email capture form ── */
.chatbot-email-form {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chatbot-email-input {
    background: #1e1e1e;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 8px 12px;
    color: #fff;
    font-size: 13px;
    outline: none;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s;
}
.chatbot-email-input:focus { border-color: #F3FE00; }
.chatbot-email-input::placeholder { color: #555; }
.chatbot-email-submit {
    padding: 8px 14px;
    background: #F3FE00;
    color: #0D0D0D;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: opacity 0.2s;
    align-self: flex-start;
}
.chatbot-email-submit:hover { opacity: 0.85; }
.chatbot-email-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.chatbot-email-note {
    margin: 0;
    font-size: 11px;
}
.chatbot-email-success {
    margin: 0;
    font-size: 13px;
    color: #4ade80;
}
.chatbot-email-success strong { color: #fff; }
