/* LINK AI — resident PWA. Deliberately dependency-free plain CSS (no Tailwind) so the resident
   bundle stays tiny and offline-cacheable, fully separate from the Filament/admin assets. */
:root {
    /* We ship a real dark theme below — tell the browser so it renders native controls (caret,
       autofill, scrollbars) for the active scheme and does NOT force-dark the page on top of ours. */
    color-scheme: light dark;
    --navy: #0B2447;
    --green: #1FA98A;
    --green-deep: #178a71;
    --card: #F2F4F6;
    --ink: #10233d;
    --muted: #5b6b7f;
    --line: #e3e8ee;
    --radius: 14px;
    --maxw: 640px;
    font-family: Inter, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Naskh Arabic", sans-serif;
}

[x-cloak] { display: none !important; }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--card);
    color: var(--ink);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100dvh;
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: var(--maxw);
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: #fff;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--navy);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 5;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 1.05rem; letter-spacing: .2px; }
.brand-icon { display: block; }
.lang { display: flex; gap: 4px; }
.lang-btn {
    border: 0; background: transparent; color: #b9c6da;
    font: inherit; font-size: .74rem; font-weight: 600;
    padding: 5px 7px; border-radius: 8px; cursor: pointer;
}
.lang-btn.active { background: rgba(255,255,255,.14); color: #fff; }

/* Offline banner */
.offline {
    background: #b4432f; color: #fff; text-align: center;
    padding: 8px 12px; font-size: .85rem;
}

/* Install (add-to-home-screen) hint — subtle, dismissible, opt-in */
.install-hint {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: #eef6f3; border-bottom: 1px solid #cfe7df;
    padding: 9px 14px; font-size: .82rem; color: #234; line-height: 1.4;
}
.install-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.install-add {
    border: 0; background: var(--green); color: #fff; font: inherit; font-weight: 600; font-size: .8rem;
    padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.install-add:hover { background: var(--green-deep); }
.install-dismiss {
    border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .8rem;
    padding: 6px 8px; border-radius: 8px; cursor: pointer;
}

/* Screens */
.screen { flex: 1; padding: 18px 16px 28px; display: flex; flex-direction: column; }
.tagline { margin: 4px 0 14px; color: var(--muted); font-size: .95rem; }
.h1 { font-size: 1.15rem; margin: 6px 0 12px; }
.muted { color: var(--muted); }

.notice {
    background: #eef6f3; border: 1px solid #cfe7df; border-inline-start: 4px solid var(--green);
    color: #234; border-radius: 10px; padding: 12px 14px; font-size: .84rem; line-height: 1.5;
}
.notice.small { font-size: .78rem; padding: 8px 12px; margin-bottom: 4px; }

.error-box {
    background: #fdecea; border: 1px solid #f4c9c2; border-radius: 10px;
    padding: 12px 14px; display: flex; align-items: center; gap: 12px; justify-content: space-between;
    font-size: .88rem; color: #7a2418;
}

/* Centre list */
.centre-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.centre-btn {
    width: 100%; text-align: start; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 15px 16px; font: inherit; font-size: 1rem; font-weight: 500;
    color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: space-between;
    transition: border-color .12s, background .12s;
}
.centre-btn:hover, .centre-btn:focus-visible { border-color: var(--green); background: #eef6f3; outline: none; }
.chev { color: var(--green); font-size: 1.4rem; line-height: 1; }

.btn-ghost {
    background: transparent; border: 0; color: var(--green-deep); font: inherit; font-weight: 600;
    cursor: pointer; padding: 6px 4px;
}

/* Chat */
.chat { padding-bottom: 0; }
.chat-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.centre-name { font-size: .98rem; }

.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px 2px; }
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }
.bubble {
    padding: 10px 13px; border-radius: 16px; font-size: .95rem; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word;
}
.msg.user .bubble { background: var(--green); color: #fff; border-bottom-right-radius: 5px; }
.msg.assistant .bubble { background: var(--card); color: var(--ink); border-bottom-left-radius: 5px; }
.cites { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.cite { font-size: .7rem; color: var(--muted); background: #eef2f6; border: 1px solid var(--line); border-radius: 20px; padding: 2px 8px; }

/* Wayfinding photos under an answer */
.media { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photo { margin: 0; max-width: 220px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.photo img { display: block; width: 100%; height: auto; }
.photo figcaption { padding: 6px 9px; font-size: .78rem; color: var(--ink); }
.photo .loc { display: block; color: var(--green-deep); margin-top: 2px; }

.typing { display: inline-flex; gap: 4px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: #9fb0c2; animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* Composer */
.composer {
    display: flex; gap: 8px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
    position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line);
}
.composer-input {
    flex: 1; border: 1px solid var(--line); border-radius: 22px; padding: 12px 16px; font: inherit; font-size: 1rem;
    background: var(--card); color: var(--ink);
}
.composer-input:focus-visible { outline: none; border-color: var(--green); background: #fff; }
.composer-send {
    border: 0; background: var(--green); color: #fff; font: inherit; font-weight: 600; font-size: .95rem;
    padding: 0 20px; border-radius: 22px; cursor: pointer;
}
.composer-send:disabled { background: #b7c6d1; cursor: default; }
.composer-send:not(:disabled):hover { background: var(--green-deep); }

@media (prefers-color-scheme: dark) {
    :root { --card: #16202e; --ink: #eaf0f6; --muted: #9fb0c2; --line: #263447; }
    html, body { background: #0d1520; }
    #app { background: #101a26; }
    .notice { background: #12241f; border-color: #1d3a31; color: #cfe7df; }
    .install-hint { background: #12241f; border-color: #1d3a31; color: #cfe7df; }
    .error-box { background: #2a1512; border-color: #5a251c; color: #f0b8ad; }
    .composer, .app-header { background: #101a26; }
    .composer { border-color: var(--line); }
    .composer-input { background: #16202e; }

    /* The light-mode rules below paint LIGHT backgrounds that the dark palette never overrode, so the
       (now light) --ink / --muted text sat on near-white and became unreadable. Keep them dark. */
    .composer-input:focus-visible { background: #1b2838; }          /* focused question field (the reported bug) */
    .centre-btn:hover, .centre-btn:focus-visible { background: #1b2838; }
    .cite { background: #1a2736; }
    .composer-send:disabled { background: #33475e; color: #8fa3b8; }
}
