/* iCodeAI chat widget, dark "Glacier" theme (October 2026).
   Same structure, IDs and classes as widget v3; only the look changed.
   Uses its own --fx- tokens so it never overrides the site's tokens. */

:root {
  --fx-void: #04060a;
  --fx-deep: #0a0f16;
  --fx-panel: #0f1620;
  --fx-panel-2: #141d28;
  --fx-line: #1c2632;
  --fx-line-2: #28343f;
  --fx-ice: #e9f3f8;
  --fx-mist: #a3b3bf;
  --fx-dim: #7a8b98;
  --fx-accent: #8fe3ff;
  --fx-accent-ink: #021018;
}

#chat-bubble, #chat-window, #chat-nudge { font-family: 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; box-sizing: border-box; }
#chat-window *, #chat-nudge * { box-sizing: border-box; font-family: inherit; }

#chat-bubble {
  position: fixed; bottom: 20px; right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px)); right: calc(20px + env(safe-area-inset-right, 0px));
  height: 54px; width: auto; padding: 0 20px 0 14px; gap: 9px;
  border-radius: 27px 27px 6px 27px;
  border: 1px solid var(--fx-line-2); background: var(--fx-deep); color: var(--fx-ice);
  cursor: pointer; box-shadow: 0 10px 30px rgba(0,0,0,.5), 0 0 0 1px rgba(143,227,255,.08);
  display: flex; align-items: center; justify-content: center; line-height: 0;
  transition: transform .15s ease, border-color .15s ease;
}
#chat-bubble:hover { transform: translateY(-2px); border-color: var(--fx-accent); }
#chat-bubble.hidden { display: none; }
#chat-bubble svg { display: block; width: 36px; height: 36px; }
#chat-bubble::after { content: "Chat with Felix"; color: var(--fx-ice); font-size: 14.5px; font-weight: 600; line-height: 1; white-space: nowrap; }
@media (max-width: 640px) { #chat-bubble { height: 50px; padding: 0 16px 0 12px; } #chat-bubble::after { content: "Chat"; } }

.felix-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--fx-panel-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 1px solid var(--fx-line-2); }
.felix-avatar svg { width: 21px; height: 21px; }

#chat-nudge {
  position: fixed; bottom: 86px; right: 20px; max-width: 250px;
  background: var(--fx-panel); color: var(--fx-ice); border: 1px solid var(--fx-line-2);
  border-radius: 14px; padding: 12px 30px 12px 14px; box-shadow: 0 14px 34px rgba(0,0,0,.5);
  font-size: 14px; cursor: pointer; animation: nudgeIn .25s ease-out both;
}
#chat-nudge.hidden { display: none; }
#chat-nudge p { margin: 0; line-height: 1.45; }
#chat-nudge::after { content: ""; position: absolute; bottom: -7px; right: 26px; width: 12px; height: 12px; background: var(--fx-panel); border-right: 1px solid var(--fx-line-2); border-bottom: 1px solid var(--fx-line-2); transform: rotate(45deg); }
#nudge-close { position: absolute; top: 6px; right: 8px; background: none; border: none; color: var(--fx-dim); font-size: 16px; line-height: 1; cursor: pointer; padding: 4px; }
@keyframes nudgeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#chat-window {
  position: fixed; bottom: 90px; right: 20px; width: 400px; max-width: 94vw; height: 590px; max-height: 78vh;
  background: var(--fx-deep); color: var(--fx-ice); border: 1px solid var(--fx-line-2); border-radius: 18px;
  box-shadow: 0 30px 70px rgba(0,0,0,.6), 0 0 0 1px rgba(143,227,255,.06);
  display: flex; flex-direction: column; overflow: hidden;
}
#chat-window.hidden { display: none; }
#chat-window.lead-mode { height: 650px; max-height: 86vh; }
#chat-window.expanded { width: min(780px, 94vw); height: 88vh; max-height: 88vh; bottom: 20px; right: max(3vw, 10px); }
#chat-window.expanded.lead-mode #chat-messages { flex: 0 1 180px; }
#chat-window.expanded .msg { max-width: 75%; }
@media (max-width: 640px) {
  #chat-window { width: 94vw; right: 3vw; bottom: 84px; height: 76vh; max-height: 76vh; }
  #chat-window.expanded { top: 0; left: 0; right: 0; bottom: 0; width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh; border-radius: 0; }
}

#chat-header { background: var(--fx-panel); border-bottom: 1px solid var(--fx-line); color: var(--fx-ice); padding: 12px 14px 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
#chat-header-left { display: flex; align-items: center; gap: 10px; }
#chat-header-text { display: flex; flex-direction: column; }
#chat-header-title { font-family: 'Archivo', 'Helvetica Neue', Arial, sans-serif; font-stretch: 112%; font-weight: 700; font-size: 15px; }
#chat-header-subtitle { font-size: 12px; color: var(--fx-mist); margin-top: 2px; }
#chat-header-actions { display: flex; align-items: center; gap: 2px; }
#chat-minimize, #chat-close, #chat-copy, #chat-expand { background: none; border: none; color: var(--fx-mist); font-size: 20px; cursor: pointer; line-height: 1; padding: 4px 6px; border-radius: 8px; }
#chat-minimize:hover, #chat-close:hover, #chat-copy:hover, #chat-expand:hover { color: var(--fx-ice); background: var(--fx-panel-2); }
#chat-minimize { font-size: 18px; }
#chat-copy { font-size: 12.5px; font-weight: 600; padding: 5px 8px; }
#chat-expand { font-size: 17px; }

#chat-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--fx-deep); }
#chat-window.lead-mode #chat-messages { flex: 0 1 40px; }
#chat-window:not(.lead-mode) #chat-messages { min-height: 96px; }

.msg { padding: 10px 14px; border-radius: 16px; max-width: 84%; font-size: 14.5px; line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--fx-accent); color: var(--fx-accent-ink); border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--fx-panel); color: var(--fx-ice); border: 1px solid var(--fx-line-2); border-bottom-left-radius: 5px; }
.msg.system { align-self: center; font-size: 12.5px; color: var(--fx-dim); font-style: italic; text-align: center; }
.msg.typing { align-self: flex-start; background: var(--fx-panel); border: 1px solid var(--fx-line-2); border-bottom-left-radius: 5px; display: flex; align-items: center; gap: 4px; padding: 12px 14px; }
.msg.typing .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fx-accent); animation: typingBounce 1.2s infinite ease-in-out; }
.msg.typing .dot:nth-child(2) { animation-delay: .15s; }
.msg.typing .dot:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

#suggested-prompts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; background: var(--fx-deep); }
#suggested-prompts.hidden { display: none; }
.prompt-chip { background: transparent; border: 1px solid var(--fx-line-2); color: var(--fx-ice); border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.prompt-chip:hover { border-color: var(--fx-accent); background: rgba(143,227,255,.08); }

#specialist-link { display: block; text-align: center; margin: 0 14px 10px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--fx-line-2); color: var(--fx-ice); font-size: 13px; font-weight: 600; text-decoration: none; background: transparent; }
#specialist-link:hover { border-color: var(--fx-accent); }
#specialist-link.hidden { display: none; }

#contact-row { display: flex; gap: 8px; margin: 0 14px 10px; }
#contact-row.hidden { display: none; }
#contact-row a { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; margin: 0; padding: 10px 8px; border-radius: 10px; font-size: 13px; font-weight: 600; text-align: center; text-decoration: none; white-space: nowrap; transition: background .15s ease, border-color .15s ease; }
#contact-row #specialist-link { border: 1px solid var(--fx-line-2); color: var(--fx-ice); background: transparent; }
#contact-row #specialist-link:hover { border-color: var(--fx-accent); }
#contact-row #booking-link { border: 1px solid var(--fx-accent); background: var(--fx-accent); color: var(--fx-accent-ink); }
#contact-row #booking-link:hover { background: var(--fx-ice); border-color: var(--fx-ice); }
#contact-row a:focus-visible { outline: 2px solid var(--fx-accent); outline-offset: 2px; }

#chat-form.hidden { display: none; }
#chat-form { display: flex; border-top: 1px solid var(--fx-line); padding: 10px; gap: 8px; background: var(--fx-panel); }
#chat-input { flex: 1; min-width: 0; border: 1px solid var(--fx-line-2); border-radius: 999px; padding: 10px 14px; font-size: 14.5px; background: var(--fx-deep); color: var(--fx-ice); }
#chat-input::placeholder { color: var(--fx-dim); }
#chat-input:focus { outline: none; border-color: var(--fx-accent); }
#chat-form button, #lead-trigger, #lead-form button[type="submit"] { background: var(--fx-accent); color: var(--fx-accent-ink); border: none; border-radius: 999px; padding: 9px 16px; cursor: pointer; font-size: 14px; font-weight: 600; }
#chat-form button:hover, #lead-form button[type="submit"]:hover { background: var(--fx-ice); }
#lead-trigger { margin: 8px 10px 10px; background: transparent; color: var(--fx-ice); border: 1px solid var(--fx-line-2); }
#lead-trigger:hover { border-color: var(--fx-accent); }
#lead-trigger.hidden { display: none; }

#lead-form { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 14px; border-top: 1px solid var(--fx-line); background: var(--fx-panel); flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#lead-form.hidden { display: none; }
#lead-form input { border: 1px solid var(--fx-line-2); border-radius: 10px; padding: 12px 14px; font-size: 15px; line-height: 1.4; background: var(--fx-deep); color: var(--fx-ice); }
#lead-form input::placeholder { color: var(--fx-dim); }
#lead-form input:focus { outline: none; border-color: var(--fx-accent); }
#lead-consent-label { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; line-height: 1.45; color: var(--fx-mist); margin: 4px 0 2px; }
#lead-consent-label input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; width: 15px; height: 15px; accent-color: var(--fx-accent); padding: 0; }
#lead-consent-label a { color: var(--fx-accent); text-decoration: underline; }

.grecaptcha-badge { visibility: hidden !important; }
.recaptcha-note { font-size: 12px; line-height: 1.5; }
.recaptcha-note a { color: inherit; text-decoration: underline; }
#lead-form .recaptcha-note { margin: 2px 0 0; color: var(--fx-dim); }

.lead-prompt { display: flex; justify-content: flex-start; padding: 0 2px; }
.lead-prompt button { background: var(--fx-accent); color: var(--fx-accent-ink); border: none; border-radius: 999px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.lead-prompt button:hover { background: var(--fx-ice); }

/* Keep the chat usable in short or zoomed-in windows (from v3). */
#chat-header, #suggested-prompts, #contact-row, #chat-form, #lead-trigger { flex-shrink: 0; }
@media (max-height: 760px) {
  #chat-window:not(.expanded) { bottom: 76px; max-height: calc(100vh - 92px); max-height: calc(100dvh - 92px); }
  #suggested-prompts { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
  #suggested-prompts::-webkit-scrollbar { display: none; }
  .prompt-chip { flex: 0 0 auto; white-space: nowrap; }
  #contact-row { margin-bottom: 8px; }
  #lead-trigger { margin: 6px 10px; }
}

/* Always on top of the site's own header (from v3). */
#chat-window { z-index: 2147483000; }
#chat-bubble, #chat-nudge { z-index: 2147482990; }

/* The 3D greeter's speech bubble, matched to the dark theme. */
#felix3d .f3-say { background: var(--fx-panel) !important; color: var(--fx-ice) !important; border-color: var(--fx-line-2) !important; box-shadow: 0 14px 34px rgba(0,0,0,.5) !important; }
#felix3d .f3-say::after { background: var(--fx-panel) !important; border-color: var(--fx-line-2) !important; }
#felix3d .f3-x { color: var(--fx-dim) !important; }

/* Phones: the chat opens full screen, above the keyboard, with 16px text so the page never zooms in. */
@media (max-width: 640px) {
  body #chat-window:not(.chat-x) { top: 0; left: 0; right: 0; bottom: auto; width: 100%; max-width: 100%; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; border: 0; }
  #chat-window input, #chat-window textarea, #chat-window select { font-size: 16px; }
}
html.chat-open-phone, html.chat-open-phone body { overflow: hidden; }
