/* ══════════════════════════════════════════════════════════════
   Codrenix Chatbot v4.0 — Redesigned
   Brand: Dark Navy + Electric Blue + Cyan Neon
   Font: Space Grotesk / JetBrains Mono — scoped to widget
══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── CSS Variables ── */
#codrenix-chatbot-root {
  --cx-bg:        #050d1a;
  --cx-bg2:       #071428;
  --cx-bg3:       #0a1e3a;
  --cx-surface:   #0d2240;
  --cx-border:    rgba(0,180,255,0.15);
  --cx-border-h:  rgba(0,220,255,0.4);
  --cx-blue:      #00b4ff;
  --cx-cyan:      #00e5ff;
  --cx-glow:      rgba(0,180,255,0.25);
  --cx-glow-h:    rgba(0,220,255,0.45);
  --cx-text:      #c8dff5;
  --cx-text-dim:  rgba(160,210,255,0.55);
  --cx-white:     #e8f4ff;
  --cx-green:     #00ff99;
  --cx-red:       #ff4466;
  --cx-radius:    20px;
  --cx-radius-sm: 12px;
  --cx-font:      'Space Grotesk', system-ui, sans-serif;
  --cx-mono:      'JetBrains Mono', monospace;
}

#codrenix-chatbot-root * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--cx-font);
}

/* Fix: button reset kills padding — restore it for buttons specifically */
#codrenix-chatbot-root button {
  padding: revert;
}

/* ══ FLOATING LAUNCHER BUTTON ══ */
#cx-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  z-index: 999998;
  background: transparent;
  padding: 0;
}

#cx-launcher-inner {
  width: 100%;
  height: 100%;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--cx-bg2), var(--cx-bg));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow:
    0 0 0 1.5px var(--cx-border),
    0 8px 28px rgba(0,0,0,0.7),
    0 0 32px var(--cx-glow),
    inset 0 1px 0 rgba(255,255,255,0.07);
  animation: cx-float 3.5s ease-in-out infinite, cx-pulse 2.8s ease-in-out infinite;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.22s ease;
}

#cx-launcher:hover #cx-launcher-inner {
  transform: scale(1.1) rotateY(-10deg) rotateX(5deg);
  box-shadow:
    0 0 0 1.5px var(--cx-border-h),
    0 14px 40px rgba(0,0,0,0.75),
    0 0 55px var(--cx-glow-h),
    inset 0 1px 0 rgba(255,255,255,0.12);
}

#cx-launcher-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 8px;
  filter: drop-shadow(0 0 6px rgba(0,200,255,0.55)) drop-shadow(0 0 14px rgba(0,160,255,0.3));
  transition: filter 0.22s ease;
}
#cx-launcher:hover #cx-launcher-logo {
  filter: drop-shadow(0 0 10px rgba(0,230,255,0.85)) drop-shadow(0 0 22px rgba(0,180,255,0.5));
}

@keyframes cx-float {
  0%, 100% { transform: translateY(0px); }
  40%       { transform: translateY(-6px); }
  70%       { transform: translateY(-3px); }
}
@keyframes cx-pulse {
  0%, 100% { box-shadow: 0 0 0 1.5px var(--cx-border), 0 8px 28px rgba(0,0,0,0.7), 0 0 32px var(--cx-glow), inset 0 1px 0 rgba(255,255,255,0.07); }
  50%       { box-shadow: 0 0 0 1.5px rgba(0,220,255,0.4), 0 8px 28px rgba(0,0,0,0.7), 0 0 55px rgba(0,210,255,0.4), inset 0 1px 0 rgba(255,255,255,0.1); }
}

/* Notification badge */
.cx-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  background: radial-gradient(circle, #ff6680, #ff1144);
  border-radius: 50%;
  border: 2.5px solid var(--cx-bg);
  box-shadow: 0 0 10px rgba(255,30,70,0.7);
  animation: cx-badge-pulse 2.2s ease-in-out infinite;
}
@keyframes cx-badge-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.3); box-shadow: 0 0 18px rgba(255,30,70,0.85); }
}

/* ══ CHAT WINDOW ══ */
#cx-window {
  position: fixed;
  bottom: 106px;
  right: 28px;
  width: 390px;
  height: 610px;
  border-radius: var(--cx-radius);
  background: var(--cx-bg);
  border: 1px solid var(--cx-border);
  box-shadow:
    0 40px 110px rgba(0,0,0,0.9),
    0 0 0 1px rgba(0,180,255,0.06),
    inset 0 0 80px rgba(0,80,180,0.04);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.86) translateY(30px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
  transform-origin: bottom right;
}
#cx-window.cx-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Scanline overlay */
#cx-window::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 4px,
    rgba(0,180,255,0.009) 4px, rgba(0,180,255,0.009) 5px
  );
  pointer-events: none;
  z-index: 0;
  border-radius: var(--cx-radius);
}

/* ── HEADER ── */
#cx-header {
  position: relative;
  z-index: 1;
  background: linear-gradient(135deg, rgba(7,20,42,0.98) 0%, rgba(10,26,52,0.98) 100%);
  border-bottom: 1px solid var(--cx-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#cx-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 16px; right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cx-cyan), transparent);
  opacity: 0.35;
}

#cx-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--cx-bg3), var(--cx-bg));
  border: 1.5px solid var(--cx-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 18px var(--cx-glow), inset 0 1px 0 rgba(255,255,255,0.06);
  overflow: hidden;
}
#cx-avatar img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 8px;
  filter: drop-shadow(0 0 5px rgba(0,200,255,0.5));
}

#cx-header-info { flex: 1; }
#cx-header-name {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--cx-white);
  letter-spacing: 0.3px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cx-brand-tag {
  font-family: var(--cx-mono);
  font-size: 8.5px;
  color: var(--cx-cyan);
  font-weight: 600;
  letter-spacing: 2px;
  background: rgba(0,229,255,0.08);
  border: 1px solid rgba(0,229,255,0.22);
  border-radius: 5px;
  padding: 2px 6px;
  vertical-align: middle;
}
#cx-header-status {
  font-size: 11px;
  color: var(--cx-text-dim);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  font-weight: 400;
}
.cx-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cx-green);
  box-shadow: 0 0 8px var(--cx-green);
  animation: cx-status-glow 2.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes cx-status-glow {
  0%, 100% { opacity: 1; box-shadow: 0 0 7px var(--cx-green); }
  50%       { opacity: 0.5; box-shadow: 0 0 16px var(--cx-green); }
}

#cx-close {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  color: rgba(255,255,255,0.45);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
  flex-shrink: 0;
}
#cx-close:hover {
  background: rgba(255,50,80,0.12);
  border-color: rgba(255,50,80,0.32);
  color: var(--cx-red);
  transform: rotate(90deg);
}

/* ── Hint bar ── */
#cx-hint {
  position: relative;
  z-index: 1;
  background: rgba(0,180,255,0.04);
  border-bottom: 1px solid rgba(0,180,255,0.07);
  padding: 7px 16px;
  font-size: 10.5px;
  color: var(--cx-text-dim);
  font-family: var(--cx-mono);
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

/* ══ MESSAGES ══ */
#cx-messages {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,180,255,0.2) transparent;
}
#cx-messages::-webkit-scrollbar { width: 4px; }
#cx-messages::-webkit-scrollbar-thumb {
  background: rgba(0,180,255,0.25);
  border-radius: 4px;
}

.cx-row { display: flex; align-items: flex-start; gap: 10px; }
.cx-row.cx-user { flex-direction: row-reverse; }

.cx-bot-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--cx-bg3), var(--cx-bg));
  border: 1px solid var(--cx-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  box-shadow: 0 0 12px var(--cx-glow);
  overflow: hidden;
}
.cx-bot-icon img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 6px;
  filter: drop-shadow(0 0 4px rgba(0,200,255,0.5));
}

.cx-bubble-wrap { max-width: 82%; }

.cx-bubble {
  padding: 11px 14px;
  font-size: 13px;
  line-height: 1.72;
  color: var(--cx-text);
  font-weight: 400;
}
.cx-bubble.cx-bot {
  padding: 20px !important;
  margin-bottom: 10px !important;
  background: linear-gradient(145deg, rgba(10,22,44,0.98), rgba(12,26,50,0.98));
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 5px 16px 16px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04);
}
.cx-bubble.cx-user {
  padding: 3px 15px !important;
  background: linear-gradient(135deg, rgba(0,140,255,0.12), rgba(0,100,220,0.08));
  border: 1px solid rgba(0,180,255,0.24);
  border-radius: 9px 0px 8px 9px;
  color: #d4eeff;
  box-shadow: 0 4px 18px rgba(0,100,255,0.12);
}
.cx-bubble b { color: var(--cx-white); font-weight: 700; }
.cx-bubble .cx-h2 {
  display: block;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--cx-cyan);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0,229,255,0.14);
  letter-spacing: 0.2px;
}

.cx-time {
  font-size: 9.5px;
  color: rgba(255,255,255,0.2);
  margin-top: 5px;
  padding-left: 2px;
  font-family: var(--cx-mono);
  letter-spacing: 0.4px;
}
.cx-row.cx-user .cx-time { text-align: right; padding-left: 0; padding-right: 2px; }

/* ── OPTION BUTTONS ── */
.cx-options {
  margin-top: 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cx-opt {
  background: rgba(0,140,255,0.05);
  border: 1px solid var(--cx-border);
  border-radius: var(--cx-radius-sm);
  padding: 10px 14px !important;
  color: rgba(160,210,255,0.9);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34,1.4,0.64,1);
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--cx-font);
  letter-spacing: 0.15px;
  position: relative;
  overflow: hidden;
}
.cx-opt::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--cx-border);
  border-radius: 3px 0 0 3px;
  transition: background 0.2s;
}
.cx-opt::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0,180,255,0.06), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.cx-opt:hover:not(:disabled) {
  background: rgba(0,180,255,0.11);
  border-color: var(--cx-border-h);
  color: var(--cx-white);
  transform: translateX(3px) scale(1.01);
  box-shadow: 0 2px 16px rgba(0,180,255,0.12), inset 0 0 0 1px rgba(0,220,255,0.08);
}
.cx-opt:hover:not(:disabled)::before { background: var(--cx-cyan); }
.cx-opt:hover:not(:disabled)::after  { opacity: 1; }
.cx-opt:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.cx-opt-arrow {
  opacity: 0.35;
  font-size: 14px;
  transition: opacity 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.cx-opt:hover:not(:disabled) .cx-opt-arrow {
  opacity: 0.85;
  transform: translateX(3px);
}

/* ── Pricing cards in options ── */
.cx-price-tag {
  margin-left: auto;
  font-family: var(--cx-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--cx-cyan);
  background: rgba(0,229,255,0.09);
  border: 1px solid rgba(0,229,255,0.2);
  border-radius: 6px;
  padding: 2px 7px;
  flex-shrink: 0;
}

/* ── Typing indicator ── */
.cx-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 15px;
  background: linear-gradient(145deg, rgba(10,22,44,0.98), rgba(12,26,50,0.98));
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 5px 16px 16px 16px;
  width: fit-content;
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
}
.cx-dot-anim {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cx-blue), var(--cx-cyan));
}
.cx-dot-anim:nth-child(1) { animation: cx-bounce 1.2s 0s infinite; }
.cx-dot-anim:nth-child(2) { animation: cx-bounce 1.2s 0.2s infinite; }
.cx-dot-anim:nth-child(3) { animation: cx-bounce 1.2s 0.4s infinite; }
@keyframes cx-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-8px); opacity: 1; }
}

/* ══ FOOTER ══ */
#cx-footer {
  position: relative;
  z-index: 1;
  padding: 10px 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: rgba(3,8,18,0.97);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#cx-footer::before {
  content: '';
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,180,255,0.2), transparent);
}
#cx-footer-brand {
  font-size: 10.5px;
  color: rgba(255,255,255,0.2);
  font-family: var(--cx-mono);
  letter-spacing: 0.4px;
}
#cx-footer-brand span { color: rgba(0,200,255,0.5); font-weight: 600; }
#cx-restart {
  background: rgba(0,180,255,0.07);
  border: 1px solid rgba(0,180,255,0.18);
  border-radius: 9px;
  padding: 5px 13px;
  color: rgba(0,210,255,0.7);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: var(--cx-font);
  font-weight: 600;
  letter-spacing: 0.3px;
}
#cx-restart:hover {
  background: rgba(0,180,255,0.14);
  border-color: rgba(0,220,255,0.35);
  color: rgba(0,230,255,0.95);
}

/* ── Animations ── */
@keyframes cx-fadeup {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cx-fadein { animation: cx-fadeup 0.3s ease; }

/* ── Mobile ── */
@media (max-width: 480px) {
  #cx-window {
    width: calc(100vw - 18px);
    right: 9px;
    bottom: 100px;
    height: 74vh;
    max-height: 590px;
    border-radius: 18px;
  }
  #cx-launcher { bottom: 18px; right: 16px; width: 58px; height: 58px; }
}
