/* ==========================================================================
   Navi — AI assistant widget. Themed with the site's --c2g-* design tokens.
   Futuristic glass panel, orange energy, fully responsive, fullscreen-capable.
   ========================================================================== */

#navi {
  --navi-z: 2147483000;
  --navi-w: 400px;
  --navi-h: min(680px, calc(100vh - 132px));
  --navi-radius: 20px;
  --navi-orange: var(--c2g-orange, #ff5a00);
  --navi-orange-bright: var(--c2g-orange-bright, #ff6b00);
  --navi-glass: rgba(16, 23, 34, 0.72);
  --navi-surface: var(--c2g-surface, #101722);
  --navi-surface-2: var(--c2g-surface-2, #161f2b);
  --navi-border: rgba(255, 255, 255, 0.12);
  --navi-text: var(--c2g-text, #f3f6fa);
  --navi-muted: var(--c2g-muted, #a8b1bf);
  --navi-ease: var(--ease, cubic-bezier(0.22, 1, 0.36, 1));
  --navi-user: linear-gradient(135deg, #ff6b00, #ff8a3d);

  position: fixed;
  inset: auto 0 0 auto;
  z-index: var(--navi-z);
  font-family: var(--font-body, "Inter", system-ui, sans-serif);
  color: var(--navi-text);
}

#navi *,
#navi *::before,
#navi *::after { box-sizing: border-box; }

/* ---------------------------------------------------------------- launcher */

.navi-fab {
  position: fixed;
  right: clamp(16px, 4vw, 28px);
  bottom: clamp(16px, 4vw, 28px);
  z-index: var(--navi-z);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 0 16px;
  height: 58px;
  border: 0;
  border-radius: var(--radius-pill, 999px);
  background: linear-gradient(135deg, var(--navi-orange), var(--navi-orange-bright));
  color: #1c0900;
  font-family: var(--font-head, "Space Grotesk", sans-serif);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(255, 90, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.35s var(--navi-ease), box-shadow 0.35s var(--navi-ease), opacity 0.25s ease;
}
.navi-fab:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 16px 40px rgba(255, 90, 0, 0.5); }
.navi-fab:active { transform: translateY(-1px) scale(0.99); }
.navi-fab:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.navi-fab-orb {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
}
.navi-fab-orb svg { width: 20px; height: 20px; }
.navi-fab-orb::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  animation: navi-ping 2.6s var(--navi-ease) infinite;
}
@keyframes navi-ping {
  0% { transform: scale(0.7); opacity: 0.8; }
  70%, 100% { transform: scale(1.5); opacity: 0; }
}
/* Attention dot */
.navi-fab-badge {
  position: absolute;
  top: -4px; right: -2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--c2g-green, #47d99c);
  border: 2px solid #1c0900;
}

#navi.is-open .navi-fab { transform: scale(0.4); opacity: 0; pointer-events: none; }

/* ------------------------------------------------------------------- panel */

.navi-panel {
  position: fixed;
  right: clamp(16px, 4vw, 28px);
  bottom: clamp(16px, 4vw, 28px);
  z-index: var(--navi-z);
  width: var(--navi-w);
  height: var(--navi-h);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--navi-radius);
  border: 1px solid var(--navi-border);
  background: var(--navi-glass);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04),
              0 0 60px rgba(255, 90, 0, 0.12);
  transform: translateY(24px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transform-origin: bottom right;
  transition: transform 0.42s var(--navi-ease), opacity 0.3s ease;
}
#navi.is-open .navi-panel { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }

/* Ambient orange aura behind the glass */
.navi-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(255, 90, 0, 0.18), transparent 60%),
    radial-gradient(90% 50% at 0% 100%, rgba(66, 184, 255, 0.10), transparent 55%),
    var(--navi-surface);
}

/* Fullscreen mode */
#navi.is-full .navi-panel {
  right: 0; bottom: 0; top: 0; left: 0;
  width: 100vw; height: 100vh; max-height: 100vh;
  border-radius: 0;
  transform-origin: center;
}
#navi.is-full .navi-inner { max-width: 900px; margin: 0 auto; width: 100%; }

/* --------------------------------------------------------------- header */

.navi-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--navi-border);
  background: linear-gradient(180deg, rgba(7, 9, 13, 0.55), rgba(7, 9, 13, 0.15));
}
.navi-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--navi-orange), var(--navi-orange-bright));
  color: #1c0900;
  box-shadow: 0 6px 18px rgba(255, 90, 0, 0.4);
}
.navi-avatar svg { width: 24px; height: 24px; }
.navi-head-meta { flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.navi-title {
  font-family: var(--font-head, "Space Grotesk", sans-serif);
  font-weight: 700; font-size: 17px; margin: 0;
  display: flex; align-items: center; gap: 8px;
}
.navi-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--navi-muted);
}
.navi-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c2g-green, #47d99c);
  box-shadow: 0 0 0 0 rgba(71, 217, 156, 0.6);
  animation: navi-live 2.4s ease-out infinite;
}
@keyframes navi-live {
  0% { box-shadow: 0 0 0 0 rgba(71, 217, 156, 0.55); }
  70%,100% { box-shadow: 0 0 0 7px rgba(71, 217, 156, 0); }
}
.navi-head-actions { display: flex; gap: 4px; }
.navi-iconbtn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--navi-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.navi-iconbtn:hover { background: rgba(255, 255, 255, 0.08); color: var(--navi-text); }
.navi-iconbtn:focus-visible { outline: 2px solid var(--navi-orange); outline-offset: 2px; }
.navi-iconbtn svg { width: 19px; height: 19px; }

/* --------------------------------------------------------------- messages */

.navi-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.navi-scroll::-webkit-scrollbar { width: 8px; }
.navi-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 8px; }
.navi-inner { display: flex; flex-direction: column; gap: 14px; }

.navi-msg { display: flex; gap: 10px; align-items: flex-end; animation: navi-rise 0.35s var(--navi-ease) both; }
@keyframes navi-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.navi-msg.is-user { flex-direction: row-reverse; }
.navi-ava-sm {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center; font-size: 13px;
  background: linear-gradient(135deg, var(--navi-orange), var(--navi-orange-bright));
  color: #1c0900;
}
.navi-ava-sm svg { width: 16px; height: 16px; }
.navi-msg.is-user .navi-ava-sm { background: rgba(255,255,255,0.10); color: var(--navi-text); }

.navi-bubble {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  background: var(--navi-surface-2);
  border: 1px solid var(--navi-border);
  border-bottom-left-radius: 5px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.navi-msg.is-user .navi-bubble {
  background: var(--navi-user);
  color: #1c0900;
  border: 0;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 5px;
  font-weight: 500;
}
/* Dark, high-contrast text on the orange outgoing bubble (override global p/li). */
.navi-msg.is-user .navi-bubble,
.navi-msg.is-user .navi-bubble p,
.navi-msg.is-user .navi-bubble li,
.navi-msg.is-user .navi-bubble strong { color: #1c0900; }
/* Explicit text colors: beat the site-wide `p { color: --c2g-muted }` rule,
   which otherwise overrides the bubble color via direct element targeting. */
.navi-bubble, .navi-bubble p, .navi-bubble li { color: var(--navi-text); }
.navi-bubble p { margin: 0 0 8px; }
.navi-bubble p:last-child { margin-bottom: 0; }
.navi-bubble ul, .navi-bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.navi-bubble li { margin: 2px 0; }
.navi-bubble a { color: var(--navi-orange); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.navi-msg.is-user .navi-bubble a { color: #3a1500; }
.navi-bubble code {
  font-family: var(--font-mono, monospace);
  font-size: 0.88em; padding: 1px 5px; border-radius: 5px;
  background: rgba(255,255,255,0.10);
}
.navi-bubble strong { font-weight: 700; }
.navi-msg-img {
  display: block; max-width: 200px; max-height: 200px;
  border-radius: 12px; margin-bottom: 8px; border: 1px solid var(--navi-border);
}

/* thinking + tool status */
.navi-thinking { display: inline-flex; align-items: center; gap: 9px; color: var(--navi-muted); font-size: 13.5px; }
.navi-dots { display: inline-flex; gap: 4px; }
.navi-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--navi-orange); animation: navi-bounce 1.3s var(--navi-ease) infinite; }
.navi-dots i:nth-child(2) { animation-delay: 0.16s; }
.navi-dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes navi-bounce { 0%,60%,100% { transform: translateY(0); opacity: 0.55; } 30% { transform: translateY(-5px); opacity: 1; } }
.navi-tool {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--navi-muted);
  padding: 5px 0;
}
.navi-tool .spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.2); border-top-color: var(--navi-orange); animation: navi-spin 0.8s linear infinite; }
@keyframes navi-spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- action cards */

.navi-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.navi-card {
  border: 1px solid var(--navi-border);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  padding: 12px 14px;
}
.navi-card-title { font-weight: 700; font-size: 13.5px; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.navi-card-title svg { width: 16px; height: 16px; color: var(--navi-orange); }
.navi-card-row { font-size: 13px; color: var(--navi-muted); margin: 2px 0; }
.navi-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.navi-cta {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 1px solid var(--navi-border); background: rgba(255,255,255,0.06); color: var(--navi-text);
  transition: background 0.2s, transform 0.2s, border-color 0.2s;
}
.navi-cta:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.navi-cta.is-primary { background: linear-gradient(135deg, var(--navi-orange), var(--navi-orange-bright)); color: #1c0900; border: 0; }
.navi-cta svg { width: 16px; height: 16px; }
.navi-ok { display: inline-flex; align-items: center; gap: 7px; color: var(--c2g-green, #47d99c); font-size: 13px; font-weight: 600; }
.navi-ok svg { width: 16px; height: 16px; }

/* -------------------------------------------------------------- lead form */

.navi-leadform { display: flex; flex-direction: column; gap: 11px; margin-top: 12px; }
.navi-field { display: flex; flex-direction: column; gap: 5px; }
.navi-field-row { display: flex; gap: 10px; }
.navi-field-row .navi-field { flex: 1 1 0; min-width: 0; }
.navi-field label { font-size: 12px; font-weight: 600; color: var(--navi-muted); }
.navi-field label span { color: var(--navi-orange); }
.navi-field input,
.navi-field textarea,
.navi-field select {
  width: 100%;
  font-family: inherit; font-size: 14px; color: var(--navi-text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--navi-border);
  border-radius: 10px;
  padding: 9px 11px;
  outline: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.navi-field textarea { resize: vertical; min-height: 62px; line-height: 1.5; }
.navi-field input::placeholder,
.navi-field textarea::placeholder { color: var(--c2g-subtle, #788494); }
.navi-field input:focus,
.navi-field textarea:focus,
.navi-field select:focus {
  border-color: rgba(255, 90, 0, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 90, 0, 0.12);
}
.navi-field select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23a8b1bf' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.navi-field select option { color: #101722; }
.navi-form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 2px; }
.navi-form-actions .navi-cta { border-radius: 12px; padding: 9px 16px; }
.navi-form-error { color: var(--c2g-danger, #ff5f6d); font-size: 12.5px; }
.navi-form-error:empty { display: none; }

@media (max-width: 430px) {
  .navi-field-row { flex-direction: column; gap: 11px; }
}

/* --------------------------------------------------------------- quick chips */

.navi-quick {
  flex: 0 0 auto;
  display: flex; gap: 8px; flex-wrap: nowrap;
  padding: 4px 14px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.navi-quick::-webkit-scrollbar { display: none; }
.navi-chip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 999px;
  border: 1px solid var(--navi-border); background: rgba(255,255,255,0.05);
  color: var(--navi-text); font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.navi-chip:hover { background: rgba(255,90,0,0.14); border-color: rgba(255,90,0,0.5); transform: translateY(-1px); }
.navi-chip:focus-visible { outline: 2px solid var(--navi-orange); outline-offset: 2px; }
.navi-chip svg { width: 15px; height: 15px; color: var(--navi-orange); }

/* --------------------------------------------------------------- composer */

.navi-compose {
  flex: 0 0 auto;
  border-top: 1px solid var(--navi-border);
  padding: 10px 12px 12px;
  background: rgba(7, 9, 13, 0.35);
}
.navi-preview { display: none; align-items: center; gap: 10px; padding: 6px 6px 10px; }
.navi-preview.is-on { display: flex; }
.navi-preview img { width: 46px; height: 46px; object-fit: cover; border-radius: 10px; border: 1px solid var(--navi-border); }
.navi-preview .navi-preview-x { margin-left: auto; }
.navi-preview span { font-size: 12.5px; color: var(--navi-muted); }
.navi-inputrow {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--navi-surface-2);
  border: 1px solid var(--navi-border);
  border-radius: 16px;
  padding: 6px 6px 6px 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.navi-inputrow:focus-within { border-color: rgba(255,90,0,0.6); box-shadow: 0 0 0 3px rgba(255,90,0,0.12); }
.navi-textarea {
  flex: 1 1 auto;
  resize: none;
  max-height: 128px;
  min-height: 24px;
  border: 0; outline: 0; background: transparent;
  color: var(--navi-text);
  font-family: inherit; font-size: 14.5px; line-height: 1.45;
  padding: 8px 2px;
}
.navi-textarea::placeholder { color: var(--navi-muted); }
.navi-round {
  flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; border: 0; cursor: pointer;
  transition: transform 0.2s, background 0.2s, opacity 0.2s;
}
.navi-attach { background: rgba(255,255,255,0.07); color: var(--navi-muted); }
.navi-attach:hover { background: rgba(255,255,255,0.14); color: var(--navi-text); }
.navi-send { background: linear-gradient(135deg, var(--navi-orange), var(--navi-orange-bright)); color: #1c0900; }
.navi-send:hover { transform: translateY(-1px) scale(1.04); }
.navi-send:disabled { opacity: 0.45; cursor: default; transform: none; }
.navi-round svg { width: 19px; height: 19px; }
.navi-round:focus-visible { outline: 2px solid var(--navi-orange); outline-offset: 2px; }
.navi-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.navi-turnstile:empty { display: none; }
.navi-turnstile { display: flex; justify-content: center; margin: 8px 0 0; }

.navi-foot { text-align: center; font-size: 10.5px; color: var(--navi-muted); padding: 8px 4px 2px; }
.navi-foot a { color: var(--navi-muted); text-decoration: underline; }

/* --------------------------------------------------------------- responsive */

@media (max-width: 560px) {
  #navi .navi-panel {
    right: 0; bottom: 0; top: 0; left: 0;
    width: 100vw; height: 100dvh; max-height: 100dvh;
    border-radius: 0;
  }
  .navi-fab { right: 16px; bottom: 16px; height: 54px; }
  #navi .navi-expand { display: none; } /* fullscreen is default on mobile */
}

/* --------------------------------------------------------------- a11y / motion */

@media (prefers-reduced-motion: reduce) {
  #navi *, #navi *::before, #navi *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.1ms !important;
  }
}

#navi[hidden] { display: none; }
