/* =========================================================================
   Live chat widget — بیمه البرز
   Floating, RTL, brand-green. Self-contained (falls back if brand vars absent).
   ========================================================================= */
.alz-chat {
    --c-brand: var(--brand, #0B7A3E);
    --c-brand-600: var(--brand-600, #0A6F38);
    --c-brand-400: var(--brand-400, #1FA85A);
    --c-ink: var(--ink, #1F2A24);
    --c-muted: var(--muted, #6B7280);
    --c-line: var(--line, #E7ECEA);
    --c-bg-soft: var(--bg-soft, #F8FAF9);
    position: fixed;
    inset-inline-start: 24px;
    inset-block-end: 24px;
    z-index: 9999;
    font-family: 'Vazirmatn', -apple-system, 'Segoe UI', Tahoma, sans-serif;
    direction: rtl;
}

/* ----------------------------------------------------------------- launcher */
.alz-chat__fab {
    width: 62px; height: 62px; border-radius: 50%; border: 0; cursor: pointer;
    background: linear-gradient(135deg, var(--c-brand-400), var(--c-brand-600));
    color: #fff; display: grid; place-items: center;
    box-shadow: 0 12px 30px rgba(11, 122, 62, .38);
    transition: transform .25s cubic-bezier(.22,.61,.36,1), box-shadow .25s;
    position: relative;
}
.alz-chat__fab:hover { transform: translateY(-3px) scale(1.04); }
.alz-chat__fab .material-symbols-rounded { font-size: 30px; font-variation-settings: 'FILL' 1; }
.alz-chat__fab .alz-ic-close { display: none; }
.alz-chat.is-open .alz-chat__fab .alz-ic-open { display: none; }
.alz-chat.is-open .alz-chat__fab .alz-ic-close { display: block; }
.alz-chat__fab::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    border: 2px solid var(--c-brand-400); opacity: .6; animation: alzPulse 2.2s ease-out infinite;
}
.alz-chat.is-open .alz-chat__fab::after { display: none; }
@keyframes alzPulse { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(1.7); opacity: 0; } }

.alz-chat__badge {
    position: absolute; top: -4px; inset-inline-end: -4px; min-width: 22px; height: 22px;
    background: #dc2626; color: #fff; border: 2px solid #fff; border-radius: 999px;
    font-size: .72rem; font-weight: 800; display: none; place-items: center; padding: 0 5px;
}
.alz-chat__badge.show { display: grid; }

/* ----------------------------------------------------------------- panel */
.alz-chat__panel {
    position: absolute; inset-block-end: 78px; inset-inline-start: 0;
    width: 370px; max-width: calc(100vw - 32px); height: 540px; max-height: calc(100vh - 120px);
    background: #fff; border-radius: 20px; overflow: hidden; display: none; flex-direction: column;
    box-shadow: 0 24px 60px rgba(16, 44, 30, .28); border: 1px solid var(--c-line);
    transform: translateY(16px) scale(.97); opacity: 0; transform-origin: bottom left;
    transition: transform .28s cubic-bezier(.22,.61,.36,1), opacity .28s;
}
.alz-chat.is-open .alz-chat__panel { display: flex; transform: translateY(0) scale(1); opacity: 1; }

.alz-chat__head {
    background: linear-gradient(125deg, var(--c-brand), var(--c-brand-600));
    color: #fff; padding: 16px 18px; display: flex; align-items: center; gap: 12px;
}
.alz-chat__head .alz-avatar { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.16); display: grid; place-items: center; flex: none; }
.alz-chat__head .alz-avatar .material-symbols-rounded { font-size: 24px; font-variation-settings: 'FILL' 1; }
.alz-chat__head .alz-head-info { flex: 1; min-width: 0; }
.alz-chat__head b { display: block; font-size: .98rem; font-weight: 800; }
.alz-chat__status { font-size: .76rem; color: rgba(255,255,255,.85); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.alz-chat__dot { width: 8px; height: 8px; border-radius: 50%; background: #9CA3AF; flex: none; }
.alz-chat__dot.online { background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.3); }
.alz-chat__min { all: unset; cursor: pointer; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: rgba(255,255,255,.85); }
.alz-chat__min:hover { background: rgba(255,255,255,.14); color: #fff; }

/* ----------------------------------------------------------------- body */
.alz-chat__body { flex: 1; overflow-y: auto; padding: 16px; background: var(--c-bg-soft); display: flex; flex-direction: column; gap: 10px; }
.alz-chat__body::-webkit-scrollbar { width: 6px; }
.alz-chat__body::-webkit-scrollbar-thumb { background: #d8e0db; border-radius: 999px; }

.alz-msg { max-width: 80%; padding: 9px 13px; border-radius: 14px; font-size: .88rem; line-height: 1.7; word-wrap: break-word; white-space: pre-wrap; }
.alz-msg time { display: block; font-size: .66rem; opacity: .6; margin-top: 3px; }
.alz-msg--visitor { align-self: flex-start; background: var(--c-brand); color: #fff; border-bottom-right-radius: 4px; }
.alz-msg--agent { align-self: flex-end; background: #fff; color: var(--c-ink); border: 1px solid var(--c-line); border-bottom-left-radius: 4px; }
.alz-msg--agent .alz-msg-author { font-size: .7rem; font-weight: 700; color: var(--c-brand); margin-bottom: 2px; }
.alz-msg--system { align-self: center; background: #eef2f0; color: var(--c-muted); font-size: .78rem; text-align: center; max-width: 92%; border-radius: 10px; }

.alz-typing { align-self: flex-end; display: none; gap: 4px; padding: 10px 14px; background: #fff; border: 1px solid var(--c-line); border-radius: 14px; }
.alz-typing.show { display: flex; }
.alz-typing span { width: 7px; height: 7px; border-radius: 50%; background: #bbb; animation: alzBlink 1.2s infinite both; }
.alz-typing span:nth-child(2) { animation-delay: .2s; }
.alz-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes alzBlink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* ----------------------------------------------------------------- pre-chat form */
.alz-chat__form { padding: 22px 18px; overflow-y: auto; background: #fff; }
.alz-chat__form .alz-intro { text-align: center; margin-bottom: 18px; }
.alz-chat__form .alz-intro .material-symbols-rounded { font-size: 46px; color: var(--c-brand); font-variation-settings: 'FILL' 1; }
.alz-chat__form .alz-intro p { color: var(--c-muted); font-size: .84rem; margin: 8px 0 0; }
.alz-field { margin-bottom: 13px; }
.alz-field label { display: block; font-size: .8rem; font-weight: 600; color: var(--c-ink); margin-bottom: 6px; }
.alz-field input, .alz-field textarea {
    width: 100%; box-sizing: border-box; border: 1px solid var(--c-line); border-radius: 11px;
    padding: 11px 13px; font-family: inherit; font-size: .88rem; background: #fff; color: var(--c-ink);
    transition: border-color .2s, box-shadow .2s;
}
.alz-field input:focus, .alz-field textarea:focus { outline: 0; border-color: var(--c-brand); box-shadow: 0 0 0 3px rgba(11,122,62,.12); }
.alz-field textarea { resize: none; min-height: 70px; }
.alz-err { color: #dc2626; font-size: .76rem; margin-top: 5px; display: none; }

.alz-btn {
    width: 100%; border: 0; border-radius: 12px; padding: 12px; cursor: pointer;
    background: linear-gradient(135deg, var(--c-brand-400), var(--c-brand-600)); color: #fff;
    font-family: inherit; font-weight: 700; font-size: .92rem; display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: filter .2s; margin-top: 4px;
}
.alz-btn:hover { filter: brightness(1.06); }
.alz-btn:disabled { opacity: .6; cursor: default; }

/* ----------------------------------------------------------------- view states
   default = pre-chat form · .has-conv = live chat · .is-ended = closed thread */
.alz-chat__body { display: none; }
.alz-chat__foot { border-top: 1px solid var(--c-line); padding: 10px 12px; background: #fff; display: none; align-items: flex-end; gap: 8px; }
.alz-chat.has-conv .alz-chat__form,
.alz-chat.is-ended .alz-chat__form { display: none; }
.alz-chat.has-conv .alz-chat__body,
.alz-chat.is-ended .alz-chat__body { display: flex; }
.alz-chat.has-conv .alz-chat__foot { display: flex; }
.alz-chat__ended { display: none; }
.alz-chat.is-ended .alz-chat__ended { display: block; }
.alz-chat__foot textarea {
    flex: 1; border: 1px solid var(--c-line); border-radius: 12px; padding: 10px 13px; resize: none;
    font-family: inherit; font-size: .88rem; max-height: 110px; min-height: 42px; line-height: 1.6; color: var(--c-ink);
}
.alz-chat__foot textarea:focus { outline: 0; border-color: var(--c-brand); }
.alz-send { all: unset; cursor: pointer; width: 44px; height: 44px; border-radius: 12px; flex: none;
    background: var(--c-brand); color: #fff; display: grid; place-items: center; transition: background .2s; }
.alz-send:hover { background: var(--c-brand-600); }
.alz-send .material-symbols-rounded { font-size: 22px; transform: scaleX(-1); }

.alz-chat__ended { padding: 14px; text-align: center; }
.alz-chat__ended .alz-btn { max-width: 220px; margin: 0 auto; }

@media (max-width: 480px) {
    .alz-chat { inset-inline-start: 14px; inset-block-end: 14px; }
    .alz-chat__panel { inset-block-end: 74px; width: calc(100vw - 28px); height: calc(100vh - 100px); }
}
