/* ==========================================================================
   CYBE AI — Neumorphism UI (Brand: #0000ff)
   ========================================================================== */

.cybe-ai-widget {
  --cybe-primary: #0000ff;
  --cybe-primary-glow: rgba(0,0,255,.45);
  --cybe-radius: 18px;

  /* Dark theme tokens */
  --cybe-bg-dark: #1e1e2e;
  --cybe-shadow-dark-1: #14141f;
  --cybe-shadow-dark-2: #28283d;
  --cybe-text-dark: #e7e7f3;
  --cybe-text-dark-dim: #9494ab;

  /* Light theme tokens */
  --cybe-bg-light: #e0e5ec;
  --cybe-shadow-light-1: #b8bec7;
  --cybe-shadow-light-2: #ffffff;
  --cybe-text-light: #2a2a3a;
  --cybe-text-light-dim: #6b6b7d;

  position: fixed;
  z-index: 999999;
  font-family: 'Inter', 'Nunito', -apple-system, sans-serif;
}

.cybe-ai-widget * { box-sizing: border-box; }

.cybe-pos-bottom-right { right: 24px; bottom: 24px; }
.cybe-pos-bottom-left  { left: 24px;  bottom: 24px; }
.cybe-pos-fullscreen   { inset: 0; }

/* Theme resolution */
.cybe-ai-widget[data-theme="dark"]  { --bg: var(--cybe-bg-dark);  --s1: var(--cybe-shadow-dark-1);  --s2: var(--cybe-shadow-dark-2);  --txt: var(--cybe-text-dark);  --txt-dim: var(--cybe-text-dark-dim); }
.cybe-ai-widget[data-theme="light"] { --bg: var(--cybe-bg-light); --s1: var(--cybe-shadow-light-1); --s2: var(--cybe-shadow-light-2); --txt: var(--cybe-text-light); --txt-dim: var(--cybe-text-light-dim); }

/* ── Neumorphic base mixins ───────────────────────────────────────────── */
.cybe-neu-out {
  background: var(--bg);
  box-shadow: 6px 6px 12px var(--s1), -6px -6px 12px var(--s2);
  border: none;
}
.cybe-neu-in {
  background: var(--bg);
  box-shadow: inset 4px 4px 8px var(--s1), inset -4px -4px 8px var(--s2);
  border: none;
}

/* ── Floating Action Button ───────────────────────────────────────────── */
.cybe-fab {
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 6px 6px 14px var(--s1), -6px -6px 14px var(--s2);
  border: none;
  color: var(--cybe-primary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s ease;
}
.cybe-fab:hover { transform: translateY(-3px) scale(1.04); }
.cybe-fab:active {
  transform: scale(.92);
  box-shadow: inset 4px 4px 8px var(--s1), inset -4px -4px 8px var(--s2);
  transition: transform .08s ease;
}
.cybe-fab-icon-close { display: none; }
.cybe-ai-widget.cybe-open .cybe-fab-icon-chat { display: none; }
.cybe-ai-widget.cybe-open .cybe-fab-icon-close { display: block; animation: cybeSpinIn .3s ease; }

.cybe-fab-ring {
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--cybe-primary);
  opacity: 0;
}
.cybe-fab:hover .cybe-fab-ring { animation: cybePulseRing 1.4s ease-out infinite; }

@keyframes cybePulseRing {
  0%   { opacity: .5; transform: scale(1); }
  100% { opacity: 0;  transform: scale(1.35); }
}
@keyframes cybeSpinIn { from { transform: rotate(-90deg); opacity:0; } to { transform: rotate(0); opacity:1; } }

/* Ripple click effect for all icon/tool buttons */
.cybe-icon-btn, .cybe-tool-btn, .cybe-send-btn, .cybe-fab, .cybe-call-end-btn {
  position: relative;
  overflow: hidden;
}
.cybe-click-ripple {
  position: absolute;
  border-radius: 50%;
  background: var(--cybe-primary-glow);
  transform: scale(0);
  animation: cybeRipple .55s ease-out forwards;
  pointer-events: none;
}
@keyframes cybeRipple {
  to { transform: scale(2.6); opacity: 0; }
}

/* ── Chat Panel ───────────────────────────────────────────────────────── */
.cybe-panel {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--bg);
  border-radius: 24px;
  box-shadow: 10px 10px 24px var(--s1), -10px -10px 24px var(--s2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(24px) scale(.96);
  pointer-events: none;
  transition: opacity .3s cubic-bezier(.2,.8,.3,1), transform .35s cubic-bezier(.2,.8,.3,1);
}
.cybe-pos-bottom-left .cybe-panel { right: auto; left: 0; }
.cybe-pos-fullscreen .cybe-panel { position: fixed; inset: 12px; width: auto; height: auto; max-width: none; max-height: none; }

.cybe-ai-widget.cybe-open .cybe-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ───────────────────────────────────────────────────────────── */
.cybe-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  flex-shrink: 0;
}
.cybe-header-left { display: flex; align-items: center; gap: 10px; }
.cybe-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg);
  box-shadow: 4px 4px 8px var(--s1), -4px -4px 8px var(--s2);
  display: flex; align-items: center; justify-content: center;
}
.cybe-avatar-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--cybe-primary);
  box-shadow: 0 0 10px var(--cybe-primary-glow);
  animation: cybeBreathe 2.4s ease-in-out infinite;
}
@keyframes cybeBreathe { 0%,100%{ transform:scale(1); } 50%{ transform:scale(1.25); } }

.cybe-header-text { display: flex; flex-direction: column; line-height: 1.25; }
.cybe-header-text strong { color: var(--txt); font-size: 15px; letter-spacing: .2px; }
.cybe-status { font-size: 11px; color: var(--txt-dim); display: flex; align-items: center; gap: 5px; }
.cybe-status-dot { width: 6px; height: 6px; border-radius: 50%; background: #2ecc71; display: inline-block; }

.cybe-header-actions { display: flex; gap: 8px; }
.cybe-icon-btn {
  width: 34px; height: 34px; border-radius: 12px;
  background: var(--bg);
  box-shadow: 4px 4px 8px var(--s1), -4px -4px 8px var(--s2);
  color: var(--txt-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s ease;
}
.cybe-icon-btn:hover { color: var(--cybe-primary); }
.cybe-icon-btn:active {
  box-shadow: inset 3px 3px 6px var(--s1), inset -3px -3px 6px var(--s2);
  transform: scale(.94);
}

/* ── Messages ─────────────────────────────────────────────────────────── */
.cybe-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
}
.cybe-messages::-webkit-scrollbar { width: 8px; }
.cybe-messages::-webkit-scrollbar-track { background: var(--bg); border-radius: 10px; }
.cybe-messages::-webkit-scrollbar-thumb {
  background: var(--bg);
  box-shadow: inset 2px 2px 4px var(--s1), inset -2px -2px 4px var(--s2);
  border-radius: 10px;
}

.cybe-msg { display: flex; flex-direction: column; max-width: 84%; animation: cybeMsgIn .35s cubic-bezier(.2,.8,.3,1); }
.cybe-msg-user { align-self: flex-end; align-items: flex-end; }
.cybe-msg-ai   { align-self: flex-start; align-items: flex-start; }

@keyframes cybeMsgIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cybe-bubble {
  padding: 11px 15px;
  border-radius: var(--cybe-radius);
  font-size: 14px;
  line-height: 1.5;
  color: var(--txt);
  word-wrap: break-word;
}
.cybe-bubble p { margin: 0 0 6px; }
.cybe-bubble p:last-child { margin-bottom: 0; }

.cybe-bubble-user {
  background: var(--bg);
  box-shadow: 5px 5px 10px var(--s1), -5px -5px 10px var(--s2);
  border-radius: var(--cybe-radius) var(--cybe-radius) 4px var(--cybe-radius);
  color: var(--cybe-primary);
}
.cybe-bubble-ai {
  background: var(--bg);
  box-shadow: inset 3px 3px 6px var(--s1), inset -3px -3px 6px var(--s2);
  border-radius: var(--cybe-radius) var(--cybe-radius) var(--cybe-radius) 4px;
}

.cybe-bubble pre {
  background: rgba(0,0,255,.06);
  border-radius: 10px;
  padding: 10px;
  overflow-x: auto;
  font-size: 12.5px;
}
.cybe-bubble code { font-family: 'Fira Code', monospace; }

.cybe-timestamp { font-size: 10px; color: var(--txt-dim); margin: 4px 6px 0; }

/* Text-reveal animation for AI streamed tokens */
.cybe-token {
  display: inline;
  opacity: 0;
  animation: cybeTokenIn .35s ease forwards;
}
@keyframes cybeTokenIn {
  from { opacity: 0; transform: translateY(3px); filter: blur(2px); }
  to   { opacity: 1; transform: translateY(0);   filter: blur(0); }
}

/* Typing indicator */
.cybe-typing-row { padding: 0 16px 10px; }
.cybe-typing-bubble { display: inline-flex; gap: 5px; padding: 12px 16px; }
.cybe-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--cybe-primary);
  box-shadow: inset 1px 1px 2px rgba(0,0,0,.3);
  animation: cybeBounce 1.2s ease-in-out infinite;
}
.cybe-dot:nth-child(2) { animation-delay: .15s; }
.cybe-dot:nth-child(3) { animation-delay: .3s; }
@keyframes cybeBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Image preview ────────────────────────────────────────────────────── */
.cybe-image-preview {
  margin: 0 16px 10px;
  position: relative;
  width: fit-content;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 4px 4px 10px var(--s1), -4px -4px 10px var(--s2);
  animation: cybeMsgIn .3s ease;
}
.cybe-image-preview img { display: block; max-height: 90px; border-radius: 14px; }
.cybe-image-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff;
  font-size: 14px; line-height: 1;
}

/* ── Input bar ────────────────────────────────────────────────────────── */
.cybe-input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  flex-shrink: 0;
}
.cybe-text-input {
  flex: 1;
  border: none; outline: none;
  background: var(--bg);
  box-shadow: inset 3px 3px 7px var(--s1), inset -3px -3px 7px var(--s2);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 14px;
  color: var(--txt);
  transition: box-shadow .2s ease;
}
.cybe-text-input::placeholder { color: var(--txt-dim); }
.cybe-text-input:focus {
  box-shadow: inset 3px 3px 7px var(--s1), inset -3px -3px 7px var(--s2), 0 0 0 2px var(--cybe-primary-glow);
}

.cybe-tool-btn.active {
  color: #fff;
  background: var(--cybe-primary);
  box-shadow: 0 0 12px var(--cybe-primary-glow);
}

.cybe-send-btn {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--cybe-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 4px 4px 10px var(--cybe-primary-glow);
  cursor: pointer;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease;
}
.cybe-send-btn:hover { transform: translateY(-2px); }
.cybe-send-btn:active { transform: scale(.9); }

/* Mic recording pulse ring */
.cybe-mic-ring {
  position: absolute; inset: -4px;
  border-radius: 12px;
  border: 2px solid var(--cybe-primary);
  opacity: 0;
}
#cybe-mic-btn.recording { color: var(--cybe-primary); }
#cybe-mic-btn.recording .cybe-mic-ring {
  opacity: 1;
  animation: cybeMicPulse 1s ease-out infinite;
}
@keyframes cybeMicPulse {
  0%   { transform: scale(1);   opacity: .7; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ── Live Call Overlay ────────────────────────────────────────────────── */
.cybe-call-overlay {
  position: fixed; inset: 0;
  background: rgba(10,10,18,.85);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000000;
  animation: cybeFadeIn .3s ease;
}
/* Respect the HTML hidden attribute */
.cybe-call-overlay[hidden] { display: none !important; }
@keyframes cybeFadeIn { from { opacity: 0; } to { opacity: 1; } }

.cybe-call-panel {
  background: var(--cybe-bg-dark);
  border-radius: 28px;
  box-shadow: 14px 14px 30px var(--cybe-shadow-dark-1), -14px -14px 30px var(--cybe-shadow-dark-2);
  padding: 40px 36px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  color: var(--cybe-text-dark);
  width: 320px; max-width: 90vw;
  animation: cybeMsgIn .4s cubic-bezier(.2,.8,.3,1);
}

.cybe-call-avatar { position: relative; width: 100px; height: 100px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.cybe-call-avatar-core {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--cybe-bg-dark);
  box-shadow: 6px 6px 14px var(--cybe-shadow-dark-1), -6px -6px 14px var(--cybe-shadow-dark-2), 0 0 20px var(--cybe-primary-glow);
  position: relative; z-index: 2;
}
.cybe-call-wave {
  position: absolute; border-radius: 50%;
  border: 2px solid var(--cybe-primary);
  width: 60px; height: 60px;
  opacity: 0;
  animation: cybeCallWave 2.2s ease-out infinite;
}
.cybe-call-wave-2 { animation-delay: 1.1s; }
@keyframes cybeCallWave {
  0%   { transform: scale(1);   opacity: .55; }
  100% { transform: scale(2.2); opacity: 0; }
}

.cybe-call-timer { font-size: 13px; color: var(--cybe-text-dark-dim); letter-spacing: 1px; }

.cybe-call-visualizer {
  display: flex; align-items: center; gap: 4px; height: 36px;
  background: var(--cybe-bg-dark);
  box-shadow: inset 4px 4px 8px var(--cybe-shadow-dark-1), inset -4px -4px 8px var(--cybe-shadow-dark-2);
  border-radius: 12px; padding: 0 14px; width: 100%; justify-content: center;
}
.cybe-call-visualizer span {
  width: 3px; border-radius: 2px;
  background: var(--cybe-primary);
  height: 6px;
  animation: cybeVizBar 1s ease-in-out infinite;
}
.cybe-call-visualizer span:nth-child(1){animation-delay:0s}
.cybe-call-visualizer span:nth-child(2){animation-delay:.1s}
.cybe-call-visualizer span:nth-child(3){animation-delay:.2s}
.cybe-call-visualizer span:nth-child(4){animation-delay:.3s}
.cybe-call-visualizer span:nth-child(5){animation-delay:.4s}
.cybe-call-visualizer span:nth-child(6){animation-delay:.3s}
.cybe-call-visualizer span:nth-child(7){animation-delay:.2s}
@keyframes cybeVizBar {
  0%, 100% { height: 6px; }
  50% { height: 28px; }
}

.cybe-call-end-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: #ff3b3b;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 4px 4px 12px rgba(255,59,59,.4);
  margin-top: 8px;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1);
}
.cybe-call-end-btn:hover { transform: scale(1.08); }
.cybe-call-end-btn:active { transform: scale(.9); }

/* ── Mobile ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .cybe-panel {
    position: fixed; inset: 0; width: 100%; height: 100%;
    max-width: none; max-height: none; border-radius: 0;
  }
  .cybe-fab { width: 56px; height: 56px; }
}

/* ── Fullscreen embed (homepage) ─────────────────────────────────────── */
.cybe-home-chat,
.cybe-home-chat body {
  margin: 0;
  padding: 0;
}
.cybe-home-chat .cybe-ai-widget {
  position: static !important;
  width: 100% !important;
  height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  z-index: auto !important;
}
.cybe-home-chat #cybe-ai-toggle,
.cybe-home-chat .cybe-fab {
  display: none !important;
}
.cybe-home-chat .cybe-panel {
  position: static !important;
  width: 100% !important;
  height: 100vh !important;
  max-width: 100% !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  opacity: 1 !important;
  transform: none !important;
  pointer-events: all !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}
.cybe-home-chat .cybe-messages {
  flex: 1 1 auto !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
}
