/* ARI chat widget — theme-aware via REAL NOW tokens.
   Site-wide via base_rn.html (every page including admin). */

.rn-ari {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 2147483640;
  font-family: var(--rn-font-sans, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}

.rn-ari[hidden] { display: none !important; }

/* Critical: panel + chip strip use display:flex which overrides the browser's
   default [hidden] { display:none }. Re-assert so close/clear buttons actually
   hide the panel when JS sets .hidden = true. */
.rn-ari__panel[hidden],
.rn-ari__suggested[hidden] { display: none !important; }

/* ── Toggle button (always-visible call-to-action) ───────────────────────────── */
.rn-ari__toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  background: linear-gradient(135deg, var(--rn-gold-500, #d4a574), var(--rn-gold-400, #e0b585));
  color: #1a1a1a;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 32px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(212, 165, 116, 0.45),
              0 6px 12px rgba(0, 0, 0, 0.25),
              0 0 0 6px rgba(212, 165, 116, 0.15);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  animation: rn-ari-pulse 2.6s ease-in-out 1.5s 3;
}
.rn-ari__toggle:hover {
  transform: translateY(-3px) scale(1.04);
  filter: brightness(1.05);
  box-shadow: 0 18px 36px rgba(212, 165, 116, 0.55),
              0 8px 16px rgba(0, 0, 0, 0.30),
              0 0 0 8px rgba(212, 165, 116, 0.20);
  animation: none;
}
.rn-ari__toggle:focus-visible {
  outline: 3px solid var(--rn-gold-300, #ebc89c);
  outline-offset: 3px;
  animation: none;
}
.rn-ari__toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}
.rn-ari.is-open .rn-ari__toggle { display: none; }

/* Soft attention pulse — fires 3 times then stops so it's not annoying */
@keyframes rn-ari-pulse {
  0%, 100% {
    box-shadow: 0 12px 28px rgba(212, 165, 116, 0.45),
                0 6px 12px rgba(0, 0, 0, 0.25),
                0 0 0 6px rgba(212, 165, 116, 0.15);
  }
  50% {
    box-shadow: 0 12px 28px rgba(212, 165, 116, 0.55),
                0 6px 12px rgba(0, 0, 0, 0.30),
                0 0 0 18px rgba(212, 165, 116, 0.05);
  }
}

@media (max-width: 480px) {
  .rn-ari { bottom: 16px; right: 16px; }
  .rn-ari__toggle-label { display: none; }
  .rn-ari__toggle {
    padding: 0;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    justify-content: center;
  }
  .rn-ari__toggle-icon { width: 26px; height: 26px; }
}

/* ── Panel ───────────────────────────── */
.rn-ari__panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: min(380px, calc(100vw - 36px));
  height: min(600px, calc(100vh - 90px));
  background: var(--rn-bg-card);
  color: var(--rn-text);
  border: 1px solid var(--rn-border-soft);
  border-radius: var(--rn-radius-card, 12px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), 0 8px 16px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
[data-theme="light"] .rn-ari__panel {
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.16), 0 8px 16px rgba(0, 0, 0, 0.08);
}

/* ── Header ───────────────────────────── */
.rn-ari__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rn-border-soft);
  background: var(--rn-bg-elev-1, var(--rn-bg-card));
}
.rn-ari__title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.rn-ari__avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rn-gold-500, #d4a574), var(--rn-gold-400, #e0b585));
  color: #1a1a1a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.6px;
}
.rn-ari__title-text { min-width: 0; }
.rn-ari__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--rn-text);
  line-height: 1.2;
}
.rn-ari__subtitle {
  margin: 2px 0 0 0;
  font-size: 11px;
  color: var(--rn-text-muted);
  line-height: 1.2;
}
.rn-ari__actions { display: inline-flex; gap: 4px; }
.rn-ari__icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--rn-text-muted);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.rn-ari__icon-btn:hover {
  background: var(--rn-tint-soft);
  color: var(--rn-text);
}

/* ── Log ───────────────────────────── */
.rn-ari__log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rn-ari__log::-webkit-scrollbar { width: 6px; }
.rn-ari__log::-webkit-scrollbar-thumb {
  background: var(--rn-border-soft);
  border-radius: 3px;
}

.rn-ari-msg {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.rn-ari-msg--assistant {
  align-self: flex-start;
  background: var(--rn-bg-elev-1, var(--rn-tint-soft));
  border: 1px solid var(--rn-border-soft);
  color: var(--rn-text);
  border-bottom-left-radius: 4px;
}
.rn-ari-msg--user {
  align-self: flex-end;
  background: var(--rn-gold-500, #d4a574);
  color: #1a1a1a;
  border-bottom-right-radius: 4px;
}
.rn-ari-msg p { margin: 0 0 6px 0; }
.rn-ari-msg p:last-child { margin-bottom: 0; }
.rn-ari-msg a {
  color: var(--rn-gold-300, #ebc89c);
  text-decoration: underline;
  font-weight: 500;
}
.rn-ari-msg--user a { color: #1a1a1a; font-weight: 600; }
.rn-ari-msg ul,
.rn-ari-msg ol { margin: 4px 0 4px 18px; padding: 0; }
.rn-ari-msg li { margin: 2px 0; }
.rn-ari-msg strong { font-weight: 600; }
.rn-ari-msg code {
  background: var(--rn-tint-soft);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
  font-family: ui-monospace, "SF Mono", monospace;
}

.rn-ari-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  background: var(--rn-bg-elev-1, var(--rn-tint-soft));
  border: 1px solid var(--rn-border-soft);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.rn-ari-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--rn-text-muted);
  animation: rn-ari-bounce 1.2s infinite;
}
.rn-ari-typing span:nth-child(2) { animation-delay: 0.15s; }
.rn-ari-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes rn-ari-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* ── Suggested chips ───────────────────────────── */
.rn-ari__suggested {
  padding: 8px 16px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.rn-ari__chip {
  background: transparent;
  border: 1px solid var(--rn-border-soft);
  color: var(--rn-text);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  font-family: inherit;
}
.rn-ari__chip:hover {
  background: var(--rn-tint-soft);
  border-color: var(--rn-gold-500, #d4a574);
  color: var(--rn-gold-300, #ebc89c);
}

/* ── Form ───────────────────────────── */
.rn-ari__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--rn-border-soft);
  background: var(--rn-bg-elev-1, var(--rn-bg-card));
}
.rn-ari__input {
  flex: 1 1 auto;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  padding: 8px 12px;
  background: var(--rn-bg-card);
  color: var(--rn-text);
  border: 1px solid var(--rn-border-soft);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s ease;
}
.rn-ari__input:focus {
  border-color: var(--rn-gold-500, #d4a574);
}
.rn-ari__send {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--rn-gold-500, #d4a574);
  color: #1a1a1a;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  flex: 0 0 38px;
}
.rn-ari__send:hover { background: var(--rn-gold-400, #e0b585); transform: scale(1.05); }
.rn-ari__send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.rn-ari__disclaimer {
  margin: 0;
  padding: 6px 16px 10px;
  font-size: 10.5px;
  color: var(--rn-text-muted);
  text-align: center;
  border-top: 1px solid var(--rn-border-soft);
  background: var(--rn-bg-elev-1, var(--rn-bg-card));
  opacity: 0.85;
  line-height: 1.35;
}

/* Mobile: full-screen panel */
@media (max-width: 480px) {
  .rn-ari__panel {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}
