/*
 * HOMEi Assistant — .hoas-* scoped skin (ASSIST-2, HO-3081).
 * House rules: page-scoped prefixed classes only, CSS logical properties
 * (one sheet for AR/EN), no font-family (typography.css owns it), dark
 * mode = token remap under .dark. Chat surfaces are read at a glance:
 * state lives in the bubble tone and the pills, not in colour alone.
 */
.hoas,
.hoas-obs {
    /* Shared roles read from the token layer (tokens.css, HO-3104); what
       stays local is the ink on the accent fill, the user bubble, and this
       design's own amber — those carry their own dark values below. */
    --hoas-card: var(--ho-surface);
    --hoas-border: var(--ho-line);
    --hoas-border-strong: var(--ho-line-strong);
    --hoas-text: var(--ho-ink);
    --hoas-muted: var(--ho-ink-muted);
    --hoas-soft: var(--ho-surface-inset);
    --hoas-accent: var(--ho-info-line);
    --hoas-accent-ink: #ffffff;
    --hoas-accent-soft: var(--ho-info-soft);
    --hoas-user: #1f2937;
    --hoas-user-ink: #ffffff;
    --hoas-danger: var(--ho-danger-ink);
    --hoas-danger-soft: var(--ho-danger-soft);
    --hoas-warn: #a45c06;
    --hoas-warn-soft: var(--ho-warning-soft);
    --hoas-ok: var(--ho-success-ink);
    --hoas-ok-soft: var(--ho-success-soft);
    --hoas-radius: 0.75rem;

    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    background: var(--hoas-card);
    border: 1px solid var(--hoas-border);
    border-radius: var(--hoas-radius);
    padding: 0.875rem 1rem;
    color: var(--hoas-text);
}
.dark .hoas,
.dark .hoas-obs {
    --hoas-accent-ink: #18181b;
    --hoas-user: #e4e4e7;
    --hoas-user-ink: #18181b;
    --hoas-warn: var(--ho-warning-ink);
}

.hoas-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.hoas-head > div:first-child { min-inline-size: 0; }
.hoas-head-actions { flex: 0 0 auto; }
.hoas-link { white-space: nowrap; }
.hoas-title { font-weight: 800; font-size: 0.95rem; }
.hoas-tagline { display: block; color: var(--hoas-muted); font-size: 0.72rem; margin-block-start: 0.15rem; }
.hoas-link { background: none; border: 0; color: var(--hoas-accent); font-size: 0.72rem; cursor: pointer; }
.hoas-link:focus-visible, .hoas-chip:focus-visible, .hoas-send:focus-visible, .hoas-fb-btn:focus-visible, .hoas-input:focus-visible, .hoas-close:focus-visible, .hoas-open:focus-visible, .hoas-fb-wrong summary:focus-visible { outline: 2px solid var(--hoas-accent); outline-offset: 1px; }

.hoas-thread { display: flex; flex-direction: column; gap: 0.5rem; max-block-size: 28rem; overflow-y: auto; padding-inline-end: 0.125rem; }
.hoas-empty p { color: var(--hoas-muted); font-size: 0.8rem; margin: 0 0 0.5rem; }
.hoas-msg { display: flex; }
.hoas-user { justify-content: flex-end; }
.hoas-bot { justify-content: flex-start; }
.hoas-bubble { max-inline-size: 92%; border-radius: var(--hoas-radius); padding: 0.55rem 0.75rem; font-size: 0.84rem; line-height: 1.55; border: 1px solid var(--hoas-border); background: var(--hoas-soft); }
.hoas-user .hoas-bubble { background: var(--hoas-user); color: var(--hoas-user-ink); border-color: transparent; }
.hoas-kind-social { background: var(--hoas-accent-soft); border-color: var(--hoas-border); }
.hoas-kind-clarify { border-color: var(--hoas-warn); background: var(--hoas-warn-soft); }
.hoas-kind-notice { border-color: var(--hoas-border); background: var(--hoas-card); color: var(--hoas-muted); }
/* A refusal or an unreachable source is not an aside: it carries the danger
   edge and full-strength ink, so it is not skimmed past. */
.hoas-status-refused, .hoas-status-unavailable { border-color: var(--hoas-danger); color: var(--hoas-text); }
.hoas-kind-unanswered { border-style: dashed; color: var(--hoas-muted); }
/* ASSIST-11: general talk from the model — the accent edge says "the
   assistant is speaking", the note under it says "not HOMEi data". */
.hoas-kind-open { border-color: var(--hoas-accent); background: var(--hoas-card); }
/* ASSIST-12: grounded in approved documents — the accent-soft ground says
   "this is HOMEi's own text", the note under it names the document. */
.hoas-kind-knowledge { border-color: var(--hoas-accent); background: var(--hoas-accent-soft); }
.hoas-general { font-style: italic; }
.hoas-thinking { color: var(--hoas-muted); font-style: italic; }
.hoas-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Containment — nothing is laid out past the panel edge. Only .hoas-text
   wrapped, so a single unbreakable run (a reference the user pasted into
   his own line, a record title with no spaces, an e-mail in a sub-label)
   set a min-content width the panel could not honour and the bubble was
   laid out outside it — PO screenshot 2026-09-09 «الكلام طالع بره». The
   panel's own clipping then cut the text off and the thread grew a
   sideways scrollbar. `anywhere` is the operative value, not
   `break-word`: only `anywhere` also LOWERS the min-content size, and the
   min-content size is exactly what a flex or grid item's automatic
   minimum size is taken from. The min-inline-size pair covers the boxes
   that carry no text of their own — a message row, a card, a kv column. */
.hoas { overflow-wrap: anywhere; }
.hoas-msg > *, .hoas-cards > *, .hoas-kv > * { min-inline-size: 0; }
.hoas-meta { color: var(--hoas-muted); font-size: 0.68rem; margin-block-start: 0.35rem; }
.hoas-bidi { unicode-bidi: isolate; }
.hoas-mono { font-size: 0.66rem; direction: ltr; unicode-bidi: isolate; }
.hoas-ltr { direction: ltr; unicode-bidi: isolate; }

.hoas-suggest { display: flex; flex-wrap: wrap; gap: 0.375rem; min-inline-size: 0; padding-block: 0.125rem 0.375rem; border-block-end: 1px dashed var(--hoas-border); }
.hoas-chip-suggest { flex: 0 1 auto; max-inline-size: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-color: var(--hoas-accent); background: var(--hoas-accent-soft); color: var(--hoas-accent); font-weight: 600; }
.hoas-chip-suggest:hover { border-color: var(--hoas-accent); }
.hoas-chips { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-block-start: 0.4rem; }
.hoas-chip { border: 1px solid var(--hoas-border-strong); background: var(--hoas-card); color: var(--hoas-text); border-radius: 999px; padding: 0.25rem 0.7rem; font-size: 0.72rem; cursor: pointer; }
.hoas-chip:hover { border-color: var(--hoas-accent); color: var(--hoas-accent); }
.hoas-chip-choice { border-color: var(--hoas-accent); color: var(--hoas-accent); background: var(--hoas-accent-soft); }

.hoas-cards { display: flex; flex-direction: column; gap: 0.375rem; margin-block-start: 0.5rem; }
.hoas-card { border: 1px solid var(--hoas-border); border-inline-start: 3px solid var(--hoas-border); border-radius: 0.5rem; padding: 0.45rem 0.6rem; background: var(--hoas-card); }
.hoas-card-overdue { border-inline-start-color: var(--hoas-danger); }
.hoas-card-today { border-inline-start-color: var(--hoas-warn); }
.hoas-card-upcoming { border-inline-start-color: var(--hoas-ok); }
.hoas-card-title { font-weight: 700; font-size: 0.8rem; unicode-bidi: isolate; }
.hoas-card-sub { color: var(--hoas-muted); font-size: 0.72rem; unicode-bidi: isolate; }
/* A figure is the point of its card: it reads first, and its unit sits with it. */
.hoas-metric { display: flex; align-items: baseline; gap: 0.35rem; margin-block-start: 0.15rem; }
.hoas-metric b { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.hoas-metric span { color: var(--hoas-muted); font-size: 0.75rem; }
.hoas-card-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin-block-start: 0.3rem; }
.hoas-pill { border-radius: 999px; padding: 0.1rem 0.5rem; font-size: 0.66rem; background: var(--hoas-soft); color: var(--hoas-muted); font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.hoas-pill-overdue { background: var(--hoas-danger-soft); color: var(--hoas-danger); }
.hoas-pill-today { background: var(--hoas-warn-soft); color: var(--hoas-warn); }
.hoas-pill-upcoming { background: var(--hoas-ok-soft); color: var(--hoas-ok); }
.hoas-pill-band { background: var(--hoas-accent-soft); color: var(--hoas-accent); font-weight: 700; }
.hoas-open { margin-inline-start: auto; color: var(--hoas-accent); font-size: 0.7rem; font-weight: 700; text-decoration: none; }
.hoas-open:hover { text-decoration: underline; }
.hoas-kv { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.75rem; font-size: 0.76rem; margin-block-start: 0.4rem; }
.hoas-kv span { color: var(--hoas-muted); }
.hoas-timeline { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.76rem; }
.hoas-timeline li { display: flex; flex-direction: column; border-inline-start: 2px solid var(--hoas-border); padding-inline-start: 0.5rem; unicode-bidi: isolate; }

.hoas-fb { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin-block-start: 0.4rem; }
.hoas-fb-wrong { flex: 1 0 100%; }
.hoas-fb-btn { background: none; border: 1px solid var(--hoas-border-strong); border-radius: 999px; padding: 0.1rem 0.45rem; cursor: pointer; font-size: 0.8rem; min-inline-size: 1.75rem; min-block-size: 1.75rem; }
.hoas-fb-wrong summary { cursor: pointer; font-size: 0.7rem; color: var(--hoas-muted); }

.hoas-composer { display: flex; align-items: flex-end; gap: 0.5rem; }
.hoas-input { flex: 1; min-inline-size: 0; border: 1px solid var(--hoas-border-strong); background: var(--hoas-soft); color: var(--hoas-text); border-radius: 0.625rem; padding: 0.5rem 0.75rem; font-size: 0.84rem; resize: vertical; }
.hoas-send { border: 0; border-radius: 0.625rem; background: var(--hoas-accent); color: var(--hoas-accent-ink); font-weight: 700; padding: 0.55rem 0.9rem; font-size: 0.8rem; cursor: pointer; }
.hoas-send:disabled { opacity: 0.6; cursor: wait; }
.hoas-foot { margin: 0; color: var(--hoas-muted); font-size: 0.66rem; }

@media (max-width: 767.98px) {
    .hoas { padding: 0.75rem; }
    .hoas-thread { max-block-size: 22rem; }
    .hoas-bubble { max-inline-size: 100%; }
}
@media (prefers-reduced-motion: reduce) { .hoas * { transition: none !important; } }

/* ── Floating dock: launcher + panel (PO 2026-09-09) ───────────── */
.hoas-dock { position: fixed; inset-block-end: 1.25rem; inset-inline-end: 1.25rem; z-index: 35; display: flex; flex-direction: column; align-items: flex-end; }
.hoas-dock [x-cloak] { display: none !important; }
.hoas-fab { --hoas-fab-bg: #2563eb; display: inline-flex; align-items: center; gap: 0.5rem; border: 0; border-radius: 999px; padding-block: 0.7rem; padding-inline: 0.9rem 1.1rem; background: var(--hoas-fab-bg); color: #fff; font-weight: 700; font-size: 0.85rem; cursor: pointer; box-shadow: 0 10px 30px rgb(37 99 235 / 0.35), 0 2px 6px rgb(0 0 0 / 0.15); position: relative; }
.hoas-fab:hover { --hoas-fab-bg: #1d4ed8; }
.hoas-fab:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.hoas-fab-icon { inline-size: 1.25rem; block-size: 1.25rem; }
.hoas-fab-dot { position: absolute; inset-block-start: 0.35rem; inset-inline-end: 0.5rem; inline-size: 0.5rem; block-size: 0.5rem; border-radius: 999px; background: #fbbf24; box-shadow: 0 0 0 2px var(--hoas-fab-bg); }
.dark .hoas-fab { --hoas-fab-bg: #1d4ed8; }
.dark .hoas-fab:hover { --hoas-fab-bg: #2563eb; }
.dark .hoas-fab:focus-visible { outline-color: #93c5fd; }
.hoas-panel { position: absolute; inset-block-end: 3.75rem; inset-inline-end: 0; /* resolved in the PAGE direction (the panel carries no dir) */ inline-size: min(24rem, calc(100vw - 2rem)); max-block-size: min(70vh, 40rem); max-block-size: min(70dvh, 40rem); box-shadow: 0 20px 50px rgb(0 0 0 / 0.22); }
/* The panel is a HARD box: it never paints outside its own card, whatever
   the thread holds (PO screenshot 2026-09-09 «الكلام طالع بره»). Clipping
   here plus `min-block-size: 0` on every column child is what makes the
   thread scroll instead of the content spilling over the page. */
.hoas-panel { display: flex; overflow: hidden; }
.hoas-inner { display: flex; flex-direction: column; gap: 0.625rem; inline-size: 100%; min-inline-size: 0; min-block-size: 0; }
.hoas-panel .hoas-head, .hoas-panel .hoas-suggest, .hoas-panel .hoas-composer, .hoas-panel .hoas-foot { flex: 0 0 auto; }
.hoas-panel .hoas-thread { max-block-size: none; flex: 1 1 auto; min-block-size: 0; overscroll-behavior: contain; }
.hoas-head-actions { display: flex; align-items: center; gap: 0.5rem; }
.hoas-close { background: none; border: 0; color: var(--hoas-muted); font-size: 1.25rem; line-height: 1; cursor: pointer; padding: 0 0.25rem; min-inline-size: 1.75rem; min-block-size: 1.75rem; }
.hoas-close:hover { color: var(--hoas-text); }
.hoas-enter { transition: opacity 160ms ease, transform 160ms ease; }
.hoas-enter-start { opacity: 0; transform: translateY(0.5rem); }
.hoas-enter-end { opacity: 1; transform: translateY(0); }
/* Above the mobile bottom navigation bar, never behind it. That bar is
   shown by navigation.css up to 1023.98px (z-index 60), so the dock has to
   lift at the SAME breakpoint — at 768–1023px the launcher used to sit
   under the bar and could not be tapped. */
@media (max-width: 1023.98px) {
    .hoas-dock { inset-block-end: calc(5.25rem + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 767.98px) {
    .hoas-dock { inset-inline-end: 0.75rem; }
    .hoas-fab-label { display: none; }
    .hoas-fab { padding: 0.8rem; }
    .hoas-panel { inline-size: calc(100vw - 1.5rem); max-block-size: 75vh; max-block-size: 75dvh; }
}
@media (prefers-reduced-motion: reduce) { .hoas-enter { transition: none; } }

/* ── Observability page ────────────────────────────────────────── */
.hoas-obs { display: flex; flex-direction: column; gap: 1rem; color: var(--hoas-text); }
.hoas-obs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem; }
.hoas-obs-tile { border: 1px solid var(--hoas-border); border-radius: 0.75rem; padding: 0.75rem 0.9rem; background: var(--hoas-card); }
.hoas-obs-tile b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.hoas-obs-tile span { color: var(--hoas-muted); font-size: 0.72rem; }
.hoas-obs table { inline-size: 100%; border-collapse: collapse; font-size: 0.8rem; }
.hoas-obs th, .hoas-obs td { text-align: start; padding: 0.4rem 0.5rem; border-block-end: 1px solid var(--hoas-border); }
.hoas-obs-wrap { overflow-x: auto; }
