/* AI Chatbot widget — all rules scoped under .aicb to avoid clashing with Bootstrap/AdminLTE */
/* Every colour is a token, so substituting the official EIL brand values is a change to this
   block alone. */
.aicb { --aicb-accent: #123a6b; --aicb-accent-hover: #0d2b50; --aicb-accent-soft: #eaf0f8; --aicb-highlight: #b5121b; /* used sparingly: recording, errors */ --aicb-bg: #ffffff; --aicb-panel-bg: #f4f6f9; --aicb-user-bg: #123a6b; --aicb-user-fg: #ffffff; --aicb-bot-bg: #ffffff; --aicb-bot-fg: #1c2430; --aicb-muted: #5c6675; --aicb-border: #dde3ea; --aicb-radius: 14px; --aicb-shadow: 0 12px 40px rgba(18, 58, 107, .20); --aicb-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; position: fixed; right: 24px; bottom: 24px; z-index: 1080; font-family: var(--aicb-font); }

/* Launcher */
.aicb__launcher { width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--aicb-accent); color: #fff; cursor: pointer; box-shadow: var(--aicb-shadow); display: grid; place-items: center; transition: transform .15s ease, background .15s ease; }
    .aicb__launcher:hover { background: var(--aicb-accent-hover); transform: translateY(-2px); }
.aicb__launcher-icon { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.aicb__launcher-icon--close { display: none; }
.aicb.is-open .aicb__launcher-icon--chat { display: none; }
.aicb.is-open .aicb__launcher-icon--close { display: block; }

/* Maximised panel.
   The two insets are the HOST PAGE's own chrome: set them to the height of the site header and
   footer so the expanded widget sits between them rather than over them. Left at 0 it covers the
   full viewport, which is right for a page with no fixed chrome. */
.aicb { --aicb-inset-top: 0px; --aicb-inset-bottom: 0px; }

/* Panel */
.aicb__panel { position: absolute; right: 0; bottom: 72px; width: 380px; max-width: calc(100vw - 32px); height: 560px; max-height: calc(100vh - 120px); background: var(--aicb-panel-bg); border: 1px solid var(--aicb-border); border-radius: var(--aicb-radius); box-shadow: var(--aicb-shadow); display: flex; flex-direction: column; overflow: hidden; animation: aicb-in .18s ease; transition: width .24s cubic-bezier(.4, 0, .2, 1), height .24s cubic-bezier(.4, 0, .2, 1); }

/* Width and height are what animate. The panel is anchored bottom-right inside .aicb, so growing
   those two dimensions expands it up and to the left - out of the launcher corner the user just
   clicked. Animating `inset`, or swapping to position:fixed, would not transition at all.

   The subtractions are the panel's own anchoring: .aicb sits 24px from the right edge, and the
   panel 72px above a 24px bottom margin. */
.aicb.is-maximized .aicb__panel { width: calc(100vw - 48px); max-width: calc(100vw - 48px); height: calc(100vh - 96px - var(--aicb-inset-top) - var(--aicb-inset-bottom)); max-height: calc(100vh - 96px - var(--aicb-inset-top) - var(--aicb-inset-bottom)); }

/* One icon at a time. Both sit in the DOM so the toggle needs no scripted markup. */
.aicb__resize-icon--collapse { display: none; }
.aicb.is-maximized .aicb__resize-icon--expand { display: none; }
.aicb.is-maximized .aicb__resize-icon--collapse { display: block; }

/* Reading measure when maximised. 100% means full width: an answer uses the whole panel.
   Kept as a variable rather than deleted, because line length is what makes long text readable
   and a very wide window loses the start of the next line on every wrap. Setting this to a length
   (1100px is about 90 characters at the widget's 14px text) re-introduces a centred column, and
   every rule below follows it without further edits. */
.aicb { --aicb-max-measure: 100%; }

    .aicb.is-maximized .aicb__messages { align-items: center; }
    .aicb.is-maximized .aicb__row { width: 100%; max-width: min(var(--aicb-max-measure), 100%); }

    /* The bubble caps itself as a PERCENTAGE OF THE ROW, so the two caps multiplied: 82% of 820px
   left 672px of text inside an 1860px panel, which is why the expanded view looked empty.
   Overriding the row alone would not have helped - the percentage would simply have taken 82% of
   whatever the row became.

   The user bubble keeps a cap. A question is short so the bubble shrinks to its content anyway,
   but a long one pasted in would otherwise stretch edge to edge and stop reading as a question. */
    .aicb.is-maximized .aicb__row--bot .aicb__bubble { max-width: 100%; }
    .aicb.is-maximized .aicb__row--user .aicb__bubble { max-width: 75%; }

    /* The disclaimer and the composer line up with the text.
   Padding rather than a max-width, so both keep their full-width background: the disclaimer's
   tinted bar and the composer's top border are meant to span the panel. The 16px floor matches
   .aicb__messages' own padding, so the text, the input and the disclaimer all start on the same
   vertical line. At --aicb-max-measure: 100% this resolves to exactly that 16px. */
    .aicb.is-maximized .aicb__disclaimer,
    .aicb.is-maximized .aicb__composer { padding-left: max(16px, calc((100% - var(--aicb-max-measure)) / 2)); padding-right: max(16px, calc((100% - var(--aicb-max-measure)) / 2)); }

@keyframes aicb-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* Header */
.aicb__header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; background: var(--aicb-accent); border-bottom: 1px solid var(--aicb-accent-hover); }
.aicb__brand { display: flex; align-items: center; gap: 8px; }
.aicb__status-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.28); }
.aicb__title { font-weight: 600; font-size: 15px; color: #fff; letter-spacing: .01em; }
.aicb__actions { display: flex; align-items: center; gap: 4px; }
.aicb__icon-btn { width: 32px; height: 32px; border: none; background: transparent; color: rgba(255,255,255,.82); border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
    .aicb__icon-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
    .aicb__icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Permanent scope disclaimer. flex: 0 0 auto keeps it at its natural height while
   .aicb__messages absorbs the remaining space, so it is never compressed and never scrolls out
   of view - the specification requires it to be permanently visible. */
.aicb__disclaimer { flex: 0 0 auto; margin: 0; padding: 8px 12px; background: var(--aicb-accent-soft); border-bottom: 1px solid var(--aicb-border); font-size: 11px; line-height: 1.45; color: var(--aicb-muted); }

/* Messages */
.aicb__messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.aicb__row { display: flex; }
.aicb__row--user { justify-content: flex-end; }
.aicb__row--bot { justify-content: flex-start; }

.aicb__bubble { max-width: 82%; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; unicode-bidi: plaintext; }
.aicb__row--user .aicb__bubble { background: var(--aicb-user-bg); color: var(--aicb-user-fg); border-bottom-right-radius: 4px; }
.aicb__row--bot .aicb__bubble { background: var(--aicb-bot-bg); color: var(--aicb-bot-fg); border: 1px solid var(--aicb-border); border-bottom-left-radius: 4px; }
.aicb__bubble--ungrounded { color: var(--aicb-muted); font-style: italic; }
.aicb__bubble--error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; font-style: normal; }
/* Right-to-left answers (Urdu, Sindhi, Kashmiri). `dir="auto"` on the element makes the browser
   infer direction from the first strong character, and unicode-bidi: plaintext applies the same
   inference per paragraph — so a mixed answer with English terms still lays out correctly. */
.aicb__bubble[dir="rtl"] { text-align: right; }
    .aicb__bubble[dir="rtl"] .aicb__cites { justify-content: flex-end; }
    .aicb__bubble[dir="rtl"] .aicb__list { padding-right: 1rem; padding-left: 0; }

/* Citations */
.aicb__cites { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.aicb__cite { display: inline-flex; align-items: center; gap: 5px; background: #eef2ff; color: #3730a3; border: 1px solid #e0e7ff; padding: 3px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; max-width: 100%; }
    .aicb__cite b { font-weight: 700; }
.aicb__cite-doc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.aicb__cite-ref { color: #6366f1; }

/* Typing indicator */
.aicb__typing { display: inline-flex; gap: 4px; padding: 12px; }
    .aicb__typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--aicb-muted); opacity: .4; animation: aicb-blink 1.2s infinite; }
        .aicb__typing span:nth-child(2) { animation-delay: .2s; }
        .aicb__typing span:nth-child(3) { animation-delay: .4s; }

@keyframes aicb-blink {
    0%, 60%, 100% { opacity: .25; }
    30% { opacity: 1; }
}

/* Composer */
.aicb__composer { display: flex; align-items: flex-end; gap: 8px; padding: 12px; background: var(--aicb-bg); border-top: 1px solid var(--aicb-border); }
.aicb__input { flex: 1; resize: none; border: 1px solid var(--aicb-border); border-radius: 10px; padding: 9px 12px; font: inherit; font-size: 14px; line-height: 1.4; max-height: 120px; outline: none; background: #fff; color: var(--aicb-bot-fg); }
    .aicb__input:focus { border-color: var(--aicb-accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.aicb__send { width: 40px; height: 40px; flex: 0 0 auto; border: none; border-radius: 10px; background: var(--aicb-accent); color: #fff; cursor: pointer; display: grid; place-items: center; transition: background .15s ease; }
    .aicb__send:hover:not(:disabled) { background: var(--aicb-accent-hover); }
    .aicb__send:disabled { opacity: .45; cursor: not-allowed; }
    .aicb__send svg { width: 18px; height: 18px; fill: currentColor; }
    .aicb__send svg { transform: scaleX(-1); }

.aicb__empty { margin: auto; text-align: center; padding: 20px 22px; }
.aicb__empty-title { margin: 0 0 8px; font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--aicb-bot-fg); }
.aicb__empty-text { margin: 0; font-size: 13px; line-height: 1.55; color: var(--aicb-muted); }
/* Separated from the body copy so the disclaimer reads as a standing note rather than part of
   the invitation to ask something. */
.aicb__empty-note { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--aicb-border); font-size: 11.5px; color: var(--aicb-muted); }

@media (max-width: 480px) {
    .aicb { right: 12px; bottom: 12px; }
    .aicb__panel { width: calc(100vw - 24px); height: calc(100vh - 90px); bottom: 68px; }

    /* Already effectively full screen, so the control has nothing to do. Hidden rather than
       disabled: a button that visibly does nothing is worse than no button. */
    .aicb__icon-btn--resize { display: none; }
}

/* Inline citation links ([S#] markers rendered by renderAnswerWithLinks) */
.aicb__cite-link { display: inline-flex; align-items: center; justify-content: center; vertical-align: super; font-size: 10px; line-height: 1; font-weight: 600; padding: 1px 4px; margin: 0 1px; border-radius: 5px; color: var(--aicb-accent, #2563eb); background: #eef2ff; border: 1px solid #e0e7ff; text-decoration: none; cursor: pointer; transition: background .12s ease, color .12s ease; white-space: nowrap; }
    .aicb__cite-link:hover { background: var(--aicb-accent, #2563eb); color: #fff; border-color: var(--aicb-accent, #2563eb); text-decoration: none; }
.aicb__source-link { color: var(--aicb-accent, #2563eb); text-decoration: underline; word-break: break-all; }

.aicb__list { margin-top: 4px; }
    .aicb__list li { margin-bottom: 4px; }
    .aicb__list ol { margin-top: 4px; }

/* ---------------- voice input / output ---------------- */

/* Both controls stay hidden until the JS confirms the browser supports the API, so an
   unsupported browser shows no dead buttons rather than ones that silently do nothing. */
/* Sits on the navy header, so it is drawn as a translucent chip rather than a form control:
   a default select renders white and would pull the eye away from the title. */
.aicb__lang { max-width: 7rem; padding: .22rem 1.35rem .22rem .45rem; border: 1px solid rgba(255, 255, 255, .32); border-radius: .4rem; background-color: rgba(255, 255, 255, .12); color: #fff; font-family: inherit; font-size: .76rem; line-height: 1.3; cursor: pointer; -webkit-appearance: none; appearance: none; /* Chevron drawn inline so the control needs no image asset and follows the text colour. */ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .35rem center; background-size: .7rem; }

    .aicb__lang:hover { background-color: rgba(255, 255, 255, .2); }

    .aicb__lang:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

    /* The dropdown list itself is painted by the OS, which ignores the translucent background —
       so the options need explicit colours or they render white-on-white. */
    .aicb__lang option { background: #fff; color: var(--aicb-bot-fg); }

.aicb__mic { align-self: flex-end; flex: 0 0 auto; width: 2.25rem; height: 2.25rem; margin: 0 .25rem .2rem 0; padding: .4rem; border: none; border-radius: 50%; background: transparent; color: var(--aicb-muted); cursor: pointer; }

    .aicb__mic svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

    .aicb__mic:hover:not(:disabled) { background: var(--aicb-accent-soft); color: var(--aicb-accent); }
    .aicb__mic:disabled { opacity: .45; cursor: default; }

/* Recording is signalled by colour AND motion: colour alone is not enough to tell someone
   their microphone is live. aria-pressed carries the same state to a screen reader. */
.aicb__mic--recording { color: #fff; background: var(--aicb-highlight); animation: aicb-pulse 1.4s ease-in-out infinite; }

    .aicb__mic--recording:hover { background: #8f0e15; }

@keyframes aicb-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(181, 18, 27, .55); }
    50% { box-shadow: 0 0 0 .35rem rgba(181, 18, 27, 0); }
}

/* Interim speech is shown in the input as it arrives so the user can see it being heard,
   but marked as provisional until recognition settles. */
.aicb__input--interim { color: var(--aicb-muted); font-style: italic; }

.aicb__listen { display: inline-flex; align-items: center; gap: .3rem; margin-top: .45rem; padding: .2rem .5rem; border: 1px solid var(--aicb-border); border-radius: 1rem; background: #fff; font-size: .75rem; color: var(--aicb-muted); cursor: pointer; }

    .aicb__listen:hover { background: var(--aicb-accent-soft); border-color: var(--aicb-accent); color: var(--aicb-accent); }
    .aicb__listen svg { width: .85rem; height: .85rem; fill: none; stroke: currentColor; stroke-width: 2; }
/* Its own line under the answer, whatever ends the answer: an inline button sat on the last line
   of text when the answer ended in a run of prose rather than a block. */
.aicb__listen { display: flex; width: fit-content; }

.aicb__listen--speaking { border-color: var(--aicb-highlight); color: var(--aicb-highlight); background: #fdf2f3; }

@media (prefers-reduced-motion: reduce) {
    .aicb__mic--recording { animation: none; }

    /* The size change still happens, it just happens at once. */
    .aicb__panel { transition: none; }
}
