/* ═══════════════════════════════════════════
   ElevatorChat Pro – Frontend CSS v3.1
═══════════════════════════════════════════ */
#ec-root * { box-sizing: border-box; /*margin: 0; padding: 0;*/ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
#ec-root { --p: #1a56db; --pd: #1245a8; --pl: rgba(26,86,219,.1); z-index: 999999; }

/* ── FAB Button ── */
#ec-fab {
    position: fixed; bottom: 24px; right: 24px;
    width: 58px; height: 58px; border-radius: 50%;
    background: var(--p); color: #fff;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(26,86,219,.45);
    transition: transform .25s, box-shadow .25s;
    z-index: 999999;
}
/* Pulse */
#ec-fab::before { content:''; position:absolute; inset:0; border-radius:50%; background:var(--p); opacity:.35; animation:ec-pulse 2.4s ease-out infinite; }
#ec-fab.open::before { display:none; }
@keyframes ec-pulse { 0%{transform:scale(1);opacity:.35} 70%,100%{transform:scale(1.75);opacity:0} }

#ec-fab.left { right: auto; left: 24px; }
#ec-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(26,86,219,.55); }
#ec-fab svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: opacity .2s, transform .2s; }
#ec-fab .ic-close { opacity: 0; position: absolute; transform: rotate(-90deg); }
#ec-fab.open .ic-chat  { opacity: 0; transform: rotate(90deg); }
#ec-fab.open .ic-close { opacity: 1; transform: rotate(0); }
#ec-badge {
    position: absolute; top: -4px; right: -4px;
    background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff; display: none;
}

/* ── Widget Window ── */
#ec-win {
    position: fixed; bottom: 96px; right: 24px;
    width: 385px; height: 610px;
    background: #fff; border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
    display: flex; flex-direction: column; overflow: hidden;
    transform: scale(.92) translateY(20px);
    opacity: 0; pointer-events: none;
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s;
    z-index: 999998;
}
#ec-win.left   { right: auto; left: 24px; }
#ec-win.open   { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

/* ── Header ── */
#ec-header {
    background: var(--p);
    padding: 13px 16px;
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}
#ec-av {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0; overflow: hidden;
}
#ec-av img { width: 100%; height: 100%; object-fit: cover; }
#ec-bot-name   { color: #fff; font-weight: 700; font-size: 15px; }
#ec-bot-status { color: rgba(255,255,255,.8); font-size: 11.5px; margin-top: 2px; display: flex; align-items: center; gap: 5px; }
#ec-bot-status::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }
#ec-header-close {
    margin-left: auto; 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 .15s; flex-shrink: 0;
}
#ec-header-close:hover { background: rgba(255,255,255,.35); }

/* Outside hours banner */
#ec-outside-banner { background: #fef3c7; color: #92400e; font-size: 12.5px; padding: 7px 14px; text-align: center; display: none; }

/* ── Tab Nav ── */
#ec-tabs { display: flex; background: #f9fafb; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }
.ec-tab-btn {
    flex: 1; padding: 10px 4px; border: none; background: none;
    font-size: 12.5px; font-weight: 600; color: #6b7280;
    cursor: pointer; border-bottom: 2.5px solid transparent;
    transition: all .18s; white-space: nowrap;
}
.ec-tab-btn:hover  { color: var(--p); }
.ec-tab-btn.active { color: var(--p); border-bottom-color: var(--p); background: rgba(26,86,219,.04); }

/* ── Panes ── */
.ec-pane {
    display: none; flex: 1; flex-direction: column;
    overflow: hidden; min-height: 0;
}
.ec-pane.active { display: flex; }

/* ═══════════════════════════════════════════
   CHAT PANE
═══════════════════════════════════════════ */
#ec-messages {
    flex: 1; overflow-y: auto; padding: 12px 14px;
    display: flex; flex-direction: column; gap: 10px;
    scroll-behavior: smooth;
}
#ec-messages::-webkit-scrollbar { width: 4px; }
#ec-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* Messages */
.ec-msg { display: flex; gap: 8px; animation: fadeUp .2s ease; max-width: 100%; }
.ec-msg.user { flex-direction: row-reverse; }
@keyframes fadeUp { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

.ec-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--p); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; overflow: hidden; margin-top: 2px; }
.ec-avatar img { width: 100%; height: 100%; object-fit: cover; }

.ec-bubble {
    max-width: 78%; padding: 9px 13px; border-radius: 14px;
    font-size: 13.5px; line-height: 1.55; word-break: break-word;
}
.ec-msg.bot  .ec-bubble { background: #f3f4f6; color: #111827; border-radius: 3px 14px 14px 14px; }
.ec-msg.user .ec-bubble { background: var(--p); color: #fff; border-radius: 14px 3px 14px 14px; }
.ec-bubble strong { font-weight: 700; }
.ec-bubble em { font-style: italic; }
.ec-bubble br { display: block; content: ''; margin: 3px 0; }

/* Typing indicator */
.ec-typing { display: flex; align-items: center; gap: 5px; padding: 10px 13px; background: #f3f4f6; border-radius: 3px 14px 14px 14px; max-width: 60px; }
.ec-typing span { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; animation: bounce .9s infinite; }
.ec-typing span:nth-child(2) { animation-delay: .15s; }
.ec-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform:none; } 30% { transform:translateY(-5px); } }

/* Quick Replies */
#ec-qr-row { padding: 6px 12px 4px; display: flex; flex-wrap: wrap; gap: 5px; flex-shrink: 0; }
.ec-qr {
    background: none; border: 1.5px solid var(--p); color: var(--p);
    border-radius: 16px; padding: 5px 13px; font-size: 12.5px; font-weight: 600;
    cursor: pointer; transition: all .18s; white-space: nowrap;
}
.ec-qr:hover { background: var(--p); color: #fff; }

/* Lead prompt */
#ec-lead-prompt {
    margin: 4px 12px 4px; padding: 9px;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1.5px solid #bfdbfe; border-radius: 8px;
    color: var(--p); font-size: 13px; font-weight: 700;
    cursor: pointer; text-align: center; transition: all .18s;
    display: none; flex-shrink: 0;
}
#ec-lead-prompt:hover { background: var(--p); color: #fff; border-color: var(--p); }

/* Input bar */
#ec-input-bar { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #f3f4f6; flex-shrink: 0; align-items: flex-end; }
#ec-input {
    flex: 1; border: 1.5px solid #e5e7eb; border-radius: 22px;
    padding: 9px 14px; font-size: 13.5px; resize: none; font-family: inherit;
    outline: none; transition: border-color .15s; max-height: 100px; line-height: 1.45;
    scrollbar-width: thin;
}
#ec-input:focus { border-color: var(--p); box-shadow: 0 0 0 3px rgba(26,86,219,.1); }
#ec-send {
    width: 38px; height: 38px; border-radius: 50%; background: var(--p);
    border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background .18s;
}
#ec-send:hover { background: var(--pd); }
#ec-send:disabled { background: #d1d5db; cursor: not-allowed; }
#ec-send svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ═══════════════════════════════════════════
   QUOTE PANE
═══════════════════════════════════════════ */
#ec-pane-quote {
    overflow-y: auto; padding: 14px 14px 10px;
    flex-direction: column; gap: 8px;
    scrollbar-width: thin;
}
.ec-qf-title { font-size: 15px; font-weight: 800; color: #111827; margin-bottom: 3px; }
.ec-qf-sub   { font-size: 12.5px; color: #6b7280; margin-bottom: 4px; }
.ec-grid2    { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ec-field    { display: flex; flex-direction: column; gap: 3px; }
.ec-field label { font-size: 12px; font-weight: 700; color: #374151; }
.ec-field label span { color: #ef4444; }
.ec-fi {
    padding: 8px 10px; border: 1.5px solid #e5e7eb; border-radius: 7px;
    font-size: 13px; font-family: inherit; outline: none; width: 100%; transition: border-color .15s;
}
.ec-fi:focus { border-color: var(--p); box-shadow: 0 0 0 3px rgba(26,86,219,.1); }
.ec-fi.err   { border-color: #ef4444; }
.ec-gdpr     { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: #6b7280; cursor: pointer; }
.ec-gdpr input { margin-top: 2px; flex-shrink: 0; }
.ec-form-err { font-size: 12.5px; color: #ef4444; min-height: 16px; }
#ec-qf-submit {
    width: 100%; padding: 11px; background: var(--p); color: #fff;
    border: none; border-radius: 9px; font-size: 14px; font-weight: 700;
    cursor: pointer; transition: background .18s; font-family: inherit;
}
#ec-qf-submit:hover    { background: var(--pd); }
#ec-qf-submit:disabled { background: #d1d5db; cursor: not-allowed; }

/* ═══════════════════════════════════════════
   FAQ PANE
═══════════════════════════════════════════ */
#ec-pane-faq { flex-direction: column; }
.ec-faq-search-wrap { padding: 10px 12px 6px; flex-shrink: 0; }
.ec-faq-search {
    width: 100%; padding: 8px 12px; border: 1.5px solid #e5e7eb;
    border-radius: 22px; font-size: 13px; font-family: inherit; outline: none;
    transition: border-color .15s;
}
.ec-faq-search:focus { border-color: var(--p); }
.ec-faq-cats { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 12px 8px; overflow-x: auto; flex-shrink: 0; scrollbar-width: none; }
.ec-faq-cats::-webkit-scrollbar { display: none; }
.ec-cat-btn {
    padding: 4px 12px; border: 1.5px solid #e5e7eb; background: #fff;
    border-radius: 14px; font-size: 12px; font-weight: 600; color: #6b7280;
    cursor: pointer; white-space: nowrap; transition: all .15s; flex-shrink: 0;
}
.ec-cat-btn:hover  { border-color: var(--p); color: var(--p); }
.ec-cat-btn.active { background: var(--p); border-color: var(--p); color: #fff; }
.ec-faq-list { flex: 1; overflow-y: auto; padding: 0 12px 12px; scrollbar-width: thin; }
.ec-faq-item { border: 1px solid #e5e7eb; border-radius: 9px; margin-bottom: 7px; overflow: hidden; transition: border-color .15s; }
.ec-faq-item:hover { border-color: #bfdbfe; }
.ec-faq-q {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; font-size: 13px; font-weight: 700; cursor: pointer;
    color: #111827; gap: 8px; background: #fff; transition: background .15s;
    user-select: none;
}
.ec-faq-item.open .ec-faq-q { background: var(--pl); color: var(--p); }
.ec-faq-arrow { font-size: 11px; flex-shrink: 0; transition: transform .2s; color: #9ca3af; }
.ec-faq-item.open .ec-faq-arrow { transform: rotate(180deg); color: var(--p); }
.ec-faq-a { display: none; padding: 0 12px 10px; font-size: 13px; color: #374151; line-height: 1.6; }
.ec-faq-item.open .ec-faq-a { display: block; }
.ec-faq-use {
    margin-top: 8px; display: inline-block;
    background: none; border: 1.5px solid var(--p); color: var(--p);
    border-radius: 6px; padding: 4px 11px; font-size: 12px; font-weight: 700;
    cursor: pointer; transition: all .15s; font-family: inherit;
}
.ec-faq-use:hover { background: var(--p); color: #fff; }

/* ── Success overlay ── */
#ec-success {
    position: absolute; inset: 0; background: #fff;
    display: none; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 30px; text-align: center;
    animation: fadeUp .3s ease;
}
#ec-success.show { display: flex; }
.ec-success-icon { font-size: 56px; margin-bottom: 14px; }
.ec-success-title { font-size: 18px; font-weight: 800; color: #111827; margin-bottom: 8px; }
.ec-success-msg   { font-size: 13.5px; color: #6b7280; line-height: 1.6; margin-bottom: 18px; }
.ec-success-back  { background: var(--p); color: #fff; border: none; padding: 10px 22px; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit; }

/* ── Mobile ── */
@media (max-width: 480px) {
    #ec-win {
        width: 100vw; height: 100vh; height: 100dvh;
        bottom: 0; right: 0; left: 0; border-radius: 0;
    }
    #ec-win.left { left: 0; right: 0; }
    #ec-fab { bottom: 16px; right: 16px; }
    #ec-fab.left { right: auto; left: 16px; }
    .ec-grid2 { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════
   v4.0 – Lead Capture Popup
═══════════════════════════════════════ */
#ec-capture-popup {
    background: #fff;
    border: 2px solid var(--p);
    border-radius: 14px;
    padding: 14px 16px;
    margin: 8px 0;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,.12);
}
#ec-capture-inner { display: flex; flex-direction: column; gap: 6px; }
#ec-capture-close {
    position: absolute; top: 8px; right: 10px;
    background: none; border: none; font-size: 14px; color: #9ca3af; cursor: pointer; line-height: 1; padding: 2px;
}
#ec-capture-title { font-weight: 800; font-size: 14px; color: #111827; }
#ec-capture-sub   { font-size: 12.5px; color: #6b7280; margin-top: -2px; }
#ec-capture-popup .ec-fi {
    width: 100%; padding: 8px 10px; border: 1.5px solid #e5e7eb; border-radius: 8px;
    font-size: 13.5px; outline: none; box-sizing: border-box; font-family: inherit;
}
#ec-capture-popup .ec-fi:focus { border-color: var(--p); }

/* ═══════════════════════════════════════
   v4.0 – Staff / System messages
═══════════════════════════════════════ */
.ec-msg.staff { justify-content: flex-end; }
.ec-staff-av {
    width: 32px; height: 32px; border-radius: 50%; background: #7c3aed;
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; flex-shrink: 0;
}
.ec-bubble-staff {
    background: #ede9fe !important;
    border: 1.5px solid #c4b5fd !important;
    color: #4c1d95 !important;
}
.ec-staff-label {
    font-size: 10.5px; font-weight: 800; color: #7c3aed; margin-bottom: 3px;
}
.ec-msg.staff .ec-bubble { background: #ede9fe; border: 1.5px solid #c4b5fd; }

.ec-msg.ec-sys-msg {
    justify-content: center; margin: 4px 0;
}
.ec-msg.ec-sys-msg span {
    background: #f3f4f6; border-radius: 20px; padding: 4px 12px;
    font-size: 11.5px; color: #6b7280; display: inline-block;
}

/* Bot status update for staff */
#ec-bot-status { transition: color .3s; }
