/* =========================================================
   Conversational Lead Engine — Widget Styles
   ========================================================= */

:root {
    --cle-primary:       #1a5276;
    --cle-primary-dark:  #154360;
    --cle-secondary:     #2980b9;
    --cle-white:         #ffffff;
    --cle-light:         #f4f6f8;
    --cle-light-2:       #eaf0f6;
    --cle-border:        #dde3ea;
    --cle-text:          #1c2733;
    --cle-text-muted:    #8898a4;
    --cle-shadow:        0 8px 32px rgba(26,82,118,.22);
    --cle-radius:        18px;
    --cle-radius-sm:     10px;
    --cle-font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --cle-widget-w:      370px;
    --cle-widget-h:      560px;
    --cle-z:             999999;
}

/* ── Widget Container ──────────────────────────────────── */
#cle-widget { position: fixed; z-index: var(--cle-z); font-family: var(--cle-font); }
.cle-pos-bottom-right { bottom: 24px; right: 24px; }
.cle-pos-bottom-left  { bottom: 24px; left:  24px; }
.cle-pos-top-right    { top:    24px; right: 24px; }
.cle-pos-top-left     { top:    24px; left:  24px; }

/* ── Trigger Button ────────────────────────────────────── */
.cle-trigger-btn {
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--cle-primary);
    color: #fff; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(26,82,118,.45);
    transition: transform .2s, box-shadow .2s;
    position: relative;
}
.cle-trigger-btn:hover { transform: scale(1.1); box-shadow: 0 6px 28px rgba(26,82,118,.55); }
.cle-trigger-icon { display: flex; }

.cle-unread-badge {
    position: absolute; top: -4px; right: -4px;
    background: #e74c3c; color: #fff; font-size: 11px;
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; border: 2px solid #fff;
}

/* ── Chat Window ───────────────────────────────────────── */
.cle-chat-window {
    position: absolute; bottom: 74px; right: 0;
    width: var(--cle-widget-w);
    height: var(--cle-widget-h);
    background: var(--cle-white);
    border-radius: var(--cle-radius);
    box-shadow: var(--cle-shadow);
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: cle-slide-up .25s ease;
}

.cle-pos-bottom-left  .cle-chat-window { right: auto; left: 0; }
.cle-pos-top-right    .cle-chat-window { bottom: auto; top: 74px; }
.cle-pos-top-left     .cle-chat-window { bottom: auto; top: 74px; right: auto; left: 0; }

@keyframes cle-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ────────────────────────────────────────────── */
.cle-chat-header {
    background: linear-gradient(135deg, var(--cle-primary), var(--cle-secondary));
    color: #fff; padding: 14px 16px;
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
}
.cle-chat-header-avatar {
    font-size: 28px; width: 42px; height: 42px;
    background: rgba(255,255,255,.18); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.cle-chat-header-info { flex: 1; min-width: 0; }
.cle-chat-header-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.cle-chat-header-status {
    font-size: 12px; opacity: .85;
    display: flex; align-items: center; gap: 5px; margin-top: 2px;
}
.cle-status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #2ecc71; display: inline-block;
    animation: cle-pulse 2s infinite;
}
@keyframes cle-pulse {
    0%,100% { opacity: 1; } 50% { opacity: .5; }
}
.cle-chat-close-btn {
    background: none; border: none; color: rgba(255,255,255,.8);
    cursor: pointer; padding: 4px; border-radius: 6px;
    display: flex; transition: background .15s;
}
.cle-chat-close-btn:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ── Messages ──────────────────────────────────────────── */
.cle-messages {
    flex: 1; overflow-y: auto; padding: 16px 14px;
    background: var(--cle-light);
    scroll-behavior: smooth;
}
.cle-messages-inner { display: flex; flex-direction: column; gap: 10px; }

.cle-msg { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.cle-msg-bot  { justify-content: flex-start; }
.cle-msg-user { justify-content: flex-end; }

.cle-msg-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--cle-white); font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

.cle-msg-bubble-wrap { max-width: 78%; display: flex; flex-direction: column; }

.cle-msg-bubble {
    padding: 10px 14px; border-radius: 16px;
    font-size: 14px; line-height: 1.5;
    word-wrap: break-word;
}
.cle-msg-bot  .cle-msg-bubble {
    background: var(--cle-white);
    color: var(--cle-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.cle-msg-user .cle-msg-bubble {
    background: var(--cle-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}
.cle-msg-time {
    font-size: 11px; color: var(--cle-text-muted);
    margin-top: 3px; padding: 0 4px;
}
.cle-msg-user .cle-msg-time { text-align: right; }

/* ── Typing Indicator ──────────────────────────────────── */
.cle-typing-indicator {
    padding: 10px 20px;
    display: flex; align-items: center; gap: 4px;
    background: var(--cle-light);
}
.cle-typing-indicator span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--cle-text-muted);
    animation: cle-bounce .9s infinite;
}
.cle-typing-indicator span:nth-child(2) { animation-delay: .15s; }
.cle-typing-indicator span:nth-child(3) { animation-delay: .30s; }
@keyframes cle-bounce {
    0%,80%,100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ── Quick Replies ─────────────────────────────────────── */
.cle-quick-replies {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 4px 0;
}
.cle-qr-btn {
    background: var(--cle-white); border: 1.5px solid var(--cle-secondary);
    color: var(--cle-secondary); border-radius: 20px;
    padding: 7px 16px; font-size: 13px; cursor: pointer;
    font-family: var(--cle-font); font-weight: 500;
    transition: all .15s;
}
.cle-qr-btn:hover {
    background: var(--cle-secondary); color: #fff;
    transform: translateY(-1px);
}

/* ── Step Input Area ───────────────────────────────────── */
.cle-step-input {
    background: var(--cle-light-2);
    border-top: 1px solid var(--cle-border);
    padding: 12px 14px;
    flex-shrink: 0; max-height: 220px; overflow-y: auto;
}

.cle-step-form {
    display: flex; flex-direction: column; gap: 10px;
}

.cle-text-input, .cle-select {
    width: 100%; padding: 10px 12px;
    border: 1.5px solid var(--cle-border); border-radius: var(--cle-radius-sm);
    font-size: 14px; font-family: var(--cle-font); color: var(--cle-text);
    background: var(--cle-white); box-sizing: border-box;
    transition: border-color .15s;
}
.cle-text-input:focus, .cle-select:focus {
    outline: none; border-color: var(--cle-secondary);
    box-shadow: 0 0 0 3px rgba(41,128,185,.12);
}
.cle-text-input.cle-error { border-color: #e74c3c; }

.cle-step-submit-btn {
    background: var(--cle-primary); color: #fff;
    border: none; border-radius: var(--cle-radius-sm);
    padding: 10px 20px; font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: var(--cle-font);
    transition: background .15s, transform .1s;
}
.cle-step-submit-btn:hover { background: var(--cle-primary-dark); transform: translateY(-1px); }

.cle-checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.cle-checkbox-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 14px; cursor: pointer; color: var(--cle-text);
}
.cle-checkbox-label input { width: 16px; height: 16px; accent-color: var(--cle-primary); }

.cle-file-label {
    display: block; border: 2px dashed var(--cle-border);
    border-radius: var(--cle-radius-sm); padding: 16px;
    text-align: center; cursor: pointer; font-size: 13px;
    color: var(--cle-text-muted); transition: border-color .15s;
}
.cle-file-label:hover { border-color: var(--cle-secondary); color: var(--cle-secondary); }
.cle-file-input-hidden { display: none; }

/* ── Free-text Input ───────────────────────────────────── */
.cle-free-input {
    padding: 10px 12px;
    border-top: 1px solid var(--cle-border);
    background: var(--cle-white);
    flex-shrink: 0;
}
.cle-input-wrapper { display: flex; align-items: flex-end; gap: 8px; }
.cle-honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.cle-message-input {
    flex: 1; resize: none; border: 1.5px solid var(--cle-border);
    border-radius: 20px; padding: 9px 14px;
    font-size: 14px; font-family: var(--cle-font); color: var(--cle-text);
    line-height: 1.5; max-height: 120px; overflow-y: auto;
    transition: border-color .15s;
}
.cle-message-input:focus { outline: none; border-color: var(--cle-secondary); }
.cle-message-input::placeholder { color: var(--cle-text-muted); }

.cle-send-btn {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--cle-primary); color: #fff;
    border: none; cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, transform .1s;
}
.cle-send-btn:hover { background: var(--cle-primary-dark); transform: scale(1.08); }

/* ── Footer ────────────────────────────────────────────── */
.cle-chat-footer {
    text-align: center; font-size: 11px; color: var(--cle-text-muted);
    padding: 6px; border-top: 1px solid var(--cle-border);
    background: var(--cle-white); flex-shrink: 0;
}

/* ── Completion ────────────────────────────────────────── */
.cle-completion-actions { padding: 8px 0; }

/* ── Scrollbar ─────────────────────────────────────────── */
.cle-messages::-webkit-scrollbar { width: 4px; }
.cle-messages::-webkit-scrollbar-track { background: transparent; }
.cle-messages::-webkit-scrollbar-thumb { background: var(--cle-border); border-radius: 4px; }

/* ── Mobile Responsive ─────────────────────────────────── */
@media (max-width: 480px) {
    .cle-chat-window {
        position: fixed !important;
        bottom: 0 !important; left: 0 !important; right: 0 !important;
        width: 100vw !important; height: 92vh !important;
        border-radius: var(--cle-radius) var(--cle-radius) 0 0;
        max-height: 92vh;
    }
    .cle-pos-bottom-left  .cle-trigger-btn,
    .cle-pos-bottom-right .cle-trigger-btn { bottom: 16px; }
}
