/* On-site help + live chat widget. Self-contained; injected via base.html. */
.cn-chat {
  --cn-brand: #13342a;
  --cn-brand-ink: #f4f9e4;
  --cn-accent: #2fae82;
  --cn-panel: #ffffff;
  --cn-ink: #16211c;
  --cn-muted: #64726b;
  --cn-line: #e4e6e1;
  --cn-bubble: #f1f4f1;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.cn-chat-launcher {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--cn-brand);
  color: var(--cn-brand-ink);
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  display: grid;
  place-items: center;
  transition: transform .15s;
}
.cn-chat-launcher:hover { transform: translateY(-2px); }
.cn-chat-launcher .cn-ic-close { display: none; }
.cn-chat.is-open .cn-chat-launcher .cn-ic-chat { display: none; }
.cn-chat.is-open .cn-chat-launcher .cn-ic-close { display: block; }

.cn-chat-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--cn-panel);
  border: 1px solid var(--cn-line);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cn-pop .16s ease-out;
}
/* The panel is toggled via the [hidden] attribute. Because the rule above sets
   `display: flex`, it would otherwise beat the UA default `[hidden]{display:none}`
   and the panel could never actually hide — so restore hiding explicitly. */
.cn-chat-panel[hidden] { display: none; }
@keyframes cn-pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.cn-chat-head {
  background: var(--cn-brand);
  color: var(--cn-brand-ink);
  padding: 15px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cn-chat-head strong { display: block; font-size: .98rem; }
.cn-chat-status { font-size: .76rem; opacity: .78; }
.cn-chat-min { background: none; border: none; color: var(--cn-brand-ink); font-size: 1.4rem; line-height: 1; cursor: pointer; opacity: .8; }
.cn-chat-min:hover { opacity: 1; }

.cn-chat-scroll { flex: 1 1 auto; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; color: var(--cn-ink); }
.cn-bot-bubble {
  background: var(--cn-bubble);
  border-radius: 4px 14px 14px 14px;
  padding: 12px 14px;
  font-size: .9rem;
  line-height: 1.5;
  max-width: 92%;
}

.cn-suggestions { display: flex; flex-wrap: wrap; gap: 7px; }
.cn-suggestions button {
  background: #fff;
  border: 1px solid var(--cn-line);
  color: var(--cn-brand);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
}
.cn-suggestions button:hover { border-color: var(--cn-accent); }

.cn-results { display: flex; flex-direction: column; gap: 10px; }
.cn-result {
  border: 1px solid var(--cn-line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}
.cn-result .cn-result-src { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--cn-accent); font-weight: 700; }
.cn-result .cn-result-q { font-weight: 700; font-size: .88rem; margin: 3px 0 4px; }
.cn-result .cn-result-a { font-size: .84rem; line-height: 1.5; color: var(--cn-muted); }
.cn-result a.cn-result-link { display: inline-block; margin-top: 8px; font-size: .8rem; color: var(--cn-brand); font-weight: 700; text-decoration: none; }
.cn-result a.cn-result-link:hover { text-decoration: underline; }
.cn-noresult { font-size: .86rem; color: var(--cn-muted); }

/* Live chat mode */
.cn-live { display: flex; flex-direction: column; gap: 10px; }
.cn-msg { max-width: 85%; padding: 10px 13px; border-radius: 13px; font-size: .88rem; line-height: 1.45; }
.cn-msg .cn-msg-t { display: block; font-size: .66rem; color: var(--cn-muted); margin-top: 4px; }
.cn-msg.visitor { align-self: flex-end; background: var(--cn-brand); color: var(--cn-brand-ink); border-radius: 13px 13px 4px 13px; }
.cn-msg.visitor .cn-msg-t { color: rgba(244, 249, 228, .7); }
.cn-msg.staff, .cn-msg.bot { align-self: flex-start; background: var(--cn-bubble); border-radius: 13px 13px 13px 4px; }
.cn-msg.system { align-self: center; background: transparent; color: var(--cn-muted); font-size: .76rem; font-style: italic; }

.cn-chat-foot { border-top: 1px solid var(--cn-line); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.cn-search-form { display: flex; gap: 8px; align-items: center; }
.cn-search-form input[type="text"] {
  flex: 1 1 auto;
  border: 1px solid var(--cn-line);
  border-radius: 999px;
  padding: 10px 15px;
  font: inherit;
  font-size: .88rem;
  color: var(--cn-ink);
  background: #fff;
}
.cn-search-form input:focus { outline: 2px solid var(--cn-accent); border-color: transparent; }
.cn-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.cn-send {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--cn-accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.cn-send:hover { filter: brightness(1.06); }
.cn-talk {
  background: none;
  border: none;
  color: var(--cn-brand);
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 2px;
  align-self: center;
}
.cn-talk:hover { text-decoration: underline; }
.cn-talk[hidden] { display: none; }

@media (prefers-color-scheme: dark) {
  .cn-chat {
    --cn-panel: #12211b;
    --cn-ink: #eaf3ee;
    --cn-muted: #9db8ac;
    --cn-line: #26473c;
    --cn-bubble: #163028;
  }
  .cn-suggestions button, .cn-result, .cn-search-form input { background: #0e1c16; }
}
