/* customeAI chat widget: sticky bottom right bubble + panel. Brand: Onyx, Circuit Bronze, Gold. */
.cai-chat {
  --cai-gold: #F0C24C;
  --cai-bronze: #AC7A34;
  --cai-ink: #05060a;
  --cai-text: #f4f1ea;
  --cai-muted: rgba(244, 241, 234, 0.62);
  --cai-border: rgba(255, 255, 255, 0.14);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  font-family: "Inter", system-ui, sans-serif;
  color: var(--cai-text);
}
.cai-chat *, .cai-chat *::before, .cai-chat *::after { box-sizing: border-box; }

.cai-chat__bubble {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(240, 194, 76, 0.55);
  background: linear-gradient(145deg, var(--cai-gold), var(--cai-bronze));
  color: var(--cai-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55), 0 0 0 0 rgba(240, 194, 76, 0.4);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.cai-chat__bubble:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 0 6px rgba(240, 194, 76, 0.16); }
.cai-chat__bubble:focus-visible, .cai-chat__send:focus-visible, .cai-chat__close:focus-visible { outline: 2px solid var(--cai-gold); outline-offset: 3px; }
.cai-chat__bubble svg { width: 40px; height: 40px; }
.cai-chat.is-open .cai-chat__bubble { display: none; }

.cai-chat__panel {
  display: none;
  flex-direction: column;
  width: 380px;
  height: min(560px, calc(100svh - 40px));
  background: rgba(10, 12, 20, 0.94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--cai-border);
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}
.cai-chat.is-open .cai-chat__panel { display: flex; animation: cai-pop 0.18s ease-out; }
@keyframes cai-pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

.cai-chat__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--cai-border);
  background: linear-gradient(180deg, rgba(240, 194, 76, 0.1), rgba(240, 194, 76, 0));
}
.cai-chat__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cai-gold); box-shadow: 0 0 10px rgba(240, 194, 76, 0.8); flex: none; }
.cai-chat__title { font-family: "Space Grotesk", system-ui, sans-serif; font-weight: 700; font-size: 15px; letter-spacing: 0.01em; margin: 0; flex: 1; }
.cai-chat__close {
  width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--cai-muted);
  display: grid; place-items: center; cursor: pointer; font-size: 22px; line-height: 1;
}
.cai-chat__close:hover { background: rgba(255, 255, 255, 0.08); color: var(--cai-text); }

.cai-chat__notice { margin: 0; padding: 8px 16px; font-size: 12px; line-height: 1.4; color: var(--cai-muted); border-bottom: 1px solid var(--cai-border); }

.cai-chat__log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.cai-chat__msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cai-chat__msg--bot { align-self: flex-start; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--cai-border); border-bottom-left-radius: 4px; }
.cai-chat__msg--user { align-self: flex-end; background: linear-gradient(145deg, var(--cai-gold), var(--cai-bronze)); color: var(--cai-ink); border-bottom-right-radius: 4px; font-weight: 500; }
.cai-chat__msg--error { align-self: flex-start; background: rgba(255, 120, 90, 0.1); border: 1px solid rgba(255, 120, 90, 0.35); color: #ffd4c8; border-bottom-left-radius: 4px; }

.cai-chat__typing { align-self: flex-start; display: flex; gap: 5px; padding: 12px 14px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--cai-border); border-radius: 14px; border-bottom-left-radius: 4px; }
.cai-chat__typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--cai-muted); animation: cai-blink 1.1s infinite ease-in-out; }
.cai-chat__typing span:nth-child(2) { animation-delay: 0.18s; }
.cai-chat__typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes cai-blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.cai-chat__form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--cai-border); }
.cai-chat__input {
  flex: 1;
  min-height: 42px;
  max-height: 110px;
  resize: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--cai-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--cai-text);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
}
.cai-chat__input::placeholder { color: rgba(244, 241, 234, 0.4); }
.cai-chat__input:focus { outline: none; border-color: rgba(240, 194, 76, 0.7); box-shadow: 0 0 0 3px rgba(240, 194, 76, 0.15); }
.cai-chat__send {
  height: 42px; padding: 0 16px; border-radius: 12px; border: 0; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 700;
  background: linear-gradient(145deg, var(--cai-gold), var(--cai-bronze)); color: var(--cai-ink);
}
.cai-chat__send:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 600px) {
  .cai-chat { right: 12px; bottom: 12px; }
  .cai-chat__panel { width: calc(100vw - 24px); height: min(72svh, 560px); }
  .cai-chat__input { font-size: 16px; }   /* under 16px makes iPhones zoom the page on focus */
}
@media (prefers-reduced-motion: reduce) {
  .cai-chat__bubble, .cai-chat__bubble:hover { transition: none; transform: none; }
  .cai-chat.is-open .cai-chat__panel { animation: none; }
  .cai-chat__typing span { animation: none; opacity: 0.7; }
}
