/* Help assistant widget (Views/Shared/_ChatbotWidget.cshtml + js/chatbot.js). Self-contained: every rule is scoped
   to .sbot so it never leaks into or inherits from the host page. --sbot-brand comes from OrganizationConfig. */

.sbot {
    --sbot-brand: #0B5D3B;
    --sbot-surface: #ffffff;
    --sbot-subtle: #f4f6f8;
    --sbot-border: #e3e7ec;
    --sbot-text: #1b2128;
    --sbot-muted: #66707c;
    --sbot-bot-bubble: #f1f3f6;
    --sbot-shadow: 0 18px 48px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .08);
    --sbot-danger: #b42318;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1080;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--sbot-text);
}

html[data-theme="dark"] .sbot {
    --sbot-surface: #1b1f24;
    --sbot-subtle: #23282f;
    --sbot-border: #323941;
    --sbot-text: #e8eaed;
    --sbot-muted: #a1a8b3;
    --sbot-bot-bubble: #262c33;
    --sbot-shadow: 0 18px 48px rgba(0, 0, 0, .5);
    --sbot-danger: #f97066;
}

.sbot *, .sbot *::before, .sbot *::after { box-sizing: border-box; }
.sbot button { font: inherit; }
.sbot .sbot-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Launcher ── */
.sbot-launcher {
    width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--sbot-brand); color: #fff; box-shadow: 0 8px 24px rgba(15, 23, 42, .25);
    display: flex; align-items: center; justify-content: center; margin-left: auto;
    transition: transform .18s ease, box-shadow .18s ease;
}
.sbot-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(15, 23, 42, .3); }
.sbot-launcher:focus-visible { outline: 3px solid color-mix(in srgb, var(--sbot-brand) 40%, transparent); outline-offset: 3px; }
.sbot-launcher .sbot-icon-close { display: none; }
.sbot.is-open .sbot-launcher .sbot-icon-open { display: none; }
.sbot.is-open .sbot-launcher .sbot-icon-close { display: block; }

.sbot-nudge {
    position: absolute; right: 70px; bottom: 14px; white-space: nowrap;
    background: var(--sbot-surface); color: var(--sbot-text); border: 1px solid var(--sbot-border);
    padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; box-shadow: var(--sbot-shadow);
    animation: sbot-in .25s ease;
}

/* ── Panel ── */
.sbot-panel {
    position: absolute; right: 0; bottom: 72px;
    width: 380px; height: min(620px, calc(100vh - 110px));
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--sbot-surface); border: 1px solid var(--sbot-border); border-radius: 18px; box-shadow: var(--sbot-shadow);
    animation: sbot-in .2s ease;
}
.sbot-panel[hidden] { display: none; }
@keyframes sbot-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.sbot-header { display: flex; align-items: center; gap: 10px; padding: 14px 12px 14px 16px; background: var(--sbot-brand); color: #fff; }
.sbot-avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 255, 255, .18); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sbot-heading { flex: 1; min-width: 0; }
.sbot-heading h2 { margin: 0; font-size: 15px; font-weight: 700; color: #fff; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sbot-heading p { margin: 0; font-size: 12px; opacity: .85; color: #fff; }
.sbot-icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.sbot-icon-btn:hover { background: rgba(255, 255, 255, .15); }
.sbot-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ── Conversation ── */
.sbot-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; background: var(--sbot-surface); }
.sbot-row { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.sbot-row.from-user { justify-content: flex-end; }
.sbot-bubble { max-width: 86%; padding: 9px 13px; border-radius: 16px; word-wrap: break-word; overflow-wrap: anywhere; }
.from-bot .sbot-bubble { background: var(--sbot-bot-bubble); color: var(--sbot-text); border-bottom-left-radius: 5px; }
.from-user .sbot-bubble { background: var(--sbot-brand); color: #fff; border-bottom-right-radius: 5px; }
.sbot-bubble p { margin: 0 0 6px; }
.sbot-bubble p:last-child { margin-bottom: 0; }
.sbot-bubble.is-error { background: color-mix(in srgb, var(--sbot-danger) 12%, var(--sbot-surface)); color: var(--sbot-danger); }

.sbot-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.sbot-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--sbot-muted); animation: sbot-blink 1s infinite ease-in-out; }
.sbot-typing span:nth-child(2) { animation-delay: .15s; }
.sbot-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes sbot-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Choice lists (topics, guides, search results) */
.sbot-choices { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.sbot-choice {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
    padding: 10px 12px; border-radius: 12px; border: 1px solid var(--sbot-border); background: var(--sbot-surface); color: var(--sbot-text);
    transition: border-color .15s, background .15s;
}
.sbot-choice:hover { border-color: var(--sbot-brand); background: color-mix(in srgb, var(--sbot-brand) 6%, var(--sbot-surface)); }
.sbot-choice:focus-visible { outline: 2px solid var(--sbot-brand); outline-offset: 1px; }
.sbot-choice-icon { width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--sbot-brand) 12%, var(--sbot-surface)); color: var(--sbot-brand); font-size: 14px; }
html[data-theme="dark"] .sbot-choice-icon { color: color-mix(in srgb, var(--sbot-brand) 55%, #fff); }
.sbot-choice-text { flex: 1; min-width: 0; }
.sbot-choice-text strong { display: block; font-size: 13.5px; font-weight: 600; }
.sbot-choice-text small { display: block; font-size: 12px; color: var(--sbot-muted); }
.sbot-choice-arrow { color: var(--sbot-muted); flex-shrink: 0; }

/* Quick replies (chips) */
.sbot-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sbot-chip {
    border: 1px solid color-mix(in srgb, var(--sbot-brand) 45%, var(--sbot-border)); background: var(--sbot-surface); color: var(--sbot-text);
    padding: 6px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; font-weight: 500;
}
.sbot-chip:hover { background: color-mix(in srgb, var(--sbot-brand) 8%, var(--sbot-surface)); }
.sbot-chip:focus-visible { outline: 2px solid var(--sbot-brand); outline-offset: 1px; }
.sbot-chip.is-primary { background: var(--sbot-brand); border-color: var(--sbot-brand); color: #fff; }

/* Guide card */
.sbot-guide { width: 100%; border: 1px solid var(--sbot-border); border-radius: 14px; overflow: hidden; background: var(--sbot-surface); }
.sbot-guide-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--sbot-border); }
.sbot-guide-head h3 { margin: 0 0 2px; font-size: 14.5px; font-weight: 700; color: var(--sbot-text); }
.sbot-guide-head p { margin: 0; font-size: 13px; color: var(--sbot-muted); }
.sbot-steps { list-style: none; margin: 0; padding: 10px 14px; counter-reset: sbot-step; }
.sbot-steps li { position: relative; padding: 0 0 9px 32px; counter-increment: sbot-step; font-size: 13.5px; }
.sbot-steps li:last-child { padding-bottom: 2px; }
.sbot-steps li::before {
    content: counter(sbot-step); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%;
    background: color-mix(in srgb, var(--sbot-brand) 12%, var(--sbot-surface)); color: var(--sbot-brand); font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
html[data-theme="dark"] .sbot-steps li::before { color: color-mix(in srgb, var(--sbot-brand) 55%, #fff); }
.sbot-tips { margin: 0 14px 10px; padding: 9px 11px; border-radius: 10px; background: var(--sbot-subtle); font-size: 12.5px; color: var(--sbot-muted); }
.sbot-tips ul { margin: 0; padding-left: 16px; }
.sbot-tips strong.sbot-tips-title { display: block; color: var(--sbot-text); font-size: 12px; margin-bottom: 2px; }
.sbot-guide-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px; }
.sbot-link {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 9px; font-size: 13px; font-weight: 600;
    text-decoration: none; border: 1px solid var(--sbot-border); color: var(--sbot-text); background: var(--sbot-surface);
}
.sbot-link:hover { border-color: var(--sbot-brand); color: var(--sbot-text); text-decoration: none; }
.sbot-link.is-primary { background: var(--sbot-brand); border-color: var(--sbot-brand); color: #fff; }
.sbot-link.is-primary:hover { color: #fff; filter: brightness(1.08); }

/* Contact card */
.sbot-contact { width: 100%; border: 1px solid var(--sbot-border); border-radius: 14px; padding: 12px 14px; background: var(--sbot-surface); }
.sbot-contact h3 { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.sbot-contact-row { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; border-top: 1px solid var(--sbot-border); font-size: 13px; }
.sbot-contact-row:first-of-type { border-top: 0; }
.sbot-contact-row svg { flex-shrink: 0; margin-top: 2px; color: var(--sbot-brand); }
html[data-theme="dark"] .sbot-contact-row svg { color: color-mix(in srgb, var(--sbot-brand) 55%, #fff); }
.sbot-contact-row a { color: var(--sbot-text); font-weight: 600; text-decoration: none; word-break: break-word; }
.sbot-contact-row a:hover { text-decoration: underline; }
.sbot-contact-row small { display: block; color: var(--sbot-muted); font-size: 11.5px; }
.sbot-contact-note { margin: 8px 0 0; font-size: 12px; color: var(--sbot-muted); }

/* ── Composer & footer ── */
.sbot-composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--sbot-border); background: var(--sbot-surface); }
.sbot-composer input {
    flex: 1; min-width: 0; border: 1px solid var(--sbot-border); border-radius: 999px; padding: 9px 14px; font: inherit; font-size: 14px;
    background: var(--sbot-subtle); color: var(--sbot-text); outline: none;
}
.sbot-composer input:focus { border-color: var(--sbot-brand); background: var(--sbot-surface); }
.sbot-composer button {
    width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; flex-shrink: 0;
    background: var(--sbot-brand); color: #fff; display: flex; align-items: center; justify-content: center;
}
.sbot-composer button:disabled { opacity: .45; cursor: default; }
.sbot-footer { display: flex; border-top: 1px solid var(--sbot-border); background: var(--sbot-subtle); }
.sbot-footer button {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 6px; border: 0; background: transparent;
    color: var(--sbot-muted); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.sbot-footer button + button { border-left: 1px solid var(--sbot-border); }
.sbot-footer button:hover { color: var(--sbot-brand); }
html[data-theme="dark"] .sbot-footer button:hover { color: #fff; }

/* ── Phones: full screen ── */
@media (max-width: 520px) {
    .sbot { right: 14px; bottom: 14px; }
    .sbot.is-open .sbot-launcher { display: none; }
    .sbot-panel { position: fixed; inset: 0; width: 100%; height: 100%; border-radius: 0; border: 0; }
    .sbot-nudge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sbot-panel, .sbot-nudge { animation: none; }
    .sbot-log { scroll-behavior: auto; }
    .sbot-launcher { transition: none; }
}

@media print { .sbot { display: none !important; } }
