/**
 * ai-chatboxes — SELF-CONTAINED client red chat widget styles.
 * =============================================================================
 * SA-1 wave (architecture correction): "chat is the PLUGIN, not the theme."
 * The plugin must render the client-facing red ArneIron chat widget on its own,
 * independent of the arneiron-g theme + its ds.css. This stylesheet PORTS the
 * minimal red "pix-theme-tone-arneiron" palette + CRT look + the
 * chat-window/launcher/composer/thread/bubble styles out of the theme's ds.css
 * (§8 CHAT block) and SCOPES every rule under `.arnyiron-chat-root` so it:
 *   - is fully self-contained (its own --c-* / --grad-* / --sh-* tokens — never
 *     reads the theme's :root or its body.pix-theme-tone-arneiron class);
 *   - cannot leak onto / collide with the host theme (all rules are descendants
 *     of .arnyiron-chat-root, the only un-prefixed selector is the launcher FAB
 *     + its own crt scrim, both plugin-namespaced);
 *   - matches the EXACT class contract the existing live driver
 *     (public/js/arnyiron-chat-live.js, U03) binds to: .chat-window / .chat-head
 *     + [data-status-bind] + .status-dot / .chat-thread[data-ai-chat-mount] /
 *     .composer + input + .send / .msg + .bubble (--user/--agent) / .alert--error.
 *
 * REVERSIBILITY: enqueued only by Arnyiron_Chat_Widget; removing that enqueue (or
 * deactivating the plugin) drops every rule. No !important, no global resets.
 *
 * @package ai-chatboxes
 */

/* ----- scoped design tokens (ported from arneiron-g ds.css :root) ---------- */
.arnyiron-chat-root {
  --acw-base:        #050203;
  --acw-obsidian:    #020402;
  --acw-panel:       #100608;
  --acw-panel-2:     #18090b;
  --acw-panel-3:     #210d10;
  --acw-oxblood:     #1a0306;
  --acw-maroon:      #4a080c;
  --acw-signal:      #ff2a2a;
  --acw-hot:         #ff6030;
  --acw-whitehot:    #ffe1d2;
  --acw-ink:         #ffd5cd;
  --acw-ink-dim:     #c4847e;
  --acw-ink-faint:   #b06a5e;
  --acw-grid:        #2c1012;
  --acw-grid-2:      #3c1618;
  --acw-green:       #00ff41;
  --acw-green-dark:  #003b00;
  --acw-amber:       #ffb300;
  --acw-error:       #ff3228;
  --acw-glow-red:    rgba(255,42,42,.55);
  --acw-glow-red-soft: rgba(255,42,42,.22);
  --acw-glow-green:  rgba(0,255,65,.45);
  --acw-glow-amber:  rgba(255,179,0,.45);
  --acw-grad-primary: linear-gradient(180deg, #ff6030 0%, #ff2a2a 38%, #8c1014 100%);
  --acw-grad-primary-hover: linear-gradient(180deg, #ff8a4a 0%, #ff3a3a 40%, #b01418 100%);
  --acw-grad-panel:  linear-gradient(180deg, #18090b 0%, #0c0608 100%);
  --acw-grad-panel-up: linear-gradient(180deg, #210d10 0%, #120709 100%);
  --acw-grad-user-bubble: linear-gradient(180deg, #5a0e12 0%, #2a0508 100%);
  --acw-grad-agent-bubble: linear-gradient(180deg, #1a090b 0%, #0e0608 100%);
  --acw-sh-glow-soft: 0 0 8px var(--acw-glow-red-soft);
  --acw-f-display: 'Orbitron', 'Rajdhani', sans-serif;
  --acw-f-ui:      'Rajdhani', sans-serif;
  --acw-f-mono:    'Share Tech Mono', ui-monospace, monospace;
  --acw-sp-2: 8px; --acw-sp-3: 12px; --acw-sp-4: 16px; --acw-sp-5: 24px;
  --acw-fs-xs: 12px; --acw-fs-sm: 13px; --acw-fs-md: 15px; --acw-fs-lg: 18px;
  --acw-t-fast: 90ms;
}

/* =========================================================================
 * FLOATING LAUNCHER (FAB) — plugin-owned, no theme equivalent.
 * ========================================================================= */
.arnyiron-chat-fab {
  position: fixed; z-index: 1100;
  right: 24px; bottom: 24px;
  width: 60px; height: 60px;
  display: grid; place-items: center;
  cursor: pointer; border: 2px solid var(--acw-whitehot, #ffe1d2);
  color: #050203; background: linear-gradient(180deg, #ff6030 0%, #ff2a2a 38%, #8c1014 100%);
  box-shadow: 4px 4px 0 0 #1a0306, 0 0 12px rgba(255,42,42,.55);
  font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 26px; line-height: 1;
  transition: transform 90ms steps(4,end), box-shadow 90ms steps(4,end), background 160ms ease;
}
.arnyiron-chat-fab:hover { background: linear-gradient(180deg, #ff8a4a 0%, #ff3a3a 40%, #b01418 100%); }
.arnyiron-chat-fab:active { transform: translate(4px,4px); box-shadow: 0 0 0 0 #1a0306, 0 0 12px rgba(255,42,42,.55); }
.arnyiron-chat-fab::before {
  content: ""; position: absolute; left: 3px; right: 3px; top: 3px; height: 1px;
  background: #ffe1d2; opacity: .9;
}
.arnyiron-chat-fab .acw-fab-ico { pointer-events: none; }
.arnyiron-chat-fab[aria-expanded="true"] { display: none; }

/* =========================================================================
 * THE DOCKED CHAT PANEL (wraps the .arnyiron-chat-root .chat-window).
 * ========================================================================= */
.arnyiron-chat-root.arnyiron-chat-dock {
  position: fixed; z-index: 1100;
  right: 24px; bottom: 24px;
  width: 380px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 48px);
  box-shadow: 6px 6px 0 0 #1a0306, 0 0 18px rgba(255,42,42,.35);
}
.arnyiron-chat-root.arnyiron-chat-dock[hidden] { display: none; }

/* Inline (shortcode/block) placement: fill the host container at a sane height. */
.arnyiron-chat-root.arnyiron-chat-inline {
  display: block; width: 100%; min-height: 520px; height: 70vh;
  background: var(--acw-base); color: var(--acw-ink);
}

/* =========================================================================
 * CHAT WINDOW (ported from ds.css §8, scoped + tokenized to --acw-*).
 * ========================================================================= */
.arnyiron-chat-root .chat-window {
  display: flex; flex-direction: column; height: 100%;
  background: var(--acw-grad-panel); border: 2px solid var(--acw-grid-2);
  position: relative; color: var(--acw-ink);
  font-family: var(--acw-f-ui);
}
.arnyiron-chat-root .chat-head {
  display: flex; align-items: center; gap: var(--acw-sp-3); height: 56px; padding: 0 var(--acw-sp-4);
  border-bottom: 2px solid var(--acw-signal);
  background: linear-gradient(180deg,#18090b,#0c0608);
}
.arnyiron-chat-root .chat-head .title {
  font-family: var(--acw-f-display); font-weight: 700; font-size: var(--acw-fs-lg);
  letter-spacing: 2px; color: var(--acw-ink);
}
.arnyiron-chat-root .chat-head .spacer { flex: 1; }
.arnyiron-chat-root .status-dot {
  width: 9px; height: 9px; display: inline-block; background: var(--acw-green);
  box-shadow: 0 0 8px var(--acw-glow-green);
}
.arnyiron-chat-root .status-dot.is-connecting,
.arnyiron-chat-root .status-dot.connecting { background: var(--acw-amber); box-shadow: 0 0 8px var(--acw-glow-amber); }
.arnyiron-chat-root .status-dot.is-error,
.arnyiron-chat-root .status-dot.error { background: var(--acw-error); box-shadow: 0 0 8px var(--acw-glow-red); }
.arnyiron-chat-root .status-dot.is-ok { background: var(--acw-green); box-shadow: 0 0 8px var(--acw-glow-green); }
.arnyiron-chat-root .status-label {
  font-family: var(--acw-f-mono); font-size: var(--acw-fs-xs); letter-spacing: 1px; color: var(--acw-ink-dim);
}
.arnyiron-chat-root .chat-close {
  background: none; border: none; color: var(--acw-ink-faint); font-size: 22px; line-height: 1;
  cursor: pointer; padding: 0 4px;
}
.arnyiron-chat-root .chat-close:hover { color: var(--acw-signal); }

.arnyiron-chat-root .chat-thread {
  flex: 1; overflow-y: auto; padding: var(--acw-sp-5);
  display: flex; flex-direction: column; gap: var(--acw-sp-4);
}

/* bubbles */
.arnyiron-chat-root .bubble {
  max-width: 82%; position: relative; padding: var(--acw-sp-3) var(--acw-sp-4);
  font-family: var(--acw-f-ui); font-size: var(--acw-fs-md); line-height: 1.5;
  border: 2px solid var(--acw-grid-2); word-wrap: break-word; overflow-wrap: anywhere;
}
.arnyiron-chat-root .msg { display: flex; gap: var(--acw-sp-3); align-items: flex-start; }
.arnyiron-chat-root .msg--agent { align-self: flex-start; }
.arnyiron-chat-root .msg--user { flex-direction: row-reverse; align-self: flex-end; }
.arnyiron-chat-root .bubble--agent {
  background: var(--acw-grad-agent-bubble); border-color: var(--acw-grid-2);
  border-left: 2px solid var(--acw-signal); color: var(--acw-ink);
}
.arnyiron-chat-root .bubble--user {
  background: var(--acw-grad-user-bubble); border-color: var(--acw-signal); color: var(--acw-whitehot);
}
.arnyiron-chat-root .bubble--error { border-color: var(--acw-error); color: var(--acw-hot); }

/* composer */
.arnyiron-chat-root .composer {
  display: flex; align-items: stretch; gap: var(--acw-sp-2); padding: var(--acw-sp-4);
  border-top: 2px solid var(--acw-grid-2); background: var(--acw-obsidian);
}
.arnyiron-chat-root .composer .field-wrap {
  flex: 1; position: relative; display: flex; align-items: center;
  background: var(--acw-grad-panel); border: 2px solid var(--acw-grid-2);
}
.arnyiron-chat-root .composer.is-focus .field-wrap { border-color: var(--acw-signal); box-shadow: var(--acw-sh-glow-soft); }
.arnyiron-chat-root .composer.is-gated .field-wrap { border-color: var(--acw-amber); }
.arnyiron-chat-root .composer input[type=text],
.arnyiron-chat-root .composer textarea {
  flex: 1; background: transparent; border: none; outline: none; color: var(--acw-ink);
  font-family: var(--acw-f-mono); font-size: var(--acw-fs-md); padding: 12px 8px; resize: none;
}
.arnyiron-chat-root .composer .estimate {
  position: absolute; top: 4px; right: 8px; font-family: var(--acw-f-mono);
  font-size: var(--acw-fs-xs); color: var(--acw-green); border: 1px solid var(--acw-green-dark); padding: 1px 6px;
}
.arnyiron-chat-root .composer .send {
  flex: none; cursor: pointer; user-select: none;
  font-family: var(--acw-f-ui); font-weight: 700; font-size: var(--acw-fs-md);
  letter-spacing: 1px; text-transform: uppercase;
  padding: 0 18px; border: 2px solid var(--acw-whitehot); border-radius: 0;
  color: var(--acw-base); background: var(--acw-grad-primary);
  box-shadow: 3px 3px 0 0 var(--acw-oxblood);
  transition: transform var(--acw-t-fast) steps(4,end), background 160ms ease;
}
.arnyiron-chat-root .composer .send:hover { background: var(--acw-grad-primary-hover); }
.arnyiron-chat-root .composer .send:active { transform: translate(3px,3px); box-shadow: none; }
.arnyiron-chat-root .composer .send[disabled] {
  cursor: not-allowed; color: #604c4a; border-color: var(--acw-grid-2);
  background: linear-gradient(180deg,#28161788,#180b0c); box-shadow: none; transform: none;
}

/* alerts (gate notice) */
.arnyiron-chat-root .alert {
  display: flex; gap: var(--acw-sp-3); padding: var(--acw-sp-3) var(--acw-sp-4); position: relative;
  font-family: var(--acw-f-mono); font-size: var(--acw-fs-sm); border: 2px solid var(--acw-grid-2);
  color: var(--acw-ink-dim); background: var(--acw-grad-panel);
}
.arnyiron-chat-root .alert--error { border-color: var(--acw-error); color: var(--acw-hot); }

/* the live thread surface the U03 driver creates inside the mount */
.arnyiron-chat-root .arnyiron-live-thread {
  display: flex; flex-direction: column; gap: var(--acw-sp-4); width: 100%;
}

/* a subtle CRT scanline scrim over the docked panel only (self-contained) */
.arnyiron-chat-root .acw-crt {
  position: absolute; inset: 0; pointer-events: none; z-index: 2; mix-blend-mode: normal;
}
.arnyiron-chat-root .acw-crt::before {
  content: ""; position: absolute; inset: 0;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.26) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255,42,42,.03) 0 1px, transparent 1px 3px);
  opacity: .85;
}
.arnyiron-chat-root .acw-crt::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 120% at 50% 50%, transparent 58%, rgba(0,0,0,.5) 100%);
}

@media (max-width: 520px) {
  .arnyiron-chat-root.arnyiron-chat-dock {
    right: 8px; left: 8px; bottom: 8px; width: auto; height: 72vh;
  }
  .arnyiron-chat-fab { right: 12px; bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .arnyiron-chat-fab { transition: none; }
}
