/* The Premium Nexus assistant: WhatsApp launcher + the AI chat assistant (js/concierge.js).
   Concept G "Portoro": a stone sheet with an 18px radius (the one rounded exception, DESIGN.md),
   a gold-tinted hairline, a Gloock title, gold visitor bubbles with black ink, 2px inputs and
   pill suggestions. Below 480px the sheet becomes a full-screen view that respects safe areas.
   Motion is transform and opacity only, and switches off with reduced motion. */
.cg {
  --cg-bg: #0b0a09;
  --cg-surface: #14120f;
  --cg-surface-2: #1d1a15;
  --cg-text: #f2eee6;
  --cg-muted: #aba49a;
  --cg-faint: #8f887e;
  --cg-border: rgb(214 180 106 / .22);
  --cg-line: rgb(242 238 230 / .08);
  --cg-accent: #d6b46a;
  --cg-accent-hi: #e2c47e;
  --cg-accent-ink: #070707;
  --cg-wa: #1f8f55;
  --cg-wa-ink: #ffffff;
  --cg-error: #f3a08f;
  --cg-radius: 18px;
  --cg-font: "Hanken Grotesk", system-ui, sans-serif;
  --cg-font-display: "Gloock", Georgia, serif;
  --cg-shadow: 0 30px 80px rgb(0 0 0 / .62), 0 8px 24px rgb(0 0 0 / .4);
  --cg-ease: cubic-bezier(.16, 1, .3, 1);
  --cg-z: 900;
  font-family: var(--cg-font);
  color: var(--cg-text);
}
.cg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* The hidden attribute must win over the display rules below (a closed panel must not catch clicks or focus). */
.cg [hidden] { display: none !important; }
.cg button:focus-visible, .cg a:focus-visible, .cg-log:focus-visible {
  outline: 2px solid var(--cg-accent); outline-offset: 3px;
}

/* ---------- the dock ---------- */
.cg-dock {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  z-index: var(--cg-z); display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  transition: opacity .45s var(--cg-ease), transform .6s var(--cg-ease), visibility 0s linear 0s;
}
.cg.is-dock-hidden:not(.is-open) .cg-dock { opacity: 0; transform: translateY(18px); visibility: hidden; pointer-events: none; transition: opacity .3s ease, transform .3s ease, visibility 0s linear .3s; }
.cg-fab {
  position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 20px 0 16px;
  border-radius: 999px; border: 1px solid var(--cg-border);
  font: 600 14px/1 var(--cg-font); letter-spacing: .01em; text-decoration: none; cursor: pointer;
  box-shadow: 0 18px 50px rgb(0 0 0 / .55);
  transition: transform .45s var(--cg-ease), background-color .25s ease, color .25s ease, border-color .25s ease;
}
.cg-fab i { font-size: 22px; }
.cg-fab:hover { transform: translateY(-2px); }
.cg-fab:active { transform: translateY(0) scale(.98); }
.cg-fab--wa { background: var(--cg-wa); color: var(--cg-wa-ink); border-color: transparent; }
.cg-fab--chat { background: rgb(18 16 13 / .88); color: #f1dda6; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.cg-fab--chat:hover { border-color: rgb(214 180 106 / .5); }
.cg-fab--chat .cg-ico-close { display: none; }
.cg.is-open .cg-fab--chat .cg-ico-open { display: none; }
.cg.is-open .cg-fab--chat .cg-ico-close { display: inline; }
.cg-badge {
  position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center;
  border-radius: 999px; background: var(--cg-accent); color: var(--cg-accent-ink); box-shadow: 0 0 0 2px var(--cg-bg);
  font: 700 11.5px/1 var(--cg-font); font-variant-numeric: tabular-nums;
}

/* ---------- the sheet ---------- */
.cg-panel {
  position: fixed; z-index: calc(var(--cg-z) + 1);
  right: max(16px, env(safe-area-inset-right)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 136px);
  width: min(408px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 176px));
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 60% at 100% 0%, rgb(214 180 106 / .07), transparent 60%),
    var(--cg-bg);
  color: var(--cg-text);
  border: 1px solid var(--cg-border); border-radius: var(--cg-radius); box-shadow: var(--cg-shadow);
  overflow: hidden;
  opacity: 0; transform: translateY(14px) scale(.985); transform-origin: bottom right;
  transition: opacity .26s ease, transform .45s var(--cg-ease);
}
.cg.is-open .cg-panel { opacity: 1; transform: none; }

.cg-head { display: flex; align-items: center; gap: 12px; padding: 14px 10px 14px 16px; border-bottom: 1px solid var(--cg-line); background: rgb(20 18 15 / .72); }
.cg-head__mark {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #1f1b15, #0b0a09 75%);
  box-shadow: inset 0 0 0 1px rgb(214 180 106 / .45), 0 0 0 4px rgb(214 180 106 / .06);
  color: var(--cg-accent); font: 700 11px/1 var(--cg-font); letter-spacing: .08em;
}
.cg-head__mark img { width: 26px; height: 26px; object-fit: contain; }
.cg-head__text { flex: 1; min-width: 0; }
.cg-title { margin: 0; font: 400 18px/1.2 var(--cg-font-display); letter-spacing: .005em; color: var(--cg-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cg-status { display: flex; align-items: center; gap: 7px; margin: 4px 0 0; font-size: 12.5px; line-height: 1.3; color: var(--cg-muted); }
.cg-status__dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--cg-accent); box-shadow: 0 0 0 3px rgb(214 180 106 / .16); }
.cg-iconbtn {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  border: 0; background: transparent; color: var(--cg-muted); cursor: pointer; font-size: 19px;
  transition: background-color .2s ease, color .2s ease;
}
.cg-iconbtn:hover { background: var(--cg-surface-2); color: var(--cg-text); }

/* ---------- the conversation ---------- */
.cg-log {
  flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px 10px; display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgb(214 180 106 / .25) transparent;
}
.cg-msg { display: flex; max-width: 88%; transition: opacity .32s ease, transform .45s var(--cg-ease); }
.cg-msg.is-new { opacity: 0; transform: translateY(8px); }
.cg-msg--bot { align-self: flex-start; }
.cg-msg--user { align-self: flex-end; }
.cg-msg__body { min-width: 0; padding: 10px 14px; font-size: 14.5px; line-height: 1.55; border-radius: 14px; overflow-wrap: anywhere; }
.cg-msg--bot .cg-msg__body { background: var(--cg-surface-2); border: 1px solid var(--cg-line); border-bottom-left-radius: 4px; color: var(--cg-text); }
.cg-msg--user .cg-msg__body { background: var(--cg-accent); color: var(--cg-accent-ink); border-bottom-right-radius: 4px; box-shadow: inset 0 1px 0 rgb(255 246 222 / .45); }
.cg-msg.is-error .cg-msg__body { background: transparent; border: 1px dashed rgb(243 160 143 / .45); color: var(--cg-text); }
.cg-msg__body p, .cg-msg__body ul, .cg-msg__body ol { margin: 0; }
.cg-msg__body p + p, .cg-msg__body p + ul, .cg-msg__body p + ol, .cg-msg__body ul + p, .cg-msg__body ol + p { margin-top: 8px; }
.cg-msg__body ul, .cg-msg__body ol { padding-left: 1.2em; }
.cg-msg__body li + li { margin-top: 3px; }
.cg-msg__body li::marker { color: var(--cg-accent); }
.cg-msg__body strong { font-weight: 650; color: #fff8ea; }
.cg-msg--bot .cg-msg__body a { color: #f1dda6; text-decoration: underline; text-decoration-color: rgb(214 180 106 / .5); text-underline-offset: .2em; }
.cg-msg--bot .cg-msg__body a:hover { text-decoration-color: currentColor; }
.cg-msg.is-streaming .cg-msg__body > :last-child::after {
  content: ""; display: inline-block; width: 6px; height: 1em; margin-left: 2px; vertical-align: -2px;
  background: var(--cg-accent); opacity: .7; animation: cg-caret 1s steps(2, start) infinite;
}
@keyframes cg-caret { to { opacity: 0; } }
.cg-typing { display: inline-flex; gap: 5px; padding: 14px 15px; background: var(--cg-surface-2); border: 1px solid var(--cg-line); border-radius: 14px; border-bottom-left-radius: 4px; }
.cg-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--cg-accent); opacity: .35; animation: cg-dot 1.1s infinite ease-in-out; }
.cg-typing span:nth-child(2) { animation-delay: .15s; }
.cg-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cg-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- suggestions ---------- */
.cg-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 16px 12px; }
.cg-chip {
  min-height: 40px; padding: 8px 15px; border-radius: 999px; border: 1px solid var(--cg-border);
  background: rgb(214 180 106 / .04); color: var(--cg-text); font: 500 13.5px/1.25 var(--cg-font); text-align: left; cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
.cg-chip:hover { background: rgb(214 180 106 / .1); border-color: rgb(214 180 106 / .55); color: #fff8ea; }

/* ---------- the details card ---------- */
.cg-lead {
  flex: none; margin: 2px 0 4px; padding: 14px 14px 12px; display: grid; gap: 10px;
  border: 1px solid var(--cg-border); border-radius: 12px; background: linear-gradient(180deg, rgb(214 180 106 / .07), rgb(214 180 106 / .02) 60%), var(--cg-surface);
  animation: cg-rise .45s var(--cg-ease);
}
@keyframes cg-rise { from { opacity: 0; transform: translateY(8px); } }
.cg-lead__title { margin: 0; font-size: 14px; line-height: 1.45; color: var(--cg-text); }
.cg-lead__row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cg-field { display: grid; gap: 5px; min-width: 0; }
.cg-field label { font-size: 12.5px; font-weight: 600; color: var(--cg-muted); }
.cg-field__opt { margin-left: 6px; font-weight: 400; color: var(--cg-faint); }
.cg-field input, .cg-input__field {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 2px; border: 1px solid rgb(214 180 106 / .26);
  background: rgb(7 7 7 / .82); color: var(--cg-text); font: 400 15px/1.35 var(--cg-font); caret-color: var(--cg-accent);
  transition: border-color .2s ease;
}
.cg-field input:hover, .cg-input__field:hover { border-color: rgb(214 180 106 / .42); }
.cg-field input:focus, .cg-input__field:focus { border-color: var(--cg-accent); box-shadow: 0 0 0 1px var(--cg-accent); outline: none; }
.cg-field input::placeholder, .cg-input__field::placeholder { color: var(--cg-faint); opacity: 1; }
.cg-lead__hint { margin: -2px 0 0; font-size: 12px; color: var(--cg-faint); }
.cg-lead__err { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--cg-error); }
.cg-lead__err:empty { display: none; }
.cg-lead__actions { display: flex; align-items: center; gap: 6px; }
.cg-lead__send {
  min-height: 44px; padding: 0 20px; border: 0; border-radius: 999px; background: var(--cg-accent); color: var(--cg-accent-ink);
  font: 600 14px/1 var(--cg-font); cursor: pointer; box-shadow: inset 0 1px 0 rgb(255 246 222 / .55);
  transition: background-color .2s ease;
}
.cg-lead__send:hover:not(:disabled) { background: var(--cg-accent-hi); }
.cg-lead__send:disabled { opacity: .6; cursor: default; }
.cg-lead__skip { min-height: 44px; padding: 0 14px; border: 0; background: none; color: var(--cg-muted); font: 500 13.5px/1 var(--cg-font); cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: .25em; }
.cg-lead__skip:hover { color: var(--cg-text); text-decoration-color: currentColor; }
.cg-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- the composer ---------- */
.cg-input { display: flex; align-items: flex-end; gap: 8px; padding: 12px 12px 10px 16px; border-top: 1px solid var(--cg-line); background: rgb(20 18 15 / .72); }
.cg-input__field { flex: 1; resize: none; max-height: 132px; overflow-y: auto; scrollbar-width: thin; }
.cg-input__send {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--cg-accent); color: var(--cg-accent-ink); font-size: 19px; cursor: pointer;
  box-shadow: inset 0 1px 0 rgb(255 246 222 / .55); transition: background-color .2s ease, transform .3s var(--cg-ease);
}
.cg-input__send:hover:not(:disabled) { background: var(--cg-accent-hi); transform: translateY(-1px); }
.cg-input__send:disabled { opacity: .55; cursor: default; }
.cg-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 12px;
  background: rgb(20 18 15 / .72); font-size: 12px; color: var(--cg-faint);
}
.cg-foot a { color: var(--cg-muted); text-underline-offset: .2em; }
.cg-foot a:hover { color: var(--cg-text); }
.cg-foot__wa { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; text-decoration: none; }
.cg-foot__wa i { font-size: 16px; color: #3fbf7f; }

/* ---------- phones: icon-only launchers, the sheet goes full screen ---------- */
@media (max-width: 640px) {
  .cg-fab__label { display: none; }
  .cg-fab { width: 56px; height: 56px; padding: 0; justify-content: center; }
  .cg-panel { right: 8px; left: 8px; width: auto; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 136px); }
}
@media (max-width: 480px) {
  .cg-panel {
    inset: 0; width: 100%; height: 100vh; height: 100dvh; border: 0; border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
    transform: translateY(24px); transform-origin: bottom center;
  }
  .cg-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .cg.is-open .cg-dock { opacity: 0; visibility: hidden; pointer-events: none; }
  .cg-msg { max-width: 92%; }
  .cg-field input, .cg-input__field { font-size: 16px; }   /* 16px stops iOS Safari zooming in on focus */
}
html.cg-lock, html.cg-lock body { overflow: hidden; }

@media (max-width: 359px) { .cg-lead__row { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
  .cg-fab, .cg-panel, .cg-msg, .cg-dock, .cg-input__send { transition: none; }
  .cg-typing span { animation: none; opacity: .6; }
  .cg-lead { animation: none; }
  .cg-msg.is-streaming .cg-msg__body > :last-child::after { animation: none; }
}
