/* assets/css/live-chat.css — পাবলিক লাইভ চ্যাট উইজেট (PART 3/4)
   নতুন স্কোপড ফাইল, প্রজেক্টের hero-banner.css/footer-full.css কনভেনশন
   অনুসরণ করে — সব সিলেক্টর .webbazarbd-live-chat র‍্যাপারের ভেতরে,
   বিদ্যমান কোনো CSS-এর সাথে কনফ্লিক্ট নেই। */

.webbazarbd-live-chat {
    --wb-lc-primary: #1a73e8;
    --wb-lc-primary-dark: #1558b0;
    --wb-lc-bg: #ffffff;
    --wb-lc-text: #1f2430;
    --wb-lc-muted: #6b7280;
    --wb-lc-border: #e5e7eb;
    --wb-lc-visitor-bubble: #1a73e8;
    --wb-lc-admin-bubble: #f1f3f5;
    --wb-lc-radius: 14px;
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 99999;
    font-family: inherit;
}

.webbazarbd-live-chat * {
    box-sizing: border-box;
}

.wb-lc-toggle {
    position: relative;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: var(--wb-lc-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(26, 115, 232, .35);
    transition: transform .15s ease, background .15s ease;
}

.wb-lc-toggle:hover {
    background: var(--wb-lc-primary-dark);
    transform: translateY(-2px);
}

/* বাটনে ক্লিক করার সাথে সাথেই (লোকেশন পারমিশনের অপেক্ষার সময়) স্পিনার —
   আগে এই ফিডব্যাক ছিল না, তাই ব্রাউজারের পারমিশন-পপআপ ধীরে এলে ইউজার মনে
   করত ক্লিক কাজ করেনি এবং বার বার ক্লিক করত। শুধু ভিজ্যুয়াল ইঙ্গিত —
   লোকেশন শর্ত/লজিক অপরিবর্তিত। */
.wb-lc-toggle-requesting {
    pointer-events: none;
}

.wb-lc-toggle-requesting .wb-lc-icon-chat {
    opacity: .35;
}

.wb-lc-toggle-requesting::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    animation: wbLcSpin .7s linear infinite;
}

.wb-lc-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e03131;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid #fff;
}

/* এই পপআপ মিস করাই আগের সমস্যার একটা বড় কারণ ছিল — তাই এখন ফুল-স্ক্রিন
   সেন্টারড + ডার্ক ব্যাকড্রপ সহ, বড় আইকন-টেক্সট-বাটনে, চোখ এড়ানো কঠিন। */
.wb-lc-geo-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 99998;
}

.wb-lc-geo-alert {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 99999;
    width: 320px;
    max-width: calc(100vw - 40px);
    background: var(--wb-lc-bg);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .32);
    border: 1px solid var(--wb-lc-border);
    padding: 28px 24px 24px;
    text-align: center;
}

.wb-lc-geo-icon {
    color: var(--wb-lc-primary);
    margin-bottom: 10px;
}

.wb-lc-geo-alert p {
    margin: 0 0 18px;
    font-size: 16px;
    line-height: 1.6;
    color: var(--wb-lc-text);
    font-weight: 500;
}

.wb-lc-geo-alert p strong {
    color: var(--wb-lc-primary);
}

.wb-lc-geo-alert .wb-lc-geo-btn {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border-radius: 10px;
    animation: wbLcPulse 1.6s ease-in-out infinite;
}

@keyframes wbLcPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(26, 115, 232, .45); }
    50% { box-shadow: 0 0 0 10px rgba(26, 115, 232, 0); }
}

.wb-lc-panel {
    position: absolute;
    right: 0;
    bottom: 74px;
    width: 340px;
    max-width: calc(100vw - 32px);
    height: 480px;
    max-height: calc(100vh - 120px);
    background: var(--wb-lc-bg);
    border-radius: var(--wb-lc-radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--wb-lc-border);
}

.wb-lc-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--wb-lc-primary);
    color: #fff;
    flex-shrink: 0;
}

.wb-lc-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #9aa0a6;
    flex-shrink: 0;
}

.wb-lc-dot-connecting {
    background: #f5c518;
    animation: wbLcPulse 1.2s infinite ease-in-out;
}

.wb-lc-dot-live {
    background: #2ecc71;
}

.wb-lc-dot-disconnected {
    background: #e03131;
}

@keyframes wbLcPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}

.wb-lc-header-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    flex-grow: 1;
    min-width: 0;
}

.wb-lc-header-title {
    font-weight: 700;
    font-size: 15px;
}

/* --- এজেন্ট-হেডার অ্যাভাটার (PART 14: live-chat.js .wb-lc-header-text এর
   ঠিক আগে .wb-lc-agent-avatar span ডাইনামিক্যালি ইনজেক্ট করে — ছবি থাকলে
   ভেতরে <img>, না থাকলে/লোড-ব্যর্থ হলে span-এই ইনিশিয়াল-লেটার টেক্সট) --- */
.wb-lc-agent-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    margin-right: 10px;
    background: rgba(255, 255, 255, .25);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    user-select: none;
}

.wb-lc-agent-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wb-lc-status-text {
    font-size: 11.5px;
    opacity: .85;
}

.wb-lc-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    opacity: .9;
}

.wb-lc-close:hover {
    opacity: 1;
}

.wb-lc-body {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

.wb-lc-state {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.wb-lc-state-loading {
    align-items: center;
    justify-content: center;
}

.wb-lc-spinner {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid var(--wb-lc-border);
    border-top-color: var(--wb-lc-primary);
    animation: wbLcSpin .8s linear infinite;
}

@keyframes wbLcSpin {
    to { transform: rotate(360deg); }
}

/* --- স্টার্ট ফর্ম --- */
.wb-lc-state-start {
    padding: 16px;
    gap: 10px;
    overflow-y: auto;
}

.wb-lc-intro {
    margin: 0 0 4px;
    font-size: 13.5px;
    color: var(--wb-lc-muted);
}

.wb-lc-alert {
    font-size: 12.5px;
    padding: 8px 10px;
    border-radius: 8px;
}

.wb-lc-alert-error {
    background: #fdecea;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

.wb-lc-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12.5px;
    color: var(--wb-lc-text);
}

.wb-lc-field input,
.wb-lc-field textarea {
    border: 1px solid var(--wb-lc-border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13.5px;
    font-family: inherit;
    resize: vertical;
    color: var(--wb-lc-text);
}

.wb-lc-field input:focus,
.wb-lc-field textarea:focus {
    outline: none;
    border-color: var(--wb-lc-primary);
}

.wb-lc-btn-primary {
    margin-top: 4px;
    background: var(--wb-lc-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease;
}

.wb-lc-btn-primary:hover {
    background: var(--wb-lc-primary-dark);
}

.wb-lc-btn-primary:disabled {
    opacity: .65;
    cursor: not-allowed;
}

/* --- থ্রেড / মেসেজ বাবল --- */
.wb-lc-state-thread {
    flex-grow: 1;
}

.wb-lc-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wb-lc-msg {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.wb-lc-msg-visitor {
    align-self: flex-end;
    background: var(--wb-lc-visitor-bubble);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.wb-lc-msg-admin {
    align-self: flex-start;
    background: var(--wb-lc-admin-bubble);
    color: var(--wb-lc-text);
    border-bottom-left-radius: 4px;
}

.wb-lc-msg-system {
    align-self: center;
    background: #fff7e0;
    color: #8a6300;
    text-align: center;
    font-size: 12px;
    max-width: 90%;
    display: flex;
    align-items: center;
    gap: 6px;
}

.wb-lc-msg-system::before {
    content: "ℹ️";
    flex-shrink: 0;
}

.wb-lc-msg-time {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    opacity: .65;
}

/* ভয়েস/সাউন্ড অপশন — মেসেজ-টেক্সটে ট্যাপ করলে পড়ে শোনানো (Web Speech API) */
.wb-lc-speakable {
    cursor: pointer;
}

.wb-lc-speakable::after {
    content: " 🔊";
    font-size: .82em;
    opacity: .55;
}

.wb-lc-speakable:active::after {
    opacity: 1;
}

.wb-lc-speakable.wb-lc-speaking::after {
    opacity: 1;
    animation: wbLcSpeakPulse .7s ease-in-out infinite;
}

@keyframes wbLcSpeakPulse {
    0%, 100% { opacity: .4; }
    50% { opacity: 1; }
}

/* --- অফ-আওয়ার --- */
.wb-lc-state-offhours {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    gap: 6px;
    color: var(--wb-lc-muted);
}

.wb-lc-offhours-icon {
    font-size: 32px;
}

/* --- ইনপুট বার (থ্রেড অবস্থায়ই শুধু দেখা যায়) --- */
.wb-lc-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--wb-lc-border);
    flex-shrink: 0;
}

.wb-lc-input-bar input {
    flex-grow: 1;
    border: 1px solid var(--wb-lc-border);
    border-radius: 999px;
    padding: 9px 14px;
    font-size: 13.5px;
    font-family: inherit;
}

.wb-lc-input-bar input:focus {
    outline: none;
    border-color: var(--wb-lc-primary);
}

.wb-lc-input-bar input:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

.wb-lc-input-bar button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--wb-lc-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.wb-lc-input-bar button:disabled {
    background: #b9c3d6;
    cursor: not-allowed;
}

/* --- রিস্টার্ট বার (কথোপকথন বন্ধ হলে wb-lc-input-bar এর জায়গায় দেখা যায়) --- */
.wb-lc-restart-bar {
    display: flex;
    padding: 10px 12px;
    border-top: 1px solid var(--wb-lc-border);
    flex-shrink: 0;
}

.wb-lc-restart-bar .wb-lc-btn-primary {
    width: 100%;
    margin-top: 0;
}

@media (max-width: 480px) {
    .webbazarbd-live-chat {
        /* PART 8 রিভিউ: প্রজেক্টে কোনো অন্য fixed-position ফ্লোটিং বাটন
           (WhatsApp/scroll-to-top) সক্রিয়ভাবে রেন্ডার হয় না (একমাত্র পাওয়া
           গেছে home-v01.css এর .ha-scroll-to-top-button, কিন্তু কোনো
           টেমপ্লেট/JS সেই মার্কআপ তৈরি করে না — মূল থিমের ডেড CSS, আগের
           PART এ পাওয়া about-us.css এর ডেড ফুটার ক্লাসের একই ক্যাটাগরি,
           তাই সরাসরি ওভারল্যাপ নেই)। তবু নচ/হোম-ইনডিকেটর যুক্ত মোবাইলে
           সিস্টেম UI এর সাথে বোতাম চাপা পড়া ঠেকাতে safe-area-inset যোগ। */
        right: max(14px, env(safe-area-inset-right));
        bottom: max(14px, env(safe-area-inset-bottom));
    }

    .wb-lc-panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 110px);
        bottom: 70px;
    }
}
