/* ── Enquiry Chatbot — Public widget ─────────────────────────────── */

:root {
    --ecb-primary: #0f172a;
    --ecb-bubble:  #f1f5f9;
    --ecb-user:    #0f172a;
    --ecb-accent:  #6366f1;
}

/* ── Floating trigger button ────────────────────────────────────── */
#ecb-trigger {
    position: fixed;
    width: 60px; height: 60px;
    border-radius: 50%;
    background: var(--ecb-primary);
    color: #fff;
    border: none; cursor: pointer;
    box-shadow: 0 4px 24px rgba(0,0,0,.3);
    display: flex; align-items: center; justify-content: center;
    z-index: 99997;
    transition: transform .25s, opacity .3s;
    padding: 0; line-height: 1;
    /* Visible by default — always shows */
    opacity: 1;
}
#ecb-trigger svg { display: block; flex-shrink: 0; }
#ecb-trigger:hover { transform: scale(1.1); }

.ecb-badge {
    position: absolute; top: -4px; right: -4px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff; animation: ecb-pulse 2s infinite;
}
@keyframes ecb-pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.2)} }

/* ── Position variants ─────────────────────────────────────────── */
/* Default: bottom-right */
#ecb-trigger              { bottom: 24px; right: 24px; }
#ecb-proactive            { bottom: 94px; right: 24px; }
#ecb-container            { bottom: 94px; right: 24px; }

.ecb-pos-bottom-right #ecb-trigger   { bottom: 24px; right: 24px; left: auto; top: auto; }
.ecb-pos-bottom-right #ecb-proactive { bottom: 94px; right: 24px; left: auto; top: auto; }
.ecb-pos-bottom-right #ecb-container { bottom: 94px; right: 24px; left: auto; top: auto; }

.ecb-pos-bottom-left #ecb-trigger    { bottom: 24px; left: 24px; right: auto; top: auto; }
.ecb-pos-bottom-left #ecb-proactive  { bottom: 94px; left: 24px; right: auto; top: auto; }
.ecb-pos-bottom-left #ecb-container  { bottom: 94px; left: 24px; right: auto; top: auto; }
.ecb-pos-bottom-left #ecb-proactive  { border-radius: 16px 16px 16px 4px; }

.ecb-pos-bottom-center #ecb-trigger  { bottom: 24px; left: 50%; right: auto; top: auto; transform: translateX(-50%); }
.ecb-pos-bottom-center #ecb-trigger:hover { transform: translateX(-50%) scale(1.1); }
.ecb-pos-bottom-center #ecb-proactive{ bottom: 94px; left: 50%; right: auto; top: auto; transform: translateX(-50%); }
.ecb-pos-bottom-center #ecb-proactive.ecb-show { transform: translateX(-50%) translateY(0); }
.ecb-pos-bottom-center #ecb-container{ bottom: 94px; left: 50%; right: auto; top: auto; transform: translateX(-50%); }

.ecb-pos-middle-right #ecb-trigger   { top: 50%; right: 24px; left: auto; bottom: auto; transform: translateY(-50%); }
.ecb-pos-middle-right #ecb-trigger:hover { transform: translateY(-50%) scale(1.1); }
.ecb-pos-middle-right #ecb-proactive { top: 50%; right: 24px; left: auto; bottom: auto; transform: translateY(calc(-100% - 40px)); }
.ecb-pos-middle-right #ecb-proactive.ecb-show { opacity:1; pointer-events:all; }
.ecb-pos-middle-right #ecb-container { top: 50%; right: 24px; left: auto; bottom: auto; transform: translateY(-50%); }

.ecb-pos-middle-left #ecb-trigger    { top: 50%; left: 24px; right: auto; bottom: auto; transform: translateY(-50%); }
.ecb-pos-middle-left #ecb-trigger:hover { transform: translateY(-50%) scale(1.1); }
.ecb-pos-middle-left #ecb-proactive  { top: 50%; left: 24px; right: auto; bottom: auto; transform: translateY(calc(-100% - 40px)); border-radius: 16px 16px 16px 4px; }
.ecb-pos-middle-left #ecb-proactive.ecb-show { opacity:1; pointer-events:all; }
.ecb-pos-middle-left #ecb-container  { top: 50%; left: 24px; right: auto; bottom: auto; transform: translateY(-50%); }

/* ── Proactive bubble ───────────────────────────────────────────── */
#ecb-proactive {
    position: fixed;
    max-width: 280px;
    background: #fff;
    border-radius: 16px 16px 4px 16px;
    padding: 14px 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,.15);
    font-size: 14px; line-height: 1.6; color: #1e293b;
    z-index: 99996;
    opacity: 0; pointer-events: none;
    transform: translateY(10px);
    transition: opacity .35s, transform .35s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#ecb-proactive.ecb-show { opacity: 1; pointer-events: all; transform: translateY(0); }
#ecb-proactive-close {
    position: absolute; top: 8px; right: 10px;
    background: none; border: none; color: #94a3b8;
    font-size: 16px; cursor: pointer; line-height: 1; padding: 0;
}
#ecb-proactive-close:hover { color: #1e293b; }
#ecb-proactive-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--ecb-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; margin-bottom: 8px;
}
#ecb-proactive-open {
    display: inline-block; margin-top: 10px;
    background: var(--ecb-primary); color: #fff;
    border: none; border-radius: 20px; padding: 8px 18px;
    font-size: 13px; font-weight: 500; cursor: pointer;
    font-family: inherit; transition: opacity .15s;
}
#ecb-proactive-open:hover { opacity: .85; }

/* ── Chat window ────────────────────────────────────────────────── */
#ecb-container {
    position: fixed;
    width: 380px; max-width: calc(100vw - 32px);
    border-radius: 16px; overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,.2);
    z-index: 99995;
    display: none; flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#ecb-container.ecb-open { display: flex; }

#ecb-head {
    padding: 14px 16px; display: flex; align-items: center; gap: 10px;
    background: var(--ecb-primary); flex-shrink: 0;
}
#ecb-head-av {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,.15);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
#ecb-head-name   { color: #fff; font-size: 15px; font-weight: 600; }
#ecb-head-status { color: rgba(255,255,255,.55); font-size: 11px; display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.ecb-sdot        { width: 6px; height: 6px; border-radius: 50%; background: #34d399; display: inline-block; }
#ecb-close {
    margin-left: auto; background: none; border: none;
    color: rgba(255,255,255,.6); font-size: 20px; cursor: pointer; padding: 2px 6px; line-height: 1;
}
#ecb-close:hover { color: #fff; }

#ecb-progress      { height: 3px; background: #e2e8f0; flex-shrink: 0; }
#ecb-progress-fill { height: 100%; background: var(--ecb-primary); transition: width .4s; width: 0; }

#ecb-msgs {
    background: #fff; padding: 14px 12px; height: 360px;
    overflow-y: auto; display: flex; flex-direction: column; gap: 9px; scroll-behavior: smooth;
}
.ecb-row   { display: flex; align-items: flex-end; gap: 7px; }
.ecb-row.u { flex-direction: row-reverse; }
.ecb-av {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; flex-shrink: 0; background: var(--ecb-primary);
}
.ecb-bub     { max-width: 82%; padding: 10px 14px; font-size: 13.5px; line-height: 1.6; }
.ecb-bub.b   { background: var(--ecb-bubble); color: #1e293b; border-radius: 4px 16px 16px 16px; }
.ecb-bub.u   { background: var(--ecb-user);   color: #fff;    border-radius: 16px 4px 16px 16px; }
.ecb-bub.typ { display: flex; align-items: center; gap: 4px; padding: 13px 16px; }
.ecb-typing-dot { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; animation: ecb-bl 1.2s infinite; }
.ecb-typing-dot:nth-child(2) { animation-delay: .2s; }
.ecb-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes ecb-bl { 0%,80%,100%{opacity:.2} 40%{opacity:1} }

.ecb-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; padding-left: 35px; }
.ecb-chip  {
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 14px;
    padding: 5px 12px; font-size: 12px; color: #64748b;
    cursor: pointer; transition: all .15s; font-family: inherit;
}
.ecb-chip:hover { background: var(--ecb-primary); color: #fff; border-color: var(--ecb-primary); }

.ecb-fallback-msg {
    max-width: 82%; padding: 10px 14px; font-size: 13px; line-height: 1.6;
    background: #fffbeb; border: 1px solid #fde68a;
    border-radius: 4px 16px 16px 16px; color: #92400e;
}
.ecb-fallback-msg a { color: #b45309; font-weight: 600; text-decoration: none; }
.ecb-fallback-msg a:hover { text-decoration: underline; }

.ecb-ok-msg {
    background: #f0fdf4; color: #166534; border-radius: 8px;
    padding: 12px; font-size: 13px; font-weight: 500; text-align: center; margin-top: 2px;
}

#ecb-foot {
    background: #fff; border-top: 1px solid #f1f5f9;
    padding: 10px 12px; display: flex; gap: 8px; align-items: center; flex-shrink: 0;
}
#ecb-input {
    flex: 1; border: 1px solid #e2e8f0; border-radius: 18px;
    padding: 9px 15px; font-size: 14px; background: #f8fafc;
    color: #1e293b; outline: none; font-family: inherit;
}
#ecb-input:focus { border-color: var(--ecb-accent); box-shadow: 0 0 0 2px rgba(99,102,241,.12); }
#ecb-input:disabled { opacity: .5; }
#ecb-send {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--ecb-primary); border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: opacity .15s;
    color: #fff; padding: 0; line-height: 1;
}
#ecb-send svg { display: block; flex-shrink: 0; }
#ecb-send:hover    { opacity: .8; }
#ecb-send:disabled { opacity: .3; cursor: default; }

/* ── Mobile ─────────────────────────────────────────────────────── */

/* CSS variable for mobile nav height — set by JS from admin setting */
:root { --ecb-mobile-nav: 0px; }

/* Hide floating button on mobile when admin option is enabled */
@media (max-width: 768px) {
    .ecb-hide-mobile-btn #ecb-trigger { display: none !important; }
    .ecb-hide-mobile-btn #ecb-proactive { display: none !important; }
}

/* Chat window on mobile — sits above the mobile nav bar */
@media (max-width: 480px) {
    #ecb-container,
    .ecb-pos-bottom-right #ecb-container,
    .ecb-pos-bottom-left #ecb-container,
    .ecb-pos-bottom-center #ecb-container,
    .ecb-pos-middle-right #ecb-container,
    .ecb-pos-middle-left #ecb-container {
        bottom: var(--ecb-mobile-nav) !important;
        right: 0 !important; left: 0 !important; top: auto !important;
        width: 100vw; max-width: 100%;
        border-radius: 16px 16px 0 0;
        transform: none !important;
        max-height: calc(100vh - var(--ecb-mobile-nav));
        z-index: 999999; /* above mobile nav */
    }

    /* Adjust trigger and proactive position above mobile nav */
    #ecb-trigger,
    .ecb-pos-bottom-right #ecb-trigger,
    .ecb-pos-bottom-left #ecb-trigger {
        bottom: calc(var(--ecb-mobile-nav) + 16px) !important;
    }
    #ecb-proactive,
    .ecb-pos-bottom-right #ecb-proactive,
    .ecb-pos-bottom-left #ecb-proactive {
        bottom: calc(var(--ecb-mobile-nav) + 82px) !important;
    }
}
