/* ==========================================================================
   MIGOMBANI — CONCIERGE
   --------------------------------------------------------------------------
   The chat panel and its launcher. Sits above the existing .fab-stack rather
   than inside it, so the WhatsApp and back-to-top buttons keep their place.
   ========================================================================== */

#cgRoot {
  position: fixed;
  right: var(--gutter, 1.25rem);
  bottom: calc(var(--gutter, 1.25rem) + 7.5rem);   /* clear of the FAB stack */
  z-index: var(--z-modal, 900);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .75rem;
  pointer-events: none;
}
#cgRoot > * { pointer-events: auto; }

/* ── Launcher ─────────────────────────────────────────────────────── */

.cg-fab {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .7rem 1.1rem .7rem .85rem;
  border: 0; border-radius: 999px;
  background: var(--forest-700); color: #fff;
  font: inherit; font-size: var(--fs-2xs); font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: var(--sh-lg);
  transition: transform var(--t-fast) var(--e-out), background var(--t-fast) var(--e-out);
}
.cg-fab:hover { background: var(--forest-600); transform: translateY(-2px); }
.cg-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cg-fab-icon { display: grid; place-items: center; }
.cg-fab-icon svg { width: 1.15rem; height: 1.15rem; }
#cgRoot.is-open .cg-fab { display: none; }

@media (max-width: 30rem) {
  .cg-fab-label { display: none; }
  .cg-fab { padding: .8rem; }
}

/* ── Panel ────────────────────────────────────────────────────────── */

/* `hidden` MUST win.
   The browser's own `[hidden] { display: none }` and a class selector have
   equal specificity, and author styles beat the user-agent sheet — so the
   `display: flex` below silently defeated the hidden attribute and left this
   panel open on every page, over the content, permanently. */
.cg-panel[hidden] { display: none !important; }

.cg-panel {
  width: min(23rem, calc(100vw - 2 * var(--gutter, 1.25rem)));
  max-height: min(38rem, calc(100vh - 9rem));
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--sh-xl);
  overflow: hidden;
  animation: cgIn var(--t-base) var(--e-out);
}
@keyframes cgIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cg-panel { animation: none; }
}

.cg-head {
  display: flex; align-items: flex-start; gap: 1rem;
  padding: 1rem 1.1rem;
  background: var(--forest-700); color: #fff;
}
.cg-head h2 { margin: 0; font-size: var(--fs-md); font-family: var(--font-sans); font-weight: 600; }
.cg-sub { margin: .2rem 0 0; font-size: var(--fs-3xs); opacity: .72; line-height: 1.4; }
.cg-close {
  margin-left: auto; flex: none;
  background: rgb(255 255 255 / .14); color: #fff;
  border: 0; border-radius: 999px;
  padding: .3rem .7rem; font: inherit; font-size: var(--fs-3xs);
  cursor: pointer;
}
.cg-close:hover { background: rgb(255 255 255 / .24); }

/* ── Messages ─────────────────────────────────────────────────────── */

.cg-log {
  flex: 1 1 auto; overflow-y: auto;
  /* Without this the message scrolled under the header looks clipped rather
     than scrolled. */
  mask-image: linear-gradient(to bottom, transparent 0, #000 14px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px);
  padding: 1rem; display: flex; flex-direction: column; gap: .7rem;
  scrollbar-width: thin;
}
.cg-msg { max-width: 88%; }
.cg-msg p { margin: 0; font-size: var(--fs-sm); line-height: 1.55; }

.cg-bot {
  align-self: flex-start;
  background: var(--surface-2);
  border-radius: 14px 14px 14px 4px;
  padding: .7rem .9rem;
}
.cg-you {
  align-self: flex-end;
  background: var(--forest-700); color: #fff;
  border-radius: 14px 14px 4px 14px;
  padding: .7rem .9rem;
}

/* "Thinking" — three dots, replaced by the answer. */
.cg-dots { display: flex; gap: 4px; }
.cg-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-3);
  animation: cgDot 1.2s var(--e-inout) infinite;
}
.cg-dots i:nth-child(2) { animation-delay: .15s; }
.cg-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes cgDot { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .cg-dots i { animation: none; opacity: .6; } }

/* ── In-message actions ───────────────────────────────────────────── */

.cg-act {
  display: inline-block; margin-top: .6rem;
  padding: .4rem .85rem;
  background: var(--accent); color: var(--on-accent);
  border: 0; border-radius: 999px;
  font: inherit; font-size: var(--fs-3xs); font-weight: 700;
  text-decoration: none; cursor: pointer;
}
.cg-act:hover { filter: brightness(.95); }

.cg-rooms { display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem; }
.cg-room {
  display: block; padding: .6rem .75rem;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 11px; text-decoration: none; color: inherit;
}
.cg-room:hover { border-color: var(--accent); }
.cg-room b { display: block; font-size: var(--fs-sm); }
.cg-room span { font-size: var(--fs-3xs); color: var(--ink-3); }

/* ── "I don't know" → hand it to the family ───────────────────────── */

.cg-ask-family { margin-top: .7rem; }
.cg-ask-family p { font-size: var(--fs-3xs); color: var(--ink-3); margin-bottom: .45rem; }
.cg-email { display: flex; gap: .35rem; }
.cg-email input {
  flex: 1 1 auto; min-width: 0;
  font: inherit; font-size: var(--fs-2xs);
  padding: .45rem .6rem;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); color: var(--ink);
}
.cg-email button {
  flex: none; font: inherit; font-size: var(--fs-3xs); font-weight: 700;
  padding: .45rem .7rem; border: 0; border-radius: 9px;
  background: var(--forest-700); color: #fff; cursor: pointer;
}
.cg-email button:disabled { opacity: .5; cursor: progress; }

/* ── Suggestion chips ─────────────────────────────────────────────── */

.cg-chips {
  display: flex; flex-wrap: wrap; gap: .35rem;
  padding: 0 1rem .6rem;
}
.cg-chips:empty { display: none; }
.cg-chips button {
  font: inherit; font-size: var(--fs-3xs);
  padding: .35rem .7rem;
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line-strong); border-radius: 999px;
  cursor: pointer;
}
.cg-chips button:hover { border-color: var(--brand); color: var(--brand); }

/* ── Composer ─────────────────────────────────────────────────────── */

.cg-form {
  display: flex; gap: .4rem;
  padding: .75rem 1rem 1rem;
  border-top: 1px solid var(--line);
}
.cg-form input {
  flex: 1 1 auto; min-width: 0;
  font: inherit; font-size: var(--fs-sm);
  padding: .6rem .8rem;
  border: 1px solid var(--line-strong); border-radius: 11px;
  background: var(--surface); color: var(--ink);
}
.cg-form input:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.cg-form button {
  flex: none; font: inherit; font-size: var(--fs-2xs); font-weight: 700;
  padding: .6rem 1rem; border: 0; border-radius: 11px;
  background: var(--accent); color: var(--on-accent); cursor: pointer;
}

/* On a phone the panel takes the lower half of the screen rather than
   floating in a corner it would overflow. */
@media (max-width: 30rem) {
  #cgRoot { left: var(--gutter, 1rem); bottom: calc(var(--gutter, 1rem) + 7.5rem); }
  .cg-panel { width: 100%; max-height: 70vh; }
}

/* The site prints as a brochure; a chat widget has no place on paper. */
@media print { #cgRoot { display: none; } }
