/* ============================================================
   Camel AI Chatbot – Frontend Widget Styles
   ============================================================ */

#camel-chatbot-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── TOGGLE BUTTON ── */
#camel-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(0,0,0,0.22);
    transition: transform .2s, box-shadow .2s;
    position: relative;
}
#camel-chat-toggle:hover { transform: scale(1.08); box-shadow: 0 8px 32px rgba(0,0,0,0.28); }
#camel-chat-toggle:active { transform: scale(0.96); }
/* Robot icon — white parts via CSS, colored parts inline */
.camel-toggle-icon { display: flex; align-items: center; justify-content: center; }
.camel-toggle-icon svg { width: 38px; height: 38px; }
.camel-notif-badge {
    position: absolute;
    top: -2px; right: -2px;
    width: 20px; height: 20px;
    background: #e53935; color: #fff;
    border-radius: 50%; border: 2px solid #fff;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* ── CHAT WINDOW ── */
#camel-chat-window {
    position: absolute;
    bottom: 76px; right: 0;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
    animation: camelSlideUp .25s cubic-bezier(.34,1.56,.64,1);
}
#camel-chat-window.camel-open { display: flex; }

@keyframes camelSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 420px) {
    #camel-chatbot-container { bottom: 16px; right: 16px; }
    #camel-chat-window { width: calc(100vw - 32px); height: 80vh; }
}

/* ── HEADER ── */
.camel-chat-header {
    padding: 12px 16px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.camel-chat-header-left { display: flex; align-items: center; gap: 10px; }
.camel-bot-avatar {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.2); border-radius: 50%;
    flex-shrink: 0;
}
.camel-bot-avatar svg { width: 30px; height: 30px; }
.camel-bot-info strong { display: block; color: #fff; font-size: 14px; font-weight: 600; }
.camel-bot-info small { color: rgba(255,255,255,.82); font-size: 12px; }
.camel-bot-info a:hover { text-decoration: underline; }

.camel-chat-header-right { display: flex; align-items: center; gap: 10px; }
.camel-online-dot { width: 9px; height: 9px; background: #76ff03; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.4); }
.camel-close-btn {
    background: rgba(255,255,255,.2); border: none; color: #fff;
    width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
    font-size: 14px; display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
.camel-close-btn:hover { background: rgba(255,255,255,.35); }

/* ── MESSAGES — fixed height + scroll ── */
.camel-messages {
    flex: 1;
    min-height: 0;          /* critical for flex scroll */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
    background: #f6faf7;
    scroll-behavior: smooth;
}
.camel-messages::-webkit-scrollbar { width: 4px; }
.camel-messages::-webkit-scrollbar-track { background: transparent; }
.camel-messages::-webkit-scrollbar-thumb { background: #cde0d1; border-radius: 2px; }

/* ── MESSAGE BUBBLES ── */
.camel-msg { max-width: 82%; display: flex; flex-direction: column; gap: 2px; animation: camelMsgIn .2s ease; }
@keyframes camelMsgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.camel-msg-bot  { align-self: flex-start; }
.camel-msg-user { align-self: flex-end; }

.camel-bubble {
    padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.5;
    word-wrap: break-word; white-space: pre-wrap;
}
.camel-msg-bot  .camel-bubble { background: #fff; color: #1e1e1e; border-radius: 4px 16px 16px 16px; box-shadow: 0 1px 4px rgba(0,0,0,.08); border: 1px solid #e8f2ea; }
.camel-msg-user .camel-bubble { color: #fff; border-radius: 16px 16px 4px 16px; background: var(--camel-accent); }

.camel-msg-time { font-size: 10px; color: #aaa; padding: 0 4px; }
.camel-msg-user .camel-msg-time { text-align: right; }

/* ── TYPING INDICATOR ── */
.camel-typing { align-self: flex-start; }
.camel-typing .camel-bubble { background: #fff; border: 1px solid #e8f2ea; padding: 12px 16px; }
.camel-dots { display: flex; gap: 4px; align-items: center; }
.camel-dot { width: 7px; height: 7px; background: #aaa; border-radius: 50%; animation: camelDot 1.2s infinite; }
.camel-dot:nth-child(2) { animation-delay: .2s; }
.camel-dot:nth-child(3) { animation-delay: .4s; }
@keyframes camelDot { 0%,80%,100% { transform: scale(.8); opacity: .5; } 40% { transform: scale(1.2); opacity: 1; } }

/* lead form styles moved to bottom */

/* ── INPUT AREA ── */
.camel-input-area { border-top: 1px solid #e8f2ea; background: #fff; padding: 10px 12px; flex-shrink: 0; }
.camel-quick-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.camel-quick-btn {
    padding: 4px 10px; border: 1.5px solid var(--camel-accent); border-radius: 20px;
    background: #fff; color: var(--camel-accent); font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all .15s; white-space: nowrap;
}
.camel-quick-btn:hover { background: var(--camel-accent); color: #fff; }

.camel-input-row { display: flex; align-items: flex-end; gap: 8px; }
#camelInput {
    flex: 1; padding: 9px 12px; border: 1.5px solid #d5e8d9; border-radius: 12px;
    font-size: 13.5px; resize: none; font-family: inherit; line-height: 1.4;
    max-height: 100px; overflow-y: auto; transition: border-color .2s;
}
#camelInput:focus { outline: none; border-color: var(--camel-accent); box-shadow: 0 0 0 3px var(--camel-accent-light); }
#camelSendBtn {
    width: 40px; height: 40px; border: none; border-radius: 10px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: opacity .2s, transform .15s;
}
#camelSendBtn:hover { opacity: .88; transform: scale(1.05); }
#camelSendBtn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
#camelSendBtn svg { width: 17px; height: 17px; }

.camel-powered-by { margin: 7px 0 0; text-align: center; font-size: 11px; color: #aaa; }
.camel-powered-by a { color: inherit; text-decoration: none; }
.camel-powered-by a:hover { text-decoration: underline; }



/* ── LEAD FORM AS CHAT BUBBLE ── */
.camel-msg-form { max-width: 96% !important; width: 96%; }

.camel-lead-card {
    background: #fff;
    border: 1.5px solid #d5e8d9;
    border-radius: 4px 14px 14px 14px;
    padding: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    width: 100%;
    box-sizing: border-box;
}
.camel-lead-card-title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: #1e1e1e;
}
.camel-lead-card .camel-form-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}
.camel-lead-card .camel-form-row .camel-form-input {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
    padding: 7px 8px;
    font-size: 12.5px;
    border-radius: 6px;
}
.camel-lead-btns {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.camel-lead-btns .camel-lead-submit-btn {
    flex: 1;
    padding: 7px 10px;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.camel-lead-btns .camel-lead-skip-btn {
    padding: 7px 10px;
    border: 1.5px solid #d5e8d9;
    border-radius: 6px;
    background: #fff;
    font-size: 12.5px;
    color: #6b7c73;
    cursor: pointer;
    white-space: nowrap;
}
.camel-lead-success {
    font-size: 13px;
    color: #1d5a28;
    padding: 4px 0;
}
.camel-lead-skipped {
    font-size: 12.5px;
    color: #6b7c73;
    font-style: italic;
}

/* ── WELCOME POPUP BUBBLE ── */
#camel-welcome-bubble {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 240px;
    z-index: 100000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    transition: opacity .25s ease, transform .25s ease;
}
#camel-welcome-bubble.camel-bubble-show {
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0) scale(1);
}
.camel-bubble-inner {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.13);
    border: 1px solid #ddeee1;
    padding: 11px 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    position: relative;
}
.camel-bubble-text {
    flex: 1;
    min-width: 0;
}
.camel-bubble-text strong {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: #1a3a24;
    margin-bottom: 3px;
    line-height: 1.3;
}
.camel-bubble-text span {
    display: block;
    font-size: 12px;
    color: #4a6a52;
    line-height: 1.4;
    word-break: break-word;
}
.camel-bubble-close {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    min-height: 16px !important;
    background: #eef4f0 !important;
    border: none !important;
    border-radius: 50% !important;
    font-size: 10px !important;
    line-height: 16px !important;
    color: #888 !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: none !important;
    text-transform: none !important;
    font-weight: normal !important;
    letter-spacing: 0 !important;
}
.camel-bubble-close:hover {
    background: #d5e8d9 !important;
    color: #333 !important;
}
.camel-bubble-arrow {
    width: 12px;
    height: 12px;
    background: #fff;
    border-right: 1px solid #ddeee1;
    border-bottom: 1px solid #ddeee1;
    transform: rotate(45deg);
    position: absolute;
    bottom: -6px;
    right: 24px;
}

/* Hard reset all chatbot container buttons from theme styles */
#camel-chatbot-container button {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#camel-chatbot-container #camel-welcome-bubble {
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#camel-chatbot-container #camel-welcome-bubble.camel-bubble-show {
    display: block;
}
