/* ══════════════════════════════════════════════════
   NEVSKY.DEV — Chatbot Widget
   ══════════════════════════════════════════════════ */

/* ─── Trigger button ─── */
.cb-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 58px;
  height: 58px;
  border-radius: var(--pill);
  cursor: pointer;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(42, 127, 255, 0.35), var(--sh-md);
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease);
  background: var(--grad-mix);
  border: none;
  padding: 3px;
}

.cb-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 32px rgba(42, 127, 255, 0.50), var(--sh-lg);
}

.cb-trigger:active {
  transform: scale(0.95);
}

.cb-trigger .cb-avatar {
  width: 100%;
  height: 100%;
  border-radius: var(--pill);
  object-fit: cover;
  display: block;
}

.cb-trigger .cb-bot-icon {
  width: 60%;
  height: 60%;
  color: #fff;
}

/* Online ping animation */
.cb-ping {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 13px;
  height: 13px;
  border-radius: var(--pill);
  background: var(--green);
  border: 2.5px solid var(--bg);
}

.cb-ping::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: var(--pill);
  background: var(--green);
  opacity: 0.4;
  animation: cb-pulse 2s ease-out infinite;
}

@keyframes cb-pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }

  70% {
    transform: scale(1.8);
    opacity: 0;
  }

  100% {
    transform: scale(0.8);
    opacity: 0;
  }
}

/* ─── Chat window ─── */
.cb-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 360px;
  height: 500px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg), 0 0 48px rgba(42, 127, 255, 0.10);
  z-index: 950;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Hidden state */
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.cb-window.cb-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ─── Header ─── */
.cb-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--grad-mix);
  flex-shrink: 0;
}

.cb-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--pill);
  object-fit: cover;
  border: 2.5px solid rgba(255, 255, 255, 0.30);
  flex-shrink: 0;
}

.cb-bot-icon {
  color: #fff;
  background: rgba(255,255,255,0.12);
  padding: 4px;
  box-sizing: border-box;
}

.cb-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cb-header-info strong {
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
}

.cb-status {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.75rem;
}

.cb-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--pill);
  background: #a8ffcc;
  flex-shrink: 0;
}

.cb-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: var(--pill);
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
  flex-shrink: 0;
}

.cb-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ─── Messages area ─── */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.cb-messages::-webkit-scrollbar {
  width: 4px;
}

.cb-messages::-webkit-scrollbar-track {
  background: transparent;
}

.cb-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

/* Message row */
.cb-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.cb-msg--user {
  flex-direction: row-reverse;
}

.cb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--pill);
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
}

.cb-msg-avatar.cb-bot-icon {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 3px;
}

/* Bubble */
.cb-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.cb-msg--bot .cb-bubble {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.cb-msg--user .cb-bubble {
  background: var(--grad-blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.cb-typing .cb-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}

.cb-typing .cb-bubble span {
  width: 7px;
  height: 7px;
  border-radius: var(--pill);
  background: var(--text-3);
  animation: cb-bounce 1.2s infinite ease-in-out;
}

.cb-typing .cb-bubble span:nth-child(2) {
  animation-delay: 0.18s;
}

.cb-typing .cb-bubble span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes cb-bounce {

  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  40% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ─── Input row ─── */
.cb-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1.5px solid var(--border);
  flex-shrink: 0;
  background: var(--card);
}

.cb-input-row input {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--pill);
  padding: 9px 14px;
  font-size: 0.875rem;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.18s;
}

.cb-input-row input:focus {
  border-color: var(--blue);
}

.cb-input-row input::placeholder {
  color: var(--text-3);
}

.cb-input-row input:disabled {
  opacity: 0.5;
}

#cbSend {
  width: 38px;
  height: 38px;
  border-radius: var(--pill);
  background: var(--grad-blue);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.18s, transform 0.18s;
  box-shadow: var(--sh-blue);
}

#cbSend:hover {
  opacity: 0.88;
  transform: scale(1.06);
}

#cbSend:active {
  transform: scale(0.94);
}

#cbSend:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ─── Mobile ─── */
@media (max-width: 480px) {
  .cb-window {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 85svh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }

  .cb-trigger {
    bottom: 20px;
    right: 20px;
  }
}