/* Hockey Australia Assistant — chat widget.
   Teal/Automatorr theme. Fills its container so it embeds cleanly in an iframe:
     <iframe src="https://host/?embed=1" style="width:400px;height:600px;border:0"> */

:root {
  --teal: #007c82;
  --teal-dark: #006065;
  --teal-700: #00545a;
  --teal-tint: #e6f1f1;
  --bg: #eef3f3;
  --panel: #ffffff;
  --text: #16201e;
  --text-soft: #5e6f6a;
  --border: #e3e8e7;
  --user-grad-a: #008a90;
  --user-grad-b: #006e74;
  --shadow-sm: 0 1px 2px rgba(16, 32, 30, 0.06);
  --shadow-md: 0 4px 14px rgba(16, 32, 30, 0.10);
  --font: Verdana, Geneva, Tahoma, "Segoe UI", system-ui, sans-serif;
  --col: 760px;            /* max conversation column width (standalone) */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: var(--bg);
}

/* ── Header ──────────────────────────────────────────────────────────── */
.chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-700) 100%);
  color: #fff;
  flex: 0 0 auto;
  box-shadow: var(--shadow-md);
  z-index: 2;
}
.chat__brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.chat__avatar {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: #fff;                 /* white badge so the teal icon shows */
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.chat__avatar img { width: 26px; height: 26px; object-fit: contain; display: block; }
.chat__titles { min-width: 0; }
.chat__title {
  margin: 0; font-size: 14.5px; font-weight: 700; letter-spacing: 0.1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat__subtitle {
  margin: 2px 0 0; font-size: 11px; opacity: 0.9;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat__online {
  width: 7px; height: 7px; border-radius: 50%;
  background: #46e6a0; box-shadow: 0 0 0 2px rgba(70,230,160,0.3);
  flex: 0 0 auto;
}
.chat__new {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,0.14);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.30);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.chat__new:hover { background: rgba(255,255,255,0.26); }
.chat__new:active { transform: scale(0.97); }

/* ── Messages ────────────────────────────────────────────────────────── */
.chat__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;        /* center the conversation column on wide screens */
  animation: rise 0.22s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg--user { flex-direction: row-reverse; }

.msg__avatar {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2px;
}
.msg__avatar img { width: 19px; height: 19px; object-fit: contain; display: block; }

.msg__col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  max-width: 80%;
}
.msg__bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  box-shadow: var(--shadow-sm);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.msg--bot .msg__bubble { max-width: 100%; }  /* width capped by .msg__col */

/* Choice buttons rendered from a [[OPTIONS: ...]] marker */
.msg__options { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  background: #fff;
  border: 1.5px solid var(--teal);
  color: var(--teal-dark);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 12.5px; font-weight: 700; font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.opt:hover { background: var(--teal); color: #fff; }
.opt:active { transform: scale(0.96); }
.msg--user .msg__bubble {
  background: linear-gradient(135deg, var(--user-grad-a), var(--user-grad-b));
  color: #fff;
  border-bottom-right-radius: 5px;
}
.msg--bot .msg__bubble {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}

/* Markdown inside bot bubbles */
.msg__bubble p { margin: 0 0 8px; }
.msg__bubble p:last-child { margin-bottom: 0; }
.msg__bubble strong { font-weight: 700; }
.msg__bubble em { font-style: italic; }
.msg__bubble ul, .msg__bubble ol { margin: 6px 0 8px; padding-left: 20px; }
.msg__bubble li { margin: 3px 0; }
.msg__bubble li::marker { color: var(--teal); }
.msg__bubble h2, .msg__bubble h3, .msg__bubble h4 {
  margin: 8px 0 5px; line-height: 1.3; font-weight: 700;
}
.msg__bubble h2 { font-size: 15px; }
.msg__bubble h3 { font-size: 14px; }
.msg__bubble h4 { font-size: 13.5px; }
.msg__bubble blockquote {
  margin: 6px 0; padding: 6px 12px;
  border-left: 3px solid var(--teal);
  background: var(--teal-tint);
  border-radius: 4px;
  color: #2a3b38; font-style: italic;
}
.msg__bubble code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.88em;
  background: rgba(0,124,130,0.10);
  padding: 1px 5px; border-radius: 4px;
}
.msg__bubble a { color: var(--teal); text-decoration: underline; font-weight: 600; }
.msg--user .msg__bubble a { color: #fff; }

/* Typing indicator (inline bot bubble) */
.msg--typing .msg__bubble {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--text-soft); font-size: 12.5px;
}
.dots { display: inline-flex; gap: 4px; }
.dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--teal);
  display: inline-block;
  animation: blink 1.3s infinite ease-in-out both;
}
.dots i:nth-child(2) { animation-delay: 0.18s; }
.dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink {
  0%, 75%, 100% { opacity: 0.25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-3px); }
}

/* ── Welcome / empty state ───────────────────────────────────────────── */
.welcome {
  margin: auto;
  max-width: 440px;
  text-align: center;
  padding: 24px 16px;
  animation: rise 0.3s ease both;
}
.welcome__avatar {
  width: 64px; height: 64px; margin: 0 auto 14px;
  display: grid; place-items: center;
  background: #fff; border: 1px solid var(--border);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.welcome__avatar img { width: 42px; height: 42px; object-fit: contain; display: block; }
.welcome__title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.welcome__text { font-size: 13px; color: var(--text-soft); line-height: 1.55; margin-bottom: 18px; }
.welcome__chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--teal-dark);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12.5px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.chip:hover { background: var(--teal-tint); border-color: var(--teal); }
.chip:active { transform: scale(0.97); }

/* ── Composer ────────────────────────────────────────────────────────── */
.chat__composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}
.chat__input {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  max-height: 120px;
  outline: none;
  background: #f6f9f9;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.chat__input:focus {
  border-color: var(--teal);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0,124,130,0.12);
}
.chat__send {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border: none; border-radius: 50%;
  background: var(--teal);
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}
.chat__send:hover { background: var(--teal-dark); }
.chat__send:active { transform: scale(0.94); }
.chat__send:disabled { opacity: 0.45; cursor: default; }

/* ── Footer ──────────────────────────────────────────────────────────── */
.chat__footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: #6b7775;
  padding: 7px;
  border-top: 1px solid var(--border);
  background: #f8fafa;
  flex: 0 0 auto;
}
.chat__footer a { display: inline-flex; align-items: center; line-height: 0; }
.chat__footer img {
  height: 14px; width: auto; display: block;
  opacity: 0.9; transition: opacity 0.15s ease;
}
.chat__footer a:hover img { opacity: 1; }

/* Embed mode (?embed=1): host wrapper provides its own chrome */
body.embed .chat__header,
body.embed .chat__footer { display: none; }

/* Scrollbar */
.chat__messages::-webkit-scrollbar { width: 8px; }
.chat__messages::-webkit-scrollbar-thumb { background: #c8d2d1; border-radius: 4px; }
.chat__messages::-webkit-scrollbar-thumb:hover { background: #b3bfbd; }
