/* Pishro Advisor — ویجت مشاور (RTL) */
.nw-adv {
    --adv-primary: #2563eb;
    --adv-primary-dark: #1d4ed8;
    --adv-ink: #23211c;
    --adv-muted: #6b6a63;
    --adv-faint: #b4b2a9;
    --adv-line: #ece9e2;
    --adv-bg: #ffffff;
    --adv-soft: #faf8f4;
    --adv-online: #57ab2e;
    --adv-radius: 16px;
    --adv-shadow: 0 12px 40px rgba(0,0,0,.16);
    --adv-shadow-sm: 0 6px 18px rgba(0,0,0,.08);
    font-family: inherit;
    color: var(--adv-ink);
}
@keyframes nwAdvPop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
/* اتربیوت hidden باید بر display پایه غلبه کند (وگرنه پنل/دکمهٔ بازگشت همیشه باز می‌مانند) */
.nw-adv__panel[hidden], .nw-adv__back[hidden] { display: none !important; }

/* دکمهٔ شناور */
.nw-adv__launcher {
    position: fixed;
    inset-block-end: 20px;
    inset-inline-start: 20px;
    z-index: 99990;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: 999px;
    background: var(--adv-primary);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(37,99,235,.4);
    transition: transform .15s, background .15s;
}
.nw-adv__launcher:hover { background: var(--adv-primary-dark); transform: translateY(-2px); }
.nw-adv__launcher { transition: transform .15s, background .15s, inset-block-end .22s ease; }
.nw-adv__launcher-icon { font-size: 1.2rem; line-height: 1; }

/* حباب دعوت */
.nw-adv__teaser {
    position: fixed;
    inset-block-end: 78px;
    inset-inline-start: 20px;
    z-index: 99989;
    max-width: 240px;
    background: var(--adv-bg);
    border: 1px solid var(--adv-line);
    border-radius: 14px;
    border-end-end-radius: 4px;
    padding-block: 11px;
    padding-inline-start: 13px;
    padding-inline-end: 30px;
    font-size: 13px;
    line-height: 1.8;
    box-shadow: var(--adv-shadow-sm);
    animation: nwAdvPop .25s ease;
}
.nw-adv__teaser::after {
    content: "";
    position: absolute;
    inset-block-end: -7px;
    inset-inline-start: 26px;
    width: 12px; height: 12px;
    background: var(--adv-bg);
    border-inline-end: 1px solid var(--adv-line);
    border-block-end: 1px solid var(--adv-line);
    transform: rotate(45deg);
}
.nw-adv__teaser-close {
    position: absolute;
    inset-block-start: 5px;
    inset-inline-end: 7px;
    background: none; border: none; cursor: pointer;
    color: var(--adv-faint); font-size: 16px; line-height: 1;
}

/* پنل */
.nw-adv__panel {
    position: fixed;
    inset-block-end: 20px;
    inset-inline-start: 20px;
    z-index: 99991;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: var(--adv-bg);
    border: 1px solid var(--adv-line);
    border-radius: var(--adv-radius);
    box-shadow: var(--adv-shadow);
    overflow: hidden;
    animation: nwAdvPop .2s ease;
}

/* هدر */
.nw-adv__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    background: var(--adv-primary);
    color: #fff;
}
.nw-adv__avatar {
    width: 36px; height: 36px; flex: none;
    border-radius: 50%;
    background: rgba(255,255,255,.22);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.nw-adv__titles { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.4; }
.nw-adv__title { font-weight: 700; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nw-adv__status { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; opacity: .92; }
.nw-adv__dot { width: 7px; height: 7px; border-radius: 50%; background: #8fe14b; display: inline-block; }
.nw-adv__back, .nw-adv__close {
    background: rgba(255,255,255,.16);
    border: none; color: #fff; cursor: pointer; flex: none;
    width: 30px; height: 30px; border-radius: 8px;
    font-size: 1.2rem; line-height: 1; display: grid; place-items: center;
}
.nw-adv__back:hover, .nw-adv__close:hover { background: rgba(255,255,255,.3); }

/* بدنه */
.nw-adv__body { flex: 1; overflow-y: auto; background: var(--adv-soft); }

/* --- نمای خانه --- */
.nw-adv-home { padding: 16px; }
.nw-adv-home__greet { font-size: .92rem; font-weight: 700; margin: 2px 0 14px; }
.nw-adv-home__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.nw-adv-topic {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 14px 8px;
    background: var(--adv-bg); border: 1px solid var(--adv-line);
    border-radius: 12px; cursor: pointer; font: inherit; font-size: .8rem; font-weight: 600;
    color: var(--adv-ink); transition: border-color .15s, transform .1s;
}
.nw-adv-topic:hover { border-color: var(--adv-primary); transform: translateY(-1px); }
.nw-adv-topic__ic {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
    background: #f1efe8;
}
.nw-adv-topic__ic--buy { background: #fdeecb; }
.nw-adv-topic__ic--order { background: #e3eefb; }
.nw-adv-topic__ic--warranty { background: #e9f2dc; }
.nw-adv-topic__ic--product { background: #fbe6ee; }
.nw-adv-topic__ic--other { background: #f1efe8; }
.nw-adv-topic--wide {
    grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 10px; padding: 13px;
}
.nw-adv-topic--wide .nw-adv-topic__ic { width: 30px; height: 30px; font-size: 1.05rem; }

/* --- نمای FAQ --- */
.nw-adv-faq { padding: 13px; }
.nw-adv-faq__hint { font-size: .8rem; color: var(--adv-muted); margin: 2px 2px 12px; }
.nw-adv-q {
    background: var(--adv-bg); border: 1px solid var(--adv-line);
    border-radius: 10px; margin-block-end: 8px; overflow: hidden; transition: border-color .15s;
}
.nw-adv-q__btn {
    width: 100%; text-align: start; padding: 11px 13px; border: none; background: none;
    font: inherit; font-weight: 600; font-size: .82rem; cursor: pointer; color: var(--adv-ink);
    display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.nw-adv-q__btn span { color: var(--adv-faint); font-size: 1rem; flex: none; }
.nw-adv-q__a { padding: 0 13px 11px; font-size: .8rem; color: var(--adv-muted); line-height: 1.95; display: none; }
.nw-adv-q.is-open { border-color: var(--adv-primary); }
.nw-adv-q.is-open .nw-adv-q__a { display: block; }
.nw-adv-q.is-open .nw-adv-q__btn { color: var(--adv-primary-dark); }
.nw-adv-q.is-open .nw-adv-q__btn span { color: var(--adv-primary-dark); }
.nw-adv-faq__links { margin: 12px 2px; display: flex; flex-wrap: wrap; gap: 10px; }
.nw-adv-faq__links a { font-size: .8rem; color: var(--adv-primary-dark); text-decoration: none; }
.nw-adv-cta {
    margin: 14px 0 4px; width: 100%; padding: 13px; border: none; border-radius: 12px;
    background: var(--adv-primary); color: #fff; font: inherit; font-weight: 700; cursor: pointer;
    transition: background .15s;
}
.nw-adv-cta:hover { background: var(--adv-primary-dark); }

/* --- نمای چت --- */
.nw-adv-chat { display: flex; flex-direction: column; height: 100%; }
.nw-adv-chat__log { flex: 1; overflow-y: auto; padding: 13px; display: flex; flex-direction: column; gap: 9px; }
.nw-adv-msg { max-width: 84%; padding: 9px 12px; border-radius: 14px; font-size: .84rem; line-height: 1.9; white-space: pre-wrap; word-break: break-word; }
.nw-adv-msg--bot { align-self: flex-start; background: var(--adv-bg); border: 1px solid var(--adv-line); border-start-start-radius: 4px; }
.nw-adv-msg--user { align-self: flex-end; background: var(--adv-primary); color: #fff; border-start-end-radius: 4px; }
.nw-adv-msg--sys { align-self: center; background: #fff3d6; color: #7a5b12; font-size: .78rem; border-radius: 10px; padding: 7px 11px; }
.nw-adv-typing { align-self: flex-start; color: var(--adv-muted); font-size: .78rem; padding: 4px 4px; }

.nw-adv-chat__form { display: flex; gap: 8px; padding: 10px; border-block-start: 1px solid var(--adv-line); background: var(--adv-bg); }
.nw-adv-chat__input {
    flex: 1; border: 1px solid var(--adv-line); border-radius: 10px; padding: 10px 12px;
    font: inherit; font-size: .84rem; resize: none; max-height: 96px; color: var(--adv-ink);
}
.nw-adv-chat__input:focus { outline: none; border-color: var(--adv-primary); }
.nw-adv-chat__send {
    border: none; border-radius: 10px; background: var(--adv-primary); color: #fff;
    width: 44px; cursor: pointer; font-size: 1.1rem; transition: background .15s;
}
.nw-adv-chat__send:hover { background: var(--adv-primary-dark); }
.nw-adv-chat__send:disabled { opacity: .5; cursor: default; }

/* موبایل — نوار ناوبری پایینِ سایت (۶۰px) حضور دارد؛ دکمه/حباب/پنل بالای آن */
@media (max-width: 860px) {
    .nw-adv__launcher { inset-block-end: calc(76px + env(safe-area-inset-bottom, 0px)); }
    .nw-adv__teaser   { inset-block-end: calc(134px + env(safe-area-inset-bottom, 0px)); }
    .nw-adv__panel    { inset-block-end: calc(72px + env(safe-area-inset-bottom, 0px)); height: 520px; }
    /* روی صفحهٔ محصول، وقتی نوار خرید چسبان ظاهر است، دکمه/حباب بالای آن می‌روند */
    .nw-adv--bar .nw-adv__launcher { inset-block-end: calc(140px + env(safe-area-inset-bottom, 0px)); }
    .nw-adv--bar .nw-adv__teaser   { inset-block-end: calc(198px + env(safe-area-inset-bottom, 0px)); }
}
/* گوشی — پنل تمام‌صفحه با احترام به کیبورد و safe-area */
@media (max-width: 480px) {
    .nw-adv__panel {
        inset: 0; width: 100%; height: 100dvh;
        max-width: 100%; max-height: none; border-radius: 0;
    }
    .nw-adv__header { padding-block-start: calc(13px + env(safe-area-inset-top, 0px)); }
    .nw-adv-chat__form { padding-block-end: calc(10px + env(safe-area-inset-bottom, 0px)); }
}
