/* ───── دستیار هوشمند کنار نرم‌افزار ───── */

/*
   ویجت روی داشبورد و روی سایت عمومی هر دو سوار می‌شود و این دو
   مجموعه متغیر یکسانی ندارند (مثلاً --accent در سایت عمومی فیروزه‌ای است).
   پس رنگ‌های خودش را با --asst-* تعریف می‌کند؛ در داشبورد کلاس
   .asst-themed آن‌ها را به تم داشبورد وصل می‌کند.
*/
.asst-fab,
.asst-panel {
    --asst-accent: #5254d4;
    --asst-accent-2: #7c3aed;
    --asst-accent-glow: rgba(99, 102, 241, 0.1);
    --asst-card: #ffffff;
    --asst-card-hover: #f7f7ff;
    --asst-border: rgba(0, 0, 0, 0.08);
    --asst-border-hover: rgba(99, 102, 241, 0.4);
    --asst-text: #1a1a2e;
    --asst-text-2: rgba(40, 40, 80, 0.65);
    --asst-muted: rgba(60, 60, 100, 0.35);
    --asst-input: rgba(0, 0, 0, 0.04);
    --asst-danger: #dc2626;
    --asst-track: rgba(0, 0, 0, 0.03);
    --asst-thumb: rgba(99, 102, 241, 0.25);
}

.asst-fab.asst-themed,
.asst-panel.asst-themed {
    --asst-accent: var(--accent);
    --asst-accent-2: var(--accent-2);
    --asst-accent-glow: var(--accent-glow);
    --asst-card: var(--bg-card);
    --asst-card-hover: var(--bg-card-hover);
    --asst-border: var(--border);
    --asst-border-hover: var(--border-hover);
    --asst-text: var(--text-primary);
    --asst-text-2: var(--text-secondary);
    --asst-muted: var(--text-muted);
    --asst-input: var(--input-bg);
    --asst-danger: var(--danger);
    --asst-track: var(--scrollbar-track);
    --asst-thumb: var(--scrollbar-thumb);
}

/* روی سایت عمومی، تم تیره‌ی لندینگ هم باید پوشش داده شود */
[data-bs-theme="dark"] .asst-fab:not(.asst-themed),
[data-bs-theme="dark"] .asst-panel:not(.asst-themed) {
    --asst-card: #12122a;
    --asst-card-hover: #1a1a38;
    --asst-border: rgba(255, 255, 255, 0.09);
    --asst-text: #f0f0ff;
    --asst-text-2: rgba(200, 200, 230, 0.65);
    --asst-muted: rgba(180, 180, 210, 0.4);
    --asst-input: rgba(255, 255, 255, 0.06);
    --asst-track: rgba(255, 255, 255, 0.03);
    --asst-thumb: rgba(99, 102, 241, 0.3);
}

/* آیکون‌ها SVG درون‌خطی‌اند تا به فونت آیکون صفحه وابسته نباشند */
.asst-fab svg,
.asst-panel svg {
    width: 1em;
    height: 1em;
    display: block;
    flex: 0 0 auto;
}

.asst-act svg { display: inline-block; vertical-align: -0.12em; }
.asst-empty-icon { font-size: 1.8rem; color: var(--asst-accent); display: flex; justify-content: center; }
.asst-botbox-title svg { display: inline-block; vertical-align: -0.12em; }

.asst-fab {
    position: fixed;
    left: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--asst-accent), var(--asst-accent-2));
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.38);
    z-index: 1040;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .18s ease, box-shadow .18s ease;
}

.asst-fab:hover { transform: translateY(-2px) scale(1.04); }
.asst-fab.active { transform: rotate(90deg); }

.asst-panel {
    position: fixed;
    left: 24px;
    bottom: 92px;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 130px);
    background: var(--asst-card);
    backdrop-filter: blur(18px);
    border: 1px solid var(--asst-border);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    z-index: 1041;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(.98);
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
}

.asst-panel.open {
    opacity: 1;
    visibility: visible;
    transform: none;
}

/* سربرگ */
.asst-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--asst-border);
    background: var(--asst-accent-glow);
}

.asst-head-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--asst-accent), var(--asst-accent-2));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.asst-head-title { font-weight: 700; font-size: .92rem; color: var(--asst-text); }
.asst-head-sub { font-size: .7rem; color: var(--asst-muted); }
.asst-head-spacer { flex: 1; }

.asst-icon-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--asst-border);
    border-radius: 8px;
    background: transparent;
    color: var(--asst-text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
}

.asst-icon-btn:hover { background: var(--asst-card-hover); color: var(--asst-text); }
.asst-icon-btn.active { background: var(--asst-accent); border-color: var(--asst-accent); color: #fff; }

/* پیام‌ها */
.asst-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.asst-messages::-webkit-scrollbar { width: 6px; }
.asst-messages::-webkit-scrollbar-track { background: var(--asst-track); }
.asst-messages::-webkit-scrollbar-thumb { background: var(--asst-thumb); border-radius: 3px; }

.asst-msg { display: flex; flex-direction: column; gap: 4px; max-width: 92%; }
.asst-msg.user { align-self: flex-end; align-items: flex-end; }
.asst-msg.bot { align-self: flex-start; align-items: flex-start; }

.asst-bubble {
    padding: 9px 12px;
    border-radius: 13px;
    font-size: .84rem;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

.asst-msg.user .asst-bubble {
    background: linear-gradient(135deg, var(--asst-accent), var(--asst-accent-2));
    color: #fff;
    border-end-end-radius: 4px;
}

.asst-msg.bot .asst-bubble {
    background: var(--asst-input);
    color: var(--asst-text);
    border: 1px solid var(--asst-border);
    border-end-start-radius: 4px;
}

.asst-msg-actions { display: flex; gap: 6px; }

.asst-act {
    border: 1px solid var(--asst-border);
    background: transparent;
    color: var(--asst-text-2);
    border-radius: 7px;
    padding: 3px 8px;
    font-size: .7rem;
    cursor: pointer;
    transition: all .15s ease;
}

.asst-act:hover { border-color: var(--asst-accent); color: var(--asst-accent); }

/* حالت خالی */
.asst-empty { text-align: center; padding: 26px 10px; color: var(--asst-text-2); }
.asst-empty-title { font-weight: 700; margin: 10px 0 6px; color: var(--asst-text); }
.asst-empty p { font-size: .78rem; line-height: 1.9; margin: 0 0 14px; }
.asst-chips { display: flex; flex-direction: column; gap: 6px; }

.asst-chip {
    border: 1px solid var(--asst-border);
    background: var(--asst-input);
    color: var(--asst-text);
    border-radius: 9px;
    padding: 7px 10px;
    font-size: .76rem;
    cursor: pointer;
    text-align: start;
    font-family: inherit;
    transition: all .15s ease;
}

.asst-chip:hover { border-color: var(--asst-accent); color: var(--asst-accent); }

/* نشانگر تایپ */
.asst-typing {
    display: none;
    align-items: center;
    gap: 7px;
    padding: 0 14px 8px;
    font-size: .74rem;
    color: var(--asst-muted);
}

.asst-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--asst-accent);
    animation: asstBounce 1.2s infinite;
}

.asst-typing span:nth-child(2) { animation-delay: .15s; }
.asst-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes asstBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* جعبه‌ی ارسال با ربات */
.asst-botbox {
    display: none;
    border-top: 1px solid var(--asst-border);
    background: var(--asst-accent-glow);
    padding: 11px 14px;
}

.asst-botbox-title {
    font-size: .78rem;
    font-weight: 700;
    color: var(--asst-text);
    margin-bottom: 8px;
}

.asst-botbox label {
    display: block;
    font-size: .7rem;
    color: var(--asst-muted);
    margin: 6px 0 3px;
}

.asst-botbox select,
.asst-botbox input,
.asst-botbox textarea {
    width: 100%;
    background: var(--asst-card);
    border: 1px solid var(--asst-border);
    border-radius: 8px;
    color: var(--asst-text);
    padding: 7px 9px;
    font-size: .78rem;
    font-family: inherit;
}

.asst-botbox textarea { resize: vertical; min-height: 60px; line-height: 1.7; }

.asst-botbox-actions { display: flex; gap: 8px; margin-top: 10px; }

.asst-btn-primary,
.asst-btn-ghost {
    border-radius: 9px;
    padding: 7px 13px;
    font-size: .78rem;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s ease;
}

.asst-btn-primary {
    flex: 1;
    border: none;
    background: linear-gradient(135deg, var(--asst-accent), var(--asst-accent-2));
    color: #fff;
}

.asst-btn-primary:disabled { opacity: .6; cursor: default; }
.asst-btn-ghost { border: 1px solid var(--asst-border); background: transparent; color: var(--asst-text-2); }
.asst-btn-ghost:hover { color: var(--asst-text); }

/* نوار ورودی */
.asst-input-bar {
    border-top: 1px solid var(--asst-border);
    padding: 10px 12px 11px;
}

.asst-input-row { display: flex; align-items: flex-end; gap: 7px; }

.asst-input-row textarea {
    flex: 1;
    resize: none;
    height: 38px;
    max-height: 140px;
    background: var(--asst-input);
    border: 1px solid var(--asst-border);
    border-radius: 11px;
    color: var(--asst-text);
    padding: 9px 11px;
    font-size: .82rem;
    line-height: 1.6;
    font-family: inherit;
}

.asst-input-row textarea:focus { outline: none; border-color: var(--asst-border-hover); }

.asst-round-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 50%;
    border: 1px solid var(--asst-border);
    background: var(--asst-input);
    color: var(--asst-text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
}

.asst-round-btn:hover:not(:disabled) { color: var(--asst-accent); border-color: var(--asst-accent); }
.asst-round-btn:disabled { opacity: .45; cursor: not-allowed; }

.asst-round-btn.send {
    border: none;
    background: linear-gradient(135deg, var(--asst-accent), var(--asst-accent-2));
    color: #fff;
}

.asst-round-btn.recording {
    background: var(--asst-danger);
    border-color: var(--asst-danger);
    color: #fff;
    animation: asstPulse 1.3s infinite;
}

@keyframes asstPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
    50% { box-shadow: 0 0 0 9px rgba(220, 38, 38, 0); }
}

.asst-hint { font-size: .68rem; color: var(--asst-muted); margin-top: 6px; text-align: center; }

@media (max-width: 560px) {
    .asst-panel {
        inset-inline: 10px;
        width: auto;
        bottom: 84px;
        height: calc(100vh - 110px);
    }

    .asst-fab { left: 16px; bottom: 16px; }
}
