
/* ── RH AI Filter Designer chat panel ─────────────────────────────────── */
.rh-ai-panel {
  position: fixed; right: 18px; bottom: 18px; z-index: 1200;
  width: 420px; max-width: 94vw; height: 560px; max-height: 80vh;
  display: flex; flex-direction: column;
  background: var(--bg-secondary, #111); border: 1px solid #a78bfa55;
  border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  font-size: 13px;
}
.rh-ai-panel.hidden { display: none; }
.rh-ai-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid var(--border-color, #333);
  color: #a78bfa; font-weight: 600;
}
.rh-ai-msgs { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.rh-ai-msg { padding: 8px 10px; border-radius: 8px; line-height: 1.45; word-wrap: break-word; }
.rh-ai-user { background: #a78bfa22; align-self: flex-end; max-width: 88%; }
.rh-ai-assistant { background: var(--bg-tertiary, #1c1c1c); align-self: flex-start; max-width: 94%; }
.rh-ai-assistant code { background: #0006; padding: 1px 4px; border-radius: 4px; font-size: 12px; }
.rh-ai-error { border: 1px solid #ef444488; color: #ef4444; }
.rh-ai-tools { align-self: flex-start; padding: 0; background: none; }
.rh-ai-chip {
  display: inline-block; padding: 2px 8px; margin: 1px 2px; border-radius: 10px;
  background: #a78bfa18; border: 1px solid #a78bfa44; color: #a78bfa; font-size: 11px;
}
.rh-ai-chip-err { border-color: #ef444488; color: #ef4444; background: #ef444418; }
.rh-ai-inputrow { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border-color, #333); }
.rh-ai-inputrow textarea {
  flex: 1; resize: none; background: var(--bg-tertiary, #1c1c1c);
  border: 1px solid var(--border-color, #333); border-radius: 6px;
  color: var(--text-primary, #eee); padding: 7px 9px; font-size: 13px; font-family: inherit;
}
.rh-ai-waiting { opacity: .75; font-style: italic; }
.rh-ai-dots::after { content: ''; animation: rhAiDots 1.2s steps(4) infinite; }
@keyframes rhAiDots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* AI panel expand mode + starters + growing textarea */
.rh-ai-panel.rh-ai-max { width: 760px; max-width: 96vw; height: 86vh; max-height: 92vh; }
.rh-ai-inputrow textarea { max-height: 220px; overflow-y: auto; }
.rh-ai-starters { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 0; background: none; }
.rh-ai-starters .rh-ai-chip { cursor: pointer; font-family: inherit; }
.rh-ai-starters .rh-ai-chip:hover { background: #a78bfa33; }
.rh-ai-model { font-weight: 400; font-size: 11px; color: var(--text-secondary, #888); margin-left: 6px; }

/* AI provider settings view */
.rh-ai-settings { padding: 14px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.rh-ai-settings.hidden { display: none; }
.rh-ai-set-title { color: #a78bfa; font-weight: 600; margin-bottom: 4px; }
.rh-ai-settings label { font-size: 12px; color: var(--text-secondary, #999); margin-top: 6px; }
.rh-ai-set-note { font-weight: 400; opacity: .7; }
.rh-ai-settings select, .rh-ai-settings input {
  background: var(--bg-tertiary, #1c1c1c); border: 1px solid var(--border-color, #333);
  border-radius: 6px; color: var(--text-primary, #eee); padding: 7px 9px; font-size: 13px; font-family: inherit;
}
.rh-ai-set-btns { margin-top: 10px; }
.rh-ai-set-status { font-size: 12px; min-height: 16px; margin-top: 4px; }
.rh-ai-set-ok { color: #00C805; }
.rh-ai-set-err { color: #ef4444; }
#rhAiKeyFields { display: flex; flex-direction: column; gap: 6px; }
#rhAiKeyFields.hidden { display: none; }
.rh-ai-set-text { font-size: 12px; line-height: 1.5; color: var(--text-secondary, #aaa); }
.rh-ai-set-text code { background: #0006; padding: 1px 4px; border-radius: 4px; font-size: 11px; }
.rh-ai-linkrow { display: flex; gap: 6px; margin: 6px 0; }
.rh-ai-linkrow input { flex: 1; font-size: 11px; }
#rhAiLinkBox.hidden { display: none; }

/* AI panel: draggable header + native corner resize */
.rh-ai-panel { resize: both; overflow: hidden; min-width: 320px; min-height: 300px; }
.rh-ai-head { cursor: move; user-select: none; touch-action: none; }
.rh-ai-head button { cursor: pointer; }
.rh-ai-panel { max-width: 98vw; max-height: 96vh; }

/* AI panel edge/corner resize handles (invisible hit strips) */
.rh-ai-rs { position: absolute; z-index: 6; }
.rh-ai-rs-n  { top: -3px; left: 12px; right: 12px; height: 8px; }
.rh-ai-rs-s  { bottom: -3px; left: 12px; right: 12px; height: 8px; }
.rh-ai-rs-e  { right: -3px; top: 12px; bottom: 12px; width: 8px; }
.rh-ai-rs-w  { left: -3px; top: 12px; bottom: 12px; width: 8px; }
.rh-ai-rs-ne { top: -3px; right: -3px; width: 16px; height: 16px; }
.rh-ai-rs-nw { top: -3px; left: -3px; width: 16px; height: 16px; }
.rh-ai-rs-se { bottom: -3px; right: -3px; width: 16px; height: 16px; }
.rh-ai-rs-sw { bottom: -3px; left: -3px; width: 16px; height: 16px; }

/* AI connect wizard */
.rh-ai-appbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.rh-ai-appbtns button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px 8px; border-radius: 8px; cursor: pointer; font-family: inherit;
  background: var(--bg-tertiary, #1c1c1c); border: 1px solid #a78bfa44;
  color: var(--text-primary, #eee); font-size: 14px; font-weight: 600;
}
.rh-ai-appbtns button:hover { border-color: #a78bfa; background: #a78bfa18; }
.rh-ai-appbtns button span { font-size: 11px; font-weight: 400; color: var(--text-secondary, #888); }
.rh-ai-steps { margin: 10px 0 6px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; font-size: 13px; line-height: 1.5; }
.rh-ai-steps li::marker { color: #a78bfa; font-weight: 700; }
.rh-ai-openbtn {
  display: inline-block; margin-top: 6px; padding: 7px 12px; border-radius: 6px;
  background: #a78bfa22; border: 1px solid #a78bfa66; color: #a78bfa;
  text-decoration: none; font-size: 13px;
}
.rh-ai-openbtn:hover { background: #a78bfa33; }
.rh-ai-step-done { color: #00C805; font-size: 12px; margin: 6px 0; }
#rhAiConnectSteps .rh-ai-linkrow { margin-top: 6px; }

/* Connect wizard: single big action button + caption */
.rh-ai-bigbtn {
  display: block; width: 100%; margin: 12px 0 10px; padding: 16px;
  border-radius: 10px; border: 0; cursor: pointer; font-family: inherit;
  background: #a78bfa; color: #14141b; font-size: 15px; font-weight: 700;
}
.rh-ai-bigbtn:hover { background: #b99cff; }
.rh-ai-caption { font-size: 13px; line-height: 1.6; color: var(--text-secondary, #aaa); margin-bottom: 10px; }
.rh-ai-caption b { color: var(--text-primary, #eee); }
.rh-ai-linkrow-small { opacity: .65; }
.rh-ai-linkrow-small input { font-size: 10px; }
.rh-ai-logo { width: 16px; height: 16px; vertical-align: -3px; margin-right: 2px; }
.rh-ai-loading { padding: 18px 14px; font-size: 13px; color: var(--text-secondary, #888); }

/* ── Lane awareness (chat can be scoped to any terminal/product area) ──── */
.rh-ai-lane {
  font-size: 10px; padding: 1px 7px; border-radius: 9px; margin-left: 6px;
  background: #a78bfa22; border: 1px solid #a78bfa55; color: #a78bfa;
  vertical-align: 1px; white-space: nowrap;
}
/* Entry button on settings pages (bots page panel headers) */
.rh-ai-open-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: #a78bfa14; border: 1px solid #a78bfa88; color: #a78bfa;
  border-radius: 6px; padding: 5px 12px; font-size: 12px; cursor: pointer;
  font-family: inherit; transition: background .15s, border-color .15s;
}
.rh-ai-open-btn:hover { background: #a78bfa2e; border-color: #a78bfa; }
.rh-ai-locked-note {
  padding: 8px 10px; border-radius: 8px; line-height: 1.45;
  background: #a78bfa11; border: 1px solid #a78bfa33; color: var(--text-secondary, #aaa);
}

/* Own-AI connected default view (built-in chat is admin-only since 2026-08-17) */
#rhAiConnected { margin-bottom: 8px; }
.rh-ai-conn-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; margin-top: 6px; border-radius: 8px;
  background: var(--bg-tertiary, #1c1c1c); border: 1px solid #00C80544; font-size: 13px;
}
.rh-ai-conn-row .rh-ai-openbtn { margin-top: 0; white-space: nowrap; }

/* ── "Your AI updated your filters" banner (2026-08-17) ───────────────── */
.rh-ai-changebar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1199;
  display: flex; align-items: center; gap: 8px; max-width: 94vw;
  padding: 8px 10px 8px 12px; border-radius: 10px;
  background: var(--bg-secondary, #111); border: 1px solid #a78bfa88;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); color: var(--text-primary, #eee); font-size: 13px;
}
.rh-ai-changebar.hidden { display: none; }
.rh-ai-changetext { flex: 1; min-width: 0; line-height: 1.35; }
.rh-ai-changetext b { color: #a78bfa; }
.rh-ai-changeago { opacity: .6; font-size: 12px; white-space: nowrap; }
.rh-ai-changebtn {
  padding: 4px 10px; border-radius: 6px; border: 1px solid #a78bfa66; background: #a78bfa22; color: #a78bfa;
  font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.rh-ai-changebtn:hover { background: #a78bfa33; }
.rh-ai-changebtn:disabled { opacity: .5; cursor: default; }
.rh-ai-changeundo { border-color: #f59e0b66; background: #f59e0b1a; color: #f59e0b; }
.rh-ai-changeundo:hover { background: #f59e0b2a; }
.rh-ai-changeclose { border: none; background: none; color: #888; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; }
.rh-ai-changeclose:hover { color: #eee; }
@media (max-width: 640px) { .rh-ai-changebar { left: 8px; right: 8px; transform: none; max-width: none; flex-wrap: wrap; } }
