/* Alphainno AI Chat: docked on the right of the editor (index.html loads it). Colours follow the
   editor's dark UI: neutral greys, one blue accent. */
:root {
  --ai-w: 380px;
  --ai-bg: #1b1c1f;
  --ai-bg2: #222327;
  --ai-bg3: #2a2b30;
  --ai-line: #303136;
  --ai-text: #e6e6e9;
  --ai-dim: #8d8e95;
  --ai-faint: #5d5e65;
  --ai-accent: #3b7cf6;
  --ai-accent-h: #4d8afa;
  --ai-ok: #3fb950;
  --ai-err: #f0715f;
  --ai-font: 13px/1.55 Inter, system-ui, -apple-system, "Segoe UI", "Noto Sans Bengali", sans-serif;
}
body.ai-open canvas { right: var(--ai-w) !important; width: calc(100% - var(--ai-w)) !important; }

#ai-fab {
  position: fixed; right: 18px; bottom: 34px; z-index: 30; display: flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px; border: 1px solid var(--ai-line); border-radius: 8px; cursor: pointer;
  background: var(--ai-bg2); color: var(--ai-text); font: 600 13px/1 Inter, system-ui, sans-serif;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .7);
}
#ai-fab img { width: 16px; height: 16px; }
body.ai-open #ai-fab, body.ai-ready #ai-fab { display: none; }

#ai-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--ai-w); z-index: 30; display: none; flex-direction: column;
  background: var(--ai-bg); border-left: 1px solid var(--ai-line); color: var(--ai-text); font: var(--ai-font);
  -webkit-font-smoothing: antialiased;
}
body.ai-open #ai-panel { display: flex; animation: ai-in .18s ease-out; }
@keyframes ai-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
#ai-panel * { box-sizing: border-box; }
#ai-panel svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* header */
.ai-head { display: flex; align-items: center; gap: 9px; height: 40px; padding: 0 6px 0 12px; border-bottom: 1px solid var(--ai-line); flex-shrink: 0; background: var(--ai-bg); }
.ai-head img { width: 18px; height: 18px; border-radius: 4px; }
.ai-title { flex: 1; font-weight: 600; font-size: 13px; letter-spacing: .01em; }
.ai-icon { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--ai-dim); cursor: pointer; }
.ai-icon:hover { background: var(--ai-bg3); color: var(--ai-text); }
.ai-icon.on { color: var(--ai-accent); }

/* conversation */
.ai-body { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; scrollbar-color: var(--ai-bg3) transparent; }
.ai-user { align-self: flex-end; max-width: 88%; padding: 8px 12px; border-radius: 10px; background: var(--ai-bg3); white-space: pre-wrap; word-wrap: break-word; }
.ai-reply { display: flex; gap: 9px; align-items: flex-start; }
.ai-reply > img { width: 18px; height: 18px; border-radius: 4px; margin-top: 2px; flex-shrink: 0; }
.ai-reply .txt { flex: 1; min-width: 0; white-space: pre-wrap; word-wrap: break-word; }
.ai-reply code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--ai-bg3); padding: 1px 5px; border-radius: 4px; }
.ai-error { display: flex; gap: 8px; padding: 9px 11px; border-radius: 8px; background: rgba(240, 113, 95, .08); border: 1px solid rgba(240, 113, 95, .25); color: #f5a093; font-size: 12.5px; }

/* tool steps */
.ai-steps { margin-left: 27px; border-left: 1px solid var(--ai-line); padding-left: 10px; display: flex; flex-direction: column; gap: 3px; }
.ai-step { display: flex; align-items: center; gap: 7px; color: var(--ai-dim); font-size: 12px; min-width: 0; }
.ai-step span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-step svg { width: 13px; height: 13px; }
.ai-step.ok svg { color: var(--ai-ok); }
.ai-step.err { color: #e9a196; }
.ai-step.err svg { color: var(--ai-err); }
.ai-step.run svg { color: var(--ai-accent); animation: ai-spin 1s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-thinking { display: flex; gap: 9px; align-items: center; color: var(--ai-dim); font-size: 12.5px; }
.ai-thinking > img { width: 18px; height: 18px; border-radius: 4px; }
.ai-dots { display: inline-flex; gap: 3px; }
.ai-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--ai-dim); animation: ai-dot 1.2s infinite ease-in-out; }
.ai-dots i:nth-child(2) { animation-delay: .15s; } .ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

/* empty state */
.ai-empty { margin: auto 0; padding: 0 8px; text-align: center; }
.ai-empty img { width: 34px; height: 34px; border-radius: 8px; opacity: .95; }
.ai-empty h4 { margin: 12px 0 4px; font-size: 15px; font-weight: 600; }
.ai-empty p { margin: 0; color: var(--ai-dim); font-size: 12.5px; }
.ai-empty .warn { margin-top: 12px; color: #e3b341; font-size: 12px; }

.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 10px; }
.ai-chip { border: 1px solid var(--ai-line); background: transparent; color: var(--ai-text); border-radius: 6px; padding: 5px 9px; font: 12px Inter, system-ui, "Noto Sans Bengali", sans-serif; cursor: pointer; }
.ai-chip:hover { background: var(--ai-bg2); border-color: #44464d; }

/* composer */
.ai-compose { margin: 0 12px 12px; border: 1px solid var(--ai-line); border-radius: 10px; background: var(--ai-bg2); transition: border-color .15s; }
.ai-compose:focus-within { border-color: var(--ai-accent); }
.ai-compose textarea { display: block; width: 100%; resize: none; min-height: 40px; max-height: 160px; padding: 10px 12px 4px; border: 0; background: transparent; color: var(--ai-text); font: var(--ai-font); outline: none; }
.ai-compose textarea::placeholder { color: var(--ai-faint); }
.ai-compose-bar { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 6px 12px; }
.ai-hint { color: var(--ai-faint); font-size: 11px; }
.ai-send { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 7px; background: var(--ai-accent); color: #fff; cursor: pointer; }
.ai-send:hover { background: var(--ai-accent-h); }
.ai-send:disabled { background: var(--ai-bg3); color: var(--ai-faint); cursor: default; }
.ai-send.stop { background: var(--ai-bg3); color: var(--ai-text); }

/* forms (sign in, settings) */
.ai-form { padding: 22px 16px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.ai-form h3 { margin: 0; font-size: 15px; font-weight: 600; }
.ai-form h5 { margin: 14px 0 0; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ai-dim); }
.ai-form p { margin: 0 0 6px; color: var(--ai-dim); font-size: 12.5px; }
.ai-form label { font-size: 11.5px; color: var(--ai-dim); margin-top: 4px; }
.ai-form input, .ai-form select, .ai-form textarea { width: 100%; height: 34px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--ai-line); background: var(--ai-bg2); color: var(--ai-text); font: var(--ai-font); outline: none; }
.ai-form textarea { height: auto; padding: 8px 10px; resize: vertical; }
.ai-form input:focus, .ai-form select:focus, .ai-form textarea:focus { border-color: var(--ai-accent); }
.ai-form .err { color: var(--ai-err); font-size: 12px; min-height: 16px; }
.ai-form .ok { color: var(--ai-ok); font-size: 12px; }
.ai-btn { height: 34px; border: 0; border-radius: 7px; padding: 0 14px; cursor: pointer; font: 600 13px Inter, system-ui, sans-serif; color: #fff; background: var(--ai-accent); }
.ai-btn:hover { background: var(--ai-accent-h); }
.ai-btn:disabled { opacity: .5; cursor: default; }
.ai-btn.ghost { background: var(--ai-bg3); color: var(--ai-text); }
.ai-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ai-brand img { width: 30px; height: 30px; border-radius: 7px; }
.ai-users { width: 100%; border-collapse: collapse; font-size: 12px; }
.ai-users td { padding: 7px 4px; border-bottom: 1px solid var(--ai-line); vertical-align: middle; }
.ai-users .dim { color: var(--ai-dim); }
.ai-keep { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border: 1px solid var(--ai-line); border-radius: 6px; background: transparent; color: var(--ai-dim); font: 12px Inter, system-ui, "Noto Sans Bengali", sans-serif; cursor: pointer; }
.ai-keep:hover { color: var(--ai-text); border-color: #3fb950; }
.ai-keep svg { width: 13px !important; height: 13px !important; color: #3fb950; }
.ai-note { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; background: rgba(63, 185, 80, .08); border: 1px solid rgba(63, 185, 80, .25); color: #9fdcaa; font-size: 12.5px; }
.ai-note svg { margin-top: 2px; color: #3fb950; }
