/* =========================================================
   AIBOS chat widget styles
   Colours match the site and the AIBOS logo: near-black + gold.
   Change the variables below to re-theme the widget.
   ========================================================= */
.aibos-chat {
  --aibos-chat-dark: #0e0e0e;      /* header, launcher, inputs */
  --aibos-chat-panel: #1a1a1a;     /* panel, input bar, form */
  --aibos-chat-accent: #c9a227;    /* logo gold */
  --aibos-chat-accent-light: #ddb947;
  --aibos-chat-accent-ink: #0e0e0e;/* text on gold */
  --aibos-chat-bg: #121212;        /* message area */
  --aibos-chat-bubble: #262626;    /* bot bubbles */
  --aibos-chat-line: #383838;
  --aibos-chat-text: #f2f0ea;
  --aibos-chat-muted: #bdbab2;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--aibos-chat-text);
}
.aibos-chat *, .aibos-chat *::before, .aibos-chat *::after { box-sizing: border-box; }

/* Launcher button */
.aibos-chat-launcher {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 9998;
  display: inline-flex; align-items: center; gap: 0.55rem;
  background: var(--aibos-chat-dark); color: #fff; border: 2px solid var(--aibos-chat-accent);
  border-radius: 999px; padding: 0.7rem 1.15rem 0.7rem 0.85rem; font: inherit; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); transition: transform 0.15s, box-shadow 0.15s;
}
.aibos-chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6); border-color: var(--aibos-chat-accent-light); }
.aibos-chat-launcher:focus-visible, .aibos-chat button:focus-visible, .aibos-chat input:focus-visible, .aibos-chat textarea:focus-visible {
  outline: 3px solid var(--aibos-chat-accent); outline-offset: 2px;
}
.aibos-chat-launcher svg { flex: none; color: var(--aibos-chat-accent); }
.aibos-chat-launcher[aria-expanded="true"] { display: none; }

/* Panel */
.aibos-chat-panel {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 9999;
  width: min(390px, calc(100vw - 36px)); height: min(620px, calc(100vh - 36px));
  display: flex; flex-direction: column; background: var(--aibos-chat-panel); border-radius: 18px; overflow: hidden;
  border: 1px solid var(--aibos-chat-line); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
.aibos-chat-panel[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .aibos-chat-panel { animation: aibos-chat-in 0.2s ease-out both; }
  .aibos-chat-msg { animation: aibos-chat-in 0.25s ease-out both; }
}
@keyframes aibos-chat-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.aibos-chat-header {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.8rem 0.9rem;
  background: var(--aibos-chat-dark); border-bottom: 1px solid rgba(201, 162, 39, 0.45); color: #fff; flex: none;
}
.aibos-chat-header p { margin: 0; }
.aibos-chat-title { font-weight: 800; letter-spacing: 0.02em; }
.aibos-chat-sub { font-size: 0.8rem; color: var(--aibos-chat-muted); display: flex; align-items: center; gap: 0.35rem; }
.aibos-chat-dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.25); }
.aibos-chat-close {
  margin-left: auto; background: transparent; border: 0; color: #fff; cursor: pointer; width: 38px; height: 38px;
  border-radius: 10px; display: grid; place-items: center;
}
.aibos-chat-close:hover { background: rgba(255, 255, 255, 0.12); }

.aibos-chat-log {
  flex: 1; overflow-y: auto; padding: 1rem 0.85rem 0.5rem; background: var(--aibos-chat-bg);
  display: flex; flex-direction: column; gap: 0.55rem; overscroll-behavior: contain;
}
.aibos-chat-msg { max-width: 88%; padding: 0.6rem 0.85rem; border-radius: 14px; word-wrap: break-word; }
.aibos-chat-msg p { margin: 0; }
.aibos-chat-msg p + p, .aibos-chat-msg ul + p, .aibos-chat-msg p + ul { margin-top: 0.4rem; }
.aibos-chat-msg ul { margin: 0.3rem 0 0; padding-left: 1.15rem; }
.aibos-chat-msg a { color: var(--aibos-chat-accent); font-weight: 700; }
.aibos-chat-user a { color: inherit; }
.aibos-chat-bot { background: var(--aibos-chat-bubble); color: var(--aibos-chat-text); border: 1px solid var(--aibos-chat-line); border-bottom-left-radius: 4px; align-self: flex-start; }
.aibos-chat-user { background: var(--aibos-chat-accent); color: var(--aibos-chat-accent-ink); border-bottom-right-radius: 4px; align-self: flex-end; }
.aibos-chat-typing { display: inline-flex; gap: 4px; padding: 0.75rem 0.9rem; }
.aibos-chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: #a8a59d; animation: aibos-chat-blink 1.2s infinite ease-in-out; }
.aibos-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.aibos-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aibos-chat-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* Quick replies */
.aibos-chat-quick { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.15rem 0 0.35rem; }
.aibos-chat-chip {
  font: inherit; font-size: 0.88rem; font-weight: 700; cursor: pointer; border-radius: 999px; padding: 0.4rem 0.85rem;
  background: transparent; color: var(--aibos-chat-accent); border: 2px solid var(--aibos-chat-accent);
}
.aibos-chat-chip:hover { background: var(--aibos-chat-accent); color: var(--aibos-chat-accent-ink); }

/* Lead form */
.aibos-chat-form {
  align-self: stretch; background: var(--aibos-chat-panel); border: 2px solid var(--aibos-chat-accent); border-radius: 14px; padding: 0.85rem;
  display: grid; gap: 0.5rem;
}
.aibos-chat-form h3 { margin: 0; font-size: 1rem; color: #fff; }
.aibos-chat-form label { display: grid; gap: 0.15rem; font-size: 0.82rem; font-weight: 600; color: var(--aibos-chat-muted); }
.aibos-chat-form input[type="text"], .aibos-chat-form input[type="email"], .aibos-chat-form input[type="tel"], .aibos-chat-form textarea {
  font: inherit; font-size: 16px; /* 16px stops iPhones zooming in */ width: 100%; padding: 0.45rem 0.6rem;
  border: 1px solid #4a4a4a; border-radius: 8px; color: var(--aibos-chat-text); background: var(--aibos-chat-dark);
}
.aibos-chat-form input:focus, .aibos-chat-form textarea:focus, .aibos-chat-inputbar textarea:focus { border-color: var(--aibos-chat-accent); }
.aibos-chat-form textarea { min-height: 3.6em; resize: vertical; }
.aibos-chat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.aibos-chat-consent { display: flex !important; grid-template-columns: none; align-items: flex-start; gap: 0.45rem !important; font-weight: 500 !important; line-height: 1.35; }
.aibos-chat-consent input { margin-top: 0.15rem; width: 18px; height: 18px; flex: none; accent-color: var(--aibos-chat-accent); }
.aibos-chat-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.aibos-chat-error { color: #ff8a80; font-size: 0.85rem; margin: 0; }
.aibos-chat-btn {
  font: inherit; font-weight: 800; cursor: pointer; border: 0; border-radius: 999px; padding: 0.6rem 1rem;
  background: var(--aibos-chat-accent); color: var(--aibos-chat-accent-ink);
}
.aibos-chat-btn:hover { background: var(--aibos-chat-accent-light); }
.aibos-chat-btn[disabled] { opacity: 0.6; cursor: progress; }

/* Input bar */
.aibos-chat-inputbar { display: flex; gap: 0.45rem; padding: 0.6rem 0.7rem; border-top: 1px solid var(--aibos-chat-line); background: var(--aibos-chat-panel); flex: none; }
.aibos-chat-inputbar textarea {
  flex: 1; font: inherit; font-size: 16px; resize: none; height: 44px; max-height: 110px; padding: 0.55rem 0.75rem;
  border: 1px solid #4a4a4a; border-radius: 12px; color: var(--aibos-chat-text); background: var(--aibos-chat-dark);
}
.aibos-chat-inputbar textarea::placeholder, .aibos-chat-form textarea::placeholder { color: #9a978f; }
.aibos-chat-send {
  flex: none; width: 44px; height: 44px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--aibos-chat-accent); color: var(--aibos-chat-accent-ink); display: grid; place-items: center;
}
.aibos-chat-send[disabled] { opacity: 0.5; cursor: progress; }
.aibos-chat-foot { margin: 0; padding: 0.35rem 0.8rem 0.55rem; font-size: 0.72rem; color: var(--aibos-chat-muted); background: var(--aibos-chat-panel); text-align: center; flex: none; }
.aibos-chat-foot a { color: var(--aibos-chat-accent); font-weight: 700; }
.aibos-chat-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Phones: full-screen panel, compact launcher */
@media (max-width: 520px) {
  .aibos-chat-panel { right: 0; bottom: 0; width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; border: 0; }
  .aibos-chat-launcher { padding: 0.75rem; }
  .aibos-chat-launcher-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .aibos-chat-row { grid-template-columns: 1fr; }
}
@media print { .aibos-chat { display: none; } }
