/* ═══════════════════════════════════════════════════════════════════════════
   المساعد — Pages/Admin/Assistant/AssistantPage.razor
   ملفّ ساكن لا يمرّ ببناء Tailwind (مثل contribute.css). الألوان من رموز اللوحة hsl(var(--…))
   فيلبس الوضع الداكن تلقائياً حين يضيف ThemeService الصنف dark على <html>.

   التخطيط: الصفحة بارتفاع الشاشة، والمحادثة وحدها تتمرّر، وحقل الكتابة ثابت أسفلها كما في
   تطبيقات المحادثة. عمود الرسائل بعرضٍ أقصى 780 بكسل حتى لا يطول السطر العربيّ على الشاشة العريضة.
   ═══════════════════════════════════════════════════════════════════════════ */

.asst {
    --asst-surface: hsl(var(--card));
    --asst-tonal: hsl(var(--muted));
    --asst-line: hsl(var(--border));
    --asst-ink: hsl(var(--foreground));
    --asst-ink-2: hsl(var(--muted-foreground));
    --asst-brand: hsl(var(--primary));
    --asst-brand-tint: hsl(var(--primary) / .07);
    --asst-glow: linear-gradient(135deg, hsl(213 71% 22%), hsl(211.9 55% 43%));
    --asst-warn: hsl(var(--warning));
    --asst-shadow: 0 1px 2px rgb(15 30 55 / .05), 0 8px 24px -12px rgb(15 30 55 / .18);

    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: calc(100dvh - 10.5rem);
    min-height: 560px;
    color: var(--asst-ink);
}

.dark .asst {
    --asst-brand-tint: hsl(var(--primary) / .08);
    --asst-glow: linear-gradient(135deg, hsl(211.9 55% 38%), hsl(199 70% 48%));
    --asst-shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 28px -14px rgb(0 0 0 / .6);
}

/* ─── رأس الصفحة ─── */
.asst-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.asst-head-id { display: flex; align-items: center; gap: .875rem; min-width: 0; }
.asst-head-logo {
    display: grid; place-items: center;
    width: 46px; height: 46px; flex: none;
    border-radius: 14px;
    background: var(--asst-glow);
    color: #fff;
    box-shadow: 0 8px 20px -8px hsl(211.9 55% 35% / .6);
}
.asst-head-title {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    margin: 0;
    font-size: 1.375rem; font-weight: 700; line-height: 1.3;
}
.asst-head-sub { margin: .125rem 0 0; font-size: .875rem; color: var(--asst-ink-2); }
.asst-tag {
    padding: .125rem .5rem;
    border-radius: 999px;
    background: hsl(var(--warning) / .14);
    color: hsl(32 85% 34%);
    font-size: .6875rem; font-weight: 600;
}
.dark .asst-tag { color: hsl(40 90% 65%); }
.asst-head-tools { display: flex; align-items: center; gap: .75rem; }

.asst-status {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .375rem .75rem;
    border-radius: 999px;
    border: 1px solid var(--asst-line);
    background: var(--asst-surface);
    font-size: .8125rem; font-weight: 600;
}
.asst-status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.asst-status.is-on { color: hsl(var(--success)); }
.asst-status.is-on .asst-status-dot { box-shadow: 0 0 0 3px hsl(var(--success) / .2); animation: asst-pulse 2s ease-in-out infinite; }
.asst-status.is-off { color: var(--asst-warn); }
.asst-status--avg { color: var(--asst-ink-2); font-weight: 500; }

.asst-time {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .75rem; color: var(--asst-ink-2);
    cursor: help;
}
.asst-elapsed {
    padding: .05rem .45rem;
    border-radius: 999px;
    background: var(--asst-surface);
    font-variant-numeric: tabular-nums;
    font-size: .75rem; font-weight: 600; color: var(--asst-ink);
}

/* ─── الإطار: قائمة المحادثات + المحادثة ─── */
.asst-shell {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    border: 1px solid var(--asst-line);
    border-radius: 18px;
    background: var(--asst-surface);
    box-shadow: var(--asst-shadow);
    overflow: hidden;
}

.asst-side {
    display: flex; flex-direction: column;
    min-height: 0;
    border-inline-end: 1px solid var(--asst-line);
    background: var(--asst-tonal);
}
.asst-side-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.125rem .75rem;
    font-size: .75rem; font-weight: 700; letter-spacing: 0;
    color: var(--asst-ink-2);
}
.asst-count {
    min-width: 22px; padding: 0 .4rem;
    border-radius: 999px;
    background: var(--asst-surface);
    border: 1px solid var(--asst-line);
    text-align: center; font-size: .6875rem; line-height: 20px;
}
.asst-side-empty { margin: 0; padding: 0 1.125rem 1rem; font-size: .8125rem; line-height: 1.7; color: var(--asst-ink-2); }
.asst-convs {
    list-style: none; margin: 0;
    padding: 0 .625rem .75rem;
    display: flex; flex-direction: column; gap: 2px;
    overflow-y: auto;
}
.asst-conv {
    position: relative;
    display: flex; align-items: flex-start; gap: .625rem;
    width: 100%;
    padding: .625rem .75rem;
    border: 0; border-radius: 12px;
    background: transparent;
    color: inherit; text-align: start;
    cursor: pointer;
    transition: background .15s ease;
}
.asst-conv:hover { background: hsl(var(--card) / .7); }
.asst-conv.is-active { background: var(--asst-surface); box-shadow: 0 1px 3px rgb(15 30 55 / .08); }
.asst-conv.is-active::before {
    content: ""; position: absolute;
    inset-block: 10px; inset-inline-start: 0;
    width: 3px; border-radius: 3px;
    background: var(--asst-brand);
}
.asst-conv-icon { flex: none; margin-top: 2px; color: var(--asst-ink-2); }
.asst-conv.is-active .asst-conv-icon { color: var(--asst-brand); }
.asst-conv-body { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.asst-conv-title {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: .8125rem; font-weight: 600; line-height: 1.55;
}
.asst-conv-time { font-size: .6875rem; color: var(--asst-ink-2); }

/* ─── المحادثة ─── */
.asst-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.asst-offline {
    display: flex; align-items: center; gap: .5rem;
    margin: .875rem 1.25rem 0;
    padding: .625rem .875rem;
    border-radius: 12px;
    border: 1px solid hsl(var(--warning) / .35);
    background: hsl(var(--warning) / .1);
    color: hsl(32 85% 30%);
    font-size: .8125rem;
}
.dark .asst-offline { color: hsl(40 90% 70%); }

.asst-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.75rem 1.5rem 1rem;
    scroll-behavior: smooth;
}

.asst-thread {
    display: flex; flex-direction: column; gap: 1.5rem;
    max-width: 780px;
    margin: 0 auto;
}

.asst-msg { display: flex; gap: .75rem; align-items: flex-start; }
.asst-msg--user { justify-content: flex-start; }
.asst-bubble {
    max-width: min(80%, 560px);
    padding: .75rem 1rem;
    border-radius: 18px 18px 18px 6px;
    background: var(--asst-brand);
    color: hsl(var(--primary-foreground));
    font-size: .9375rem; line-height: 1.75;
    white-space: pre-wrap;
    box-shadow: 0 6px 16px -10px hsl(var(--primary) / .7);
}
[dir="rtl"] .asst-bubble { border-radius: 18px 18px 6px 18px; }

.asst-avatar {
    display: grid; place-items: center;
    width: 34px; height: 34px; flex: none;
    border-radius: 11px;
    background: var(--asst-glow);
    color: #fff;
}
.asst-avatar.is-busy { animation: asst-pulse 1.6s ease-in-out infinite; }

.asst-answer { flex: 1; min-width: 0; }
.asst-md {
    font-size: .9375rem; line-height: 1.9;
    color: var(--asst-ink);
}
.asst-md p { margin: 0 0 .75rem; }
.asst-md .asst-lead { font-size: 1rem; }
.asst-h { margin: 1.125rem 0 .5rem; font-size: .9375rem; font-weight: 700; color: var(--asst-ink); }

.asst-steps {
    list-style: none;
    counter-reset: asst-step;
    margin: .25rem 0 1rem;
    padding: 0;
    display: flex; flex-direction: column; gap: .5rem;
}
.asst-steps > li {
    counter-increment: asst-step;
    position: relative;
    padding: .625rem .875rem;
    padding-inline-start: 3rem;
    border: 1px solid var(--asst-line);
    border-radius: 12px;
    background: var(--asst-surface);
}
.asst-steps > li::before {
    content: counter(asst-step);
    position: absolute;
    inset-inline-start: .75rem; top: .7rem;
    display: grid; place-items: center;
    width: 24px; height: 24px;
    border-radius: 8px;
    background: var(--asst-brand-tint);
    color: var(--asst-brand);
    font-size: .75rem; font-weight: 700; line-height: 1;
}

.asst-note {
    margin: .25rem 0 1rem;
    padding: .875rem 1rem;
    border-radius: 14px;
    border: 1px solid hsl(var(--warning) / .3);
    background: hsl(var(--warning) / .07);
}
.asst-note-title {
    display: flex; align-items: center; gap: .4rem;
    margin-bottom: .375rem;
    font-size: .8125rem; font-weight: 700;
    color: hsl(32 85% 32%);
}
.dark .asst-note-title { color: hsl(40 90% 66%); }
.asst-note ul { list-style: disc; margin: 0; padding-inline-start: 1.125rem; display: flex; flex-direction: column; gap: .375rem; }
.asst-note li { font-size: .875rem; line-height: 1.85; }
.asst-note li::marker { color: var(--asst-warn); }
.asst-bullets { list-style: disc; margin: 0 0 .875rem; padding-inline-start: 1.25rem; display: flex; flex-direction: column; gap: .3rem; }
.asst-bullets li::marker { color: var(--asst-ink-2); }

.asst-ui {
    display: inline-block;
    margin: 0 .1rem;
    padding: 0 .45rem;
    border-radius: 7px;
    border: 1px solid var(--asst-line);
    border-bottom-width: 2px;
    background: var(--asst-tonal);
    font-size: .8125rem; font-weight: 600; line-height: 1.6;
    white-space: nowrap;
}

.asst-meta { display: flex; align-items: center; gap: .5rem; margin-top: .25rem; }
.asst-chip {
    padding: .125rem .5rem;
    border-radius: 999px;
    background: var(--asst-brand-tint);
    color: var(--asst-ink-2);
    font-size: .6875rem; font-weight: 600;
}
.asst-copy {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .25rem .5rem;
    border: 0; border-radius: 8px;
    background: transparent;
    color: var(--asst-ink-2);
    font-size: .75rem;
    cursor: pointer;
}
.asst-copy:hover { background: var(--asst-tonal); color: var(--asst-ink); }

/* ─── بطاقات الأعمال: لا يقع شيء قبل «اسمح» ─── */
.asst-actions { display: flex; flex-direction: column; gap: .625rem; margin: .25rem 0 .75rem; }
.asst-action {
    padding: .875rem 1rem;
    border: 1px solid hsl(var(--primary) / .25);
    border-radius: 14px;
    background: var(--asst-brand-tint);
}
.asst-action-head { display: flex; align-items: flex-start; gap: .5rem; }
.asst-action-icon { flex: none; margin-top: 3px; color: var(--asst-brand); }
.asst-action-sum { flex: 1; font-size: .9375rem; font-weight: 600; line-height: 1.7; }
.asst-action-state {
    flex: none;
    padding: .125rem .55rem;
    border-radius: 999px;
    background: var(--asst-surface);
    border: 1px solid var(--asst-line);
    font-size: .6875rem; font-weight: 700; color: var(--asst-ink-2);
}
.asst-action-details { margin: .5rem 0 0; white-space: pre-wrap; font-size: .8125rem; line-height: 1.85; color: var(--asst-ink-2); }
.asst-action-confirm { margin-top: .625rem; max-width: 320px; }
.asst-action-confirm .form-group { margin: 0; }
.asst-action-btns { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.asst-action-hint { font-size: .75rem; color: var(--asst-ink-2); }
.asst-action-result { margin: .5rem 0 0; font-size: .8125rem; font-weight: 600; }
.asst-action.is-done { border-color: hsl(var(--success) / .35); background: hsl(var(--success) / .07); }
.asst-action.is-done .asst-action-icon, .asst-action.is-done .asst-action-result { color: hsl(var(--success)); }
.asst-action.is-failed { border-color: hsl(var(--destructive) / .3); background: hsl(var(--destructive) / .06); }
.asst-action.is-failed .asst-action-icon, .asst-action.is-failed .asst-action-result { color: hsl(var(--destructive)); }
.asst-action.is-cancelled, .asst-action.is-expired { opacity: .65; border-style: dashed; background: transparent; }
.asst-action.is-running .asst-action-icon { animation: asst-spin 1s linear infinite; }

/* «اسمح بالكلّ»: أوّل الصفوف قبل الإذن، ثمّ شريط تقدّم بلونين (نجح / لم يُنفَّذ)، ثمّ ما لم يُنفَّذ ولماذا */
.asst-batch-preview { display: flex; flex-wrap: wrap; gap: .375rem; margin: .625rem 0 0; padding: 0; list-style: none; }
.asst-batch-preview li {
    padding: .125rem .5rem; border: 1px solid var(--asst-line); border-radius: 999px;
    background: var(--asst-surface); font-size: .75rem; line-height: 1.7; direction: auto;
}
.asst-batch-preview li.is-more { border-style: dashed; color: var(--asst-ink-2); }
.asst-batch-progress { display: flex; height: 6px; margin-top: .75rem; border-radius: 999px; overflow: hidden; background: var(--asst-tonal); }
.asst-batch-progress span { display: block; height: 100%; transition: width .3s ease; }
.asst-batch-progress .is-ok { background: hsl(var(--success)); }
.asst-batch-progress .is-bad { background: hsl(var(--destructive)); }
.asst-batch-counts { display: flex; flex-wrap: wrap; gap: .25rem .875rem; margin: .5rem 0 0; font-size: .8125rem; color: var(--asst-ink-2); }
.asst-batch-counts .is-ok { color: hsl(var(--success)); font-weight: 600; }
.asst-batch-counts .is-bad { color: hsl(var(--destructive)); font-weight: 600; }
.asst-batch-fails { margin-top: .5rem; font-size: .8125rem; }
.asst-batch-fails summary { cursor: pointer; color: hsl(var(--destructive)); font-weight: 600; }
.asst-batch-fails ul { margin: .375rem 0 0; padding-inline-start: 1.125rem; max-height: 220px; overflow-y: auto; line-height: 1.85; }
.asst-batch-fails strong { margin-inline-end: .375rem; }
@keyframes asst-spin { to { transform: rotate(360deg); } }

/* ─── 👍 و👎 ─── */
.asst-fb { display: inline-flex; gap: 2px; }
.asst-fb-btn {
    display: grid; place-items: center;
    width: 26px; height: 26px;
    border: 0; border-radius: 8px;
    background: transparent;
    color: var(--asst-ink-2);
    cursor: pointer;
}
.asst-fb-btn:hover { background: var(--asst-tonal); color: var(--asst-ink); }
.asst-fb-btn.is-on { background: hsl(var(--success) / .14); color: hsl(var(--success)); }
.asst-fb-btn.is-down.is-on { background: hsl(var(--destructive) / .12); color: hsl(var(--destructive)); }
.asst-thanks { font-size: .75rem; color: var(--asst-ink-2); }
.asst-complaint {
    margin-top: .5rem;
    padding: .625rem .75rem;
    border: 1px solid var(--asst-line);
    border-radius: 12px;
    background: var(--asst-tonal);
}
.asst-complaint .form-group { margin: 0; }
.asst-complaint-actions { display: flex; gap: .5rem; margin-top: .5rem; }

.asst-typing {
    display: inline-flex; align-items: center; gap: .625rem;
    padding: .625rem .875rem;
    border-radius: 14px;
    background: var(--asst-tonal);
    font-size: .8125rem; color: var(--asst-ink-2);
}
.asst-dots { display: inline-flex; gap: 4px; }
.asst-dots i {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
    animation: asst-bounce 1.2s ease-in-out infinite;
}
.asst-dots i:nth-child(2) { animation-delay: .15s; }
.asst-dots i:nth-child(3) { animation-delay: .3s; }

/* ─── خطوات المساعد: حيّةً أثناء الانتظار، ومطويّةً فوق الردّ ─── */
.asst-live { display: flex; flex-direction: column; gap: .375rem; min-width: 0; }
.asst-live-now {
    font-weight: 600; color: var(--asst-ink);
    background: linear-gradient(90deg, var(--asst-ink) 30%, var(--asst-ink-2) 50%, var(--asst-ink) 70%);
    background-size: 200% 100%;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: asst-shimmer 2.2s linear infinite;
}
.asst-live-done {
    list-style: none; margin: 0;
    padding-inline-start: .875rem;
    display: flex; flex-direction: column; gap: .2rem;
    font-size: .75rem; color: var(--asst-ink-2);
}
.asst-live-done li { display: flex; align-items: center; gap: .375rem; }
.asst-live-done li svg { color: hsl(var(--success)); flex: none; }

.asst-think { margin: 0 0 .625rem; }
.asst-think > summary {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .3rem .7rem;
    border-radius: 999px;
    background: var(--asst-tonal);
    color: var(--asst-ink-2);
    font-size: .75rem; font-weight: 600;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.asst-think > summary::-webkit-details-marker { display: none; }
.asst-think > summary:hover { color: var(--asst-ink); }
.asst-think-caret { transition: transform .15s ease; }
.asst-think[open] .asst-think-caret { transform: rotate(180deg); }
.asst-think-list {
    list-style: none;
    margin: .5rem 0 0;
    padding: .25rem 0 .25rem;
    padding-inline-start: 1rem;
    border-inline-start: 2px solid var(--asst-line);
    display: flex; flex-direction: column; gap: .3rem;
    font-size: .8125rem; color: var(--asst-ink-2);
}
.asst-think-list { width: fit-content; max-width: 100%; }
.asst-think-list li { display: flex; align-items: baseline; gap: .75rem; }
.asst-think-at {
    flex: none; min-width: 2.25rem;
    direction: ltr; text-align: end;
    font-size: .6875rem; font-variant-numeric: tabular-nums; opacity: .75;
}

/* ─── الترحيب ─── */
.asst-welcome {
    display: flex; flex-direction: column; align-items: center;
    max-width: 640px;
    margin: 0 auto;
    padding: 2.5rem 0 1rem;
    text-align: center;
}
.asst-welcome-logo {
    display: grid; place-items: center;
    width: 64px; height: 64px;
    border-radius: 20px;
    background: var(--asst-glow);
    color: #fff;
    box-shadow: 0 14px 30px -12px hsl(211.9 55% 35% / .65);
}
.asst-welcome h2 { margin: 1.125rem 0 .375rem; font-size: 1.375rem; font-weight: 700; }
.asst-welcome p { margin: 0 0 1.5rem; font-size: .9375rem; line-height: 1.8; color: var(--asst-ink-2); }
.asst-suggest {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    width: 100%;
}
.asst-suggest-card {
    display: flex; align-items: flex-start; gap: .625rem;
    padding: .875rem 1rem;
    border: 1px solid var(--asst-line);
    border-radius: 14px;
    background: var(--asst-surface);
    color: var(--asst-ink);
    font-size: .875rem; line-height: 1.6; text-align: start;
    cursor: pointer;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.asst-suggest-card:hover { border-color: hsl(var(--primary) / .35); transform: translateY(-1px); box-shadow: var(--asst-shadow); }
.asst-suggest-icon { flex: none; margin-top: 2px; color: var(--asst-brand); }

/* ─── حقل الكتابة ─── */
.asst-compose-wrap {
    padding: .75rem 1.5rem 1rem;
    border-top: 1px solid var(--asst-line);
    background: var(--asst-surface);
}
.asst-compose {
    display: flex; align-items: flex-end; gap: .5rem;
    max-width: 780px;
    margin: 0 auto;
    padding: .375rem .375rem .375rem .5rem;
    border: 1px solid var(--asst-line);
    border-radius: 16px;
    background: var(--asst-surface);
    box-shadow: 0 2px 10px -6px rgb(15 30 55 / .2);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.asst-compose:focus-within { border-color: hsl(var(--ring) / .6); box-shadow: 0 0 0 4px hsl(var(--ring) / .12); }
.asst-compose.is-busy { opacity: .75; }
.asst-compose .form-group { flex: 1; margin: 0; min-width: 0; }
.asst-compose textarea {
    display: block;
    width: 100%;
    min-height: 48px !important;
    max-height: 220px;
    overflow-y: hidden;
    padding: .7rem .75rem !important;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--asst-ink);
    font-size: .9375rem; line-height: 1.6;
    resize: none !important;
}
/* ─── المرفقات ─── */
.asst-compose-zone { position: relative; max-width: 780px; margin: 0 auto; border-radius: 18px; transition: box-shadow .15s ease; }
.asst-compose-zone.is-drop { box-shadow: 0 0 0 3px hsl(var(--ring) / .45); }
.asst-compose-zone .asst-compose { max-width: none; }
.asst-attach {
    display: grid; place-items: center; flex: none;
    width: 42px; height: 42px; border-radius: 12px;
    color: var(--asst-ink-2); cursor: pointer;
}
.asst-attach:hover { background: var(--asst-tonal); color: var(--asst-ink); }
.asst-attach.is-disabled { opacity: .45; pointer-events: none; }
.asst-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.asst-pending { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.asst-pending-item {
    display: inline-flex; align-items: center; gap: .4rem;
    max-width: 240px; padding: .25rem .35rem .25rem .5rem;
    border: 1px solid var(--asst-line); border-radius: 10px;
    background: var(--asst-surface); font-size: .75rem;
}
.asst-pending-item img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.asst-pending-item.is-error { border-color: hsl(var(--destructive) / .4); color: hsl(var(--destructive)); }
.asst-pending-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asst-pending-x { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 6px; background: transparent; color: var(--asst-ink-2); cursor: pointer; flex: none; }
.asst-pending-x:hover { background: var(--asst-tonal); color: var(--asst-ink); }
.asst-user-col { display: flex; flex-direction: column; align-items: flex-start; gap: .375rem; max-width: min(80%, 560px); }
.asst-user-col .asst-bubble { max-width: 100%; }
.asst-files { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .4rem; }
.asst-thumb {
    display: grid; place-items: center;
    width: 120px; height: 120px; padding: 0; overflow: hidden;
    border: 1px solid var(--asst-line); border-radius: 12px;
    background: var(--asst-tonal); cursor: zoom-in;
}
.asst-thumb img { width: 100%; height: 100%; object-fit: cover; }
.asst-file {
    display: inline-flex; align-items: center; gap: .45rem;
    max-width: 260px; padding: .45rem .7rem;
    border: 1px solid var(--asst-line); border-radius: 12px;
    background: var(--asst-surface); color: var(--asst-ink);
    font-size: .8125rem; cursor: pointer;
}
.asst-file:hover { border-color: hsl(var(--primary) / .35); }
.asst-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.asst-file-size { flex: none; font-size: .6875rem; color: var(--asst-ink-2); }
.asst-lightbox {
    position: fixed; inset: 0; z-index: 2000;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem;
    padding: 1.5rem;
    background: rgb(8 15 28 / .82);
}
.asst-lightbox-bar { display: flex; align-items: center; gap: .5rem; max-width: 92vw; color: #fff; }
.asst-lightbox-name { font-size: .875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-inline-end: .5rem; }
.asst-lightbox-img { max-width: 92vw; max-height: calc(100dvh - 7rem); border-radius: 12px; box-shadow: 0 20px 60px rgb(0 0 0 / .5); background: #fff; }

.asst-send { flex: none; height: 42px; border-radius: 12px !important; padding-inline: 1rem !important; }
.asst-hint { max-width: 780px; margin: .5rem auto 0; font-size: .75rem; color: var(--asst-ink-2); text-align: center; }
.asst-hint kbd {
    display: inline-block; padding: 0 .35rem;
    border: 1px solid var(--asst-line); border-bottom-width: 2px; border-radius: 5px;
    background: var(--asst-surface); font: 600 .6875rem/1.5 ui-monospace, Consolas, monospace; direction: ltr;
}
.asst-sound {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .375rem .7rem;
    border: 1px solid var(--asst-line); border-radius: 999px;
    background: var(--asst-surface); color: var(--asst-ink-2);
    font-size: .8125rem; font-weight: 600; cursor: pointer;
}
.asst-sound.is-on { color: var(--asst-ink); }
.asst-sound:hover { border-color: hsl(var(--primary) / .35); }
.asst-error { max-width: 780px; margin: 0 auto .5rem; font-size: .8125rem; color: hsl(var(--destructive)); }

@keyframes asst-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes asst-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes asst-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-4px); opacity: 1; } }

/* ─── صفحة «ما تعلّمه المساعد» ─── */
.asst-learn {
    --asst-surface: hsl(var(--card)); --asst-tonal: hsl(var(--muted)); --asst-line: hsl(var(--border));
    --asst-ink: hsl(var(--foreground)); --asst-ink-2: hsl(var(--muted-foreground));
    --asst-brand: hsl(var(--primary)); --asst-brand-tint: hsl(var(--primary) / .07);
    --asst-glow: linear-gradient(135deg, hsl(213 71% 22%), hsl(211.9 55% 43%)); --asst-warn: hsl(var(--warning));
    --asst-shadow: 0 1px 2px rgb(15 30 55 / .05), 0 8px 24px -12px rgb(15 30 55 / .18);
    display: flex; flex-direction: column; gap: 1rem;
    max-width: 980px;
    color: var(--asst-ink);
}
.dark .asst-learn { --asst-glow: linear-gradient(135deg, hsl(211.9 55% 38%), hsl(199 70% 48%)); --asst-brand-tint: hsl(var(--primary) / .08); }
.asst-learn-empty {
    display: flex; flex-direction: column; align-items: center; gap: .5rem;
    padding: 3rem 1.5rem;
    border: 1px dashed var(--asst-line); border-radius: 18px;
    background: var(--asst-surface); text-align: center;
}
.asst-learn-empty h2 { margin: .75rem 0 0; font-size: 1.125rem; font-weight: 700; }
.asst-learn-empty p { margin: 0; color: var(--asst-ink-2); font-size: .875rem; }
.asst-learn-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.asst-learn-stats { display: flex; gap: .4rem; flex-wrap: wrap; }
.asst-learn-filters { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.asst-learn-filters .form-group { margin: 0; min-width: 220px; }
.asst-chip--warn { background: hsl(var(--warning) / .14); color: hsl(32 85% 32%); }
.asst-chip--good { background: hsl(var(--success) / .12); color: hsl(var(--success)); }
.asst-chip--bad { background: hsl(var(--destructive) / .1); color: hsl(var(--destructive)); }
.dark .asst-chip--warn { color: hsl(40 90% 66%); }
.asst-seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--asst-tonal); }
.asst-seg-btn {
    padding: .35rem .75rem; border: 0; border-radius: 9px;
    background: transparent; color: var(--asst-ink-2);
    font-size: .8125rem; font-weight: 600; cursor: pointer;
}
.asst-seg-btn.is-on { background: var(--asst-surface); color: var(--asst-ink); box-shadow: 0 1px 3px rgb(15 30 55 / .1); }
.asst-learn-list { display: flex; flex-direction: column; gap: .5rem; }
.asst-lcard {
    border: 1px solid var(--asst-line); border-radius: 14px;
    background: var(--asst-surface);
    box-shadow: 0 1px 2px rgb(15 30 55 / .04);
    overflow: hidden;
}
.asst-lcard.is-check { border-inline-start: 3px solid var(--asst-warn); }
.asst-lcard-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    width: 100%; padding: .875rem 1.125rem;
    border: 0; background: transparent; color: inherit; text-align: start; cursor: pointer;
}
.asst-lcard-head:hover { background: var(--asst-tonal); }
.asst-lcard-title { font-size: .9375rem; font-weight: 600; line-height: 1.6; min-width: 0; }
.asst-lcard-meta { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; flex: none; color: var(--asst-ink-2); }
.asst-lcard-date { font-size: .75rem; }
.asst-lcard-body { padding: .25rem 1.125rem 1.125rem; border-top: 1px solid var(--asst-line); }
.asst-lcard-patterns { display: flex; flex-wrap: wrap; gap: .35rem; margin: .875rem 0 .5rem; }
.asst-lcard-text { margin: .75rem 0 0; white-space: pre-wrap; font-size: .875rem; line-height: 1.9; }
.asst-lcard-recipe { margin: .75rem 0 0; font-size: .8125rem; color: var(--asst-ink-2); direction: rtl; }
.asst-lcard-foot { margin: .75rem 0 0; font-size: .75rem; color: var(--asst-ink-2); }
.asst-lcard-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.asst-lcard-form { display: flex; flex-direction: column; gap: .25rem; padding-top: .875rem; }
.asst-danger { color: hsl(var(--destructive)) !important; }

/* ─── الشاشات الضيّقة: القائمة شريطٌ أفقيّ فوق المحادثة ─── */
@media (max-width: 1023.98px) {
    .asst { height: auto; min-height: 0; }
    .asst-shell { grid-template-columns: minmax(0, 1fr); }
    .asst-side { border-inline-end: 0; border-bottom: 1px solid var(--asst-line); }
    .asst-convs { flex-direction: row; overflow-x: auto; padding-bottom: .75rem; }
    .asst-convs > li { flex: 0 0 220px; }
    .asst-scroll { max-height: 62dvh; min-height: 320px; padding: 1.25rem 1rem .75rem; }
    .asst-compose-wrap { padding: .75rem 1rem 1rem; }
}
@media (max-width: 639.98px) {
    .asst-suggest { grid-template-columns: minmax(0, 1fr); }
    .asst-head-sub { display: none; }
    .asst-bubble { max-width: 88%; }
    .asst-steps > li { padding-inline-start: 2.625rem; }
    .asst-msg--bot > .asst-avatar:not(.is-busy) { display: none; }
    .asst-scroll { padding-inline: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
    .asst-status-dot, .asst-avatar.is-busy, .asst-dots i, .asst-live-now { animation: none !important; }
    .asst-scroll { scroll-behavior: auto; }
}

/* ─── اختصار المساعد في الشريط العلويّ (الحاسب والجوال): بلون الهويّة ليُميَّز عن أزرار الأدوات ─── */
.header-assistant,
.mobile-top-header .header-btn.header-assistant {
    color: hsl(var(--primary));
    text-decoration: none;
}

.header-assistant:hover {
    background: hsl(var(--primary) / 0.1);
}
