/* Support chatbot widget (partials/chatbot_widget.html, js/chatbot.js) */
.cb-root {
    --cb-accent: var(--t-600, #4f46e5);
    --cb-bg: #ffffff; --cb-surface: #f6f7fb; --cb-border: #e5e7eb; --cb-text: #0f172a; --cb-muted: #64748b;
    --cb-bot: #f1f5f9; --cb-chip: var(--t-50, #eef2ff); --cb-chip-text: var(--t-800, #3730a3);
    position: fixed; bottom: 22px; right: 22px; z-index: 1050; font-family: inherit;
}
.cb-root.cb-left { right: auto; left: 22px; }
html[data-bs-theme="dark"] .cb-root, html.dark-theme .cb-root {
    --cb-bg: #161b22; --cb-surface: #0d1117; --cb-border: #30363d; --cb-text: #e6edf3; --cb-muted: #8b949e;
    --cb-bot: #21262d; --cb-chip: rgba(var(--t-400-rgb, 129, 140, 248), .16); --cb-chip-text: var(--t-200, #c7d2fe);
}
/* keep the back-to-top button clear of the launcher */
body:has(.cb-root.cb-right) .back-to-top { bottom: 92px; }

.cb-launcher {
    width: 58px; height: 58px; border-radius: 50%; border: none; background: var(--cb-accent); color: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .28); display: flex; align-items: center; justify-content: center;
    font-size: 24px; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; position: relative;
}
.cb-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 32px rgba(15, 23, 42, .32); }
.cb-launcher:focus-visible { outline: 3px solid rgba(var(--t-500-rgb, 99, 102, 241), .45); outline-offset: 3px; }
.cb-launcher .cb-ic-close { display: none; font-size: 20px; }
.cb-root.is-open .cb-launcher .cb-ic-open { display: none; }
.cb-root.is-open .cb-launcher .cb-ic-close { display: inline-block; }

.cb-panel {
    position: absolute; bottom: 72px; right: 0; width: 370px; height: min(600px, calc(100vh - 120px));
    background: var(--cb-bg); color: var(--cb-text); border: 1px solid var(--cb-border); border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28); display: flex; flex-direction: column; overflow: hidden;
    transform-origin: bottom right; animation: cb-pop .18s ease-out;
}
.cb-left .cb-panel { right: auto; left: 0; transform-origin: bottom left; }
.cb-panel[hidden] { display: none; }
@keyframes cb-pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }

.cb-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: var(--cb-accent); color: #fff; }
.cb-avatar { width: 38px; height: 38px; border-radius: 12px; background: rgba(255, 255, 255, .18); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.cb-head-text { flex: 1; min-width: 0; }
.cb-title { font-weight: 700; font-size: 15px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-status { font-size: 11.5px; opacity: .85; display: flex; align-items: center; gap: 6px; }
.cb-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; }
.cb-icon-btn { border: none; background: transparent; color: #fff; width: 32px; height: 32px; border-radius: 8px; font-size: 16px; opacity: .9; }
.cb-icon-btn:hover { background: rgba(255, 255, 255, .16); opacity: 1; }

.cb-body { flex: 1; overflow-y: auto; padding: 14px; background: var(--cb-surface); display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.cb-msg { display: flex; flex-direction: column; max-width: 88%; }
.cb-msg.cb-user { align-self: flex-end; align-items: flex-end; }
.cb-msg.cb-bot { align-self: flex-start; }
.cb-bubble { padding: 9px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; word-wrap: break-word; overflow-wrap: anywhere; }
.cb-user .cb-bubble { background: var(--cb-accent); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.cb-bot .cb-bubble { background: var(--cb-bot); color: var(--cb-text); border-bottom-left-radius: 4px; }
.cb-bubble p { margin: 0 0 6px; } .cb-bubble p:last-child { margin-bottom: 0; }
.cb-bubble ul { margin: 4px 0 6px; padding-left: 18px; } .cb-bubble li { margin: 2px 0; }
.cb-bubble a { color: var(--cb-accent); font-weight: 600; text-decoration: underline; }
html[data-bs-theme="dark"] .cb-bot .cb-bubble a, html.dark-theme .cb-bot .cb-bubble a { color: var(--t-300, #a5b4fc); }
.cb-meta { font-size: 10.5px; color: var(--cb-muted); margin-top: 3px; display: flex; align-items: center; gap: 8px; }
.cb-fb { border: none; background: none; color: var(--cb-muted); padding: 0 2px; font-size: 12px; line-height: 1; }
.cb-fb:hover, .cb-fb.on { color: var(--cb-accent); }
.cb-tag { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: var(--cb-chip); color: var(--cb-chip-text); }

.cb-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cb-link { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
    border: 1px solid var(--cb-border); background: var(--cb-bg); color: var(--cb-text); text-decoration: none; max-width: 100%; }
.cb-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-link:hover { border-color: var(--cb-accent); color: var(--cb-accent); }

.cb-chips { display: flex; gap: 6px; padding: 8px 12px 0; overflow-x: auto; background: var(--cb-bg); scrollbar-width: none; }
.cb-chips::-webkit-scrollbar { display: none; }
.cb-chips:empty { display: none; }
.cb-chip { flex-shrink: 0; border: none; font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 999px; background: var(--cb-chip); color: var(--cb-chip-text); }
.cb-chip:hover { filter: brightness(.96); }

.cb-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; background: var(--cb-bg); border-top: 1px solid var(--cb-border); margin-top: 8px; }
.cb-form textarea { flex: 1; resize: none; border: 1px solid var(--cb-border); border-radius: 12px; padding: 9px 12px; font-size: 13.5px;
    max-height: 110px; background: var(--cb-surface); color: var(--cb-text); outline: none; line-height: 1.4; }
.cb-form textarea:focus { border-color: var(--cb-accent); }
.cb-send { width: 40px; height: 40px; border-radius: 12px; border: none; background: var(--cb-accent); color: #fff; flex-shrink: 0; font-size: 15px; }
.cb-send:disabled { opacity: .5; }
.cb-foot { font-size: 10.5px; color: var(--cb-muted); text-align: center; padding: 0 12px 8px; background: var(--cb-bg); }

.cb-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.cb-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--cb-muted); animation: cb-blink 1.2s infinite ease-in-out; }
.cb-typing i:nth-child(2) { animation-delay: .15s; } .cb-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes cb-blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.cb-notice { margin: auto 0; text-align: center; padding: 18px 10px; color: var(--cb-muted); font-size: 13.5px; }
.cb-notice i { font-size: 34px; display: block; margin-bottom: 8px; color: var(--cb-accent); }
.cb-notice .cb-links { justify-content: center; }

.cb-card { background: var(--cb-bg); border: 1px solid var(--cb-border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 7px; }
.cb-card input, .cb-card textarea { border: 1px solid var(--cb-border); border-radius: 8px; padding: 7px 10px; font-size: 13px; background: var(--cb-surface); color: var(--cb-text); width: 100%; }
.cb-card textarea { resize: vertical; min-height: 64px; }
.cb-card .cb-err { color: #dc2626; font-size: 12px; }
.cb-btn { border: none; border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; background: var(--cb-accent); color: #fff; }
.cb-btn:disabled { opacity: .6; }

@media (max-width: 480px) {
    .cb-root { bottom: 14px; right: 14px; }
    .cb-root.cb-left { left: 14px; }
    .cb-panel { position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; border: none; }
    .cb-root.is-open .cb-launcher { display: none; }
}
@media (prefers-reduced-motion: reduce) { .cb-panel, .cb-typing i { animation: none; } .cb-body { scroll-behavior: auto; } }
