/* ================================================================
   TECHAVENTURE CHATBOT WIDGET
   ================================================================ */

:root {
  --cb-primary: #1857ff;
  --cb-primary-dk: #0d3fcf;
  --cb-bg: #060a14;
  --cb-bg2: #0d1527;
  --cb-border: rgba(255, 255, 255, 0.08);
  --cb-text: #e2e8f0;
  --cb-muted: rgba(226, 232, 240, 0.55);
  --cb-radius: 16px;
  --cb-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(24, 87, 255, 0.12);
  --cb-w: 380px;
  --cb-h: 580px;
}

/* ── FAB BUTTON ─────────────────────────────────────────────────── */
#cb-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 8px 28px rgba(24, 87, 255, 0.45);
  z-index: 9990;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease;
  outline: none;
}

#cb-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 36px rgba(24, 87, 255, 0.6);
}

#cb-fab:active {
  transform: scale(0.96);
}

#cb-fab .cb-fab-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity .25s, transform .25s;
}

#cb-fab .cb-fab-icon-open,
#cb-fab .cb-fab-icon-close {
  transition: opacity .25s, transform .25s;
}

#cb-fab .cb-fab-icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

#cb-fab.open .cb-fab-img {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

#cb-fab.open .cb-fab-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

#cb-fab.open .cb-fab-online {
  opacity: 0;
  transform: scale(0);
}

/* Live Status Indicator */
.cb-fab-online {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  background: #22c55e;
  border: 3px solid #fff;
  border-radius: 50%;
  z-index: 2;
  transition: opacity 0.3s, transform 0.3s;
}

.cb-fab-online::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  width: 18px;
  height: 18px;
  border: 3px solid #22c55e;
  border-radius: 50%;
  animation: cb-live-pulse 2s infinite;
}

@keyframes cb-live-pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* Unread badge */
#cb-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: cb-pulse 2s infinite;
}

#cb-badge.show {
  display: flex;
}

@keyframes cb-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, .5);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
}

/* ── CHAT WINDOW ─────────────────────────────────────────────────── */
#cb-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: var(--cb-w);
  max-width: calc(100vw - 32px);
  height: var(--cb-h);
  max-height: calc(100vh - 120px);
  background: var(--cb-bg);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  border: 1px solid var(--cb-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9989;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.3s ease;
}

#cb-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── HEADER ──────────────────────────────────────────────────────── */
.cb-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #0d1a3e, #121e48);
  border-bottom: 1px solid var(--cb-border);
  flex-shrink: 0;
}

.cb-header-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary), #5b8dff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.cb-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cb-header-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #121e48;
}

.cb-header-info {
  flex: 1;
  min-width: 0;
}

.cb-header-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.3;
}

.cb-header-status {
  font-size: 0.75rem;
  color: #22c55e;
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cb-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  animation: cb-blink 2s infinite;
  flex-shrink: 0;
}

@keyframes cb-blink {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .35
  }
}

.cb-header-actions {
  display: flex;
  gap: 4px;
}

.cb-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: background .2s, color .2s;
}

.cb-header-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* Language selector */
.cb-lang-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--cb-border);
  border-radius: 6px;
  color: var(--cb-text);
  font-size: 0.75rem;
  padding: 4px 6px;
  cursor: pointer;
  outline: none;
}

.cb-lang-select option {
  background: #0d1527;
}

/* ── MESSAGES AREA ───────────────────────────────────────────────── */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.cb-messages::-webkit-scrollbar {
  width: 4px;
}

.cb-messages::-webkit-scrollbar-track {
  background: transparent;
}

.cb-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* Message bubbles */
.cb-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: cb-msg-in .35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cb-msg-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cb-msg.bot {
  align-self: flex-start;
}

.cb-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.cb-msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary), #5b8dff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.cb-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cb-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.cb-msg.bot .cb-bubble {
  background: var(--cb-bg2);
  color: var(--cb-text);
  border: 1px solid var(--cb-border);
  border-bottom-left-radius: 4px;
}

.cb-msg.user .cb-bubble {
  background: var(--cb-bg2);
  color: var(--cb-text);
  border: 1px solid var(--cb-border);
  border-radius: 18px 18px 18px 4;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
}

/* Bold within messages */
.cb-bubble strong {
  font-weight: 700;
  color: #93c5fd;
}

.cb-msg.user .cb-bubble strong {
  color: #fff;
  font-weight: 700;
}

/* Timestamp */
.cb-ts {
  font-size: 0.68rem;
  color: var(--cb-muted);
  margin-top: 3px;
  display: block;
  text-align: right;
}

.cb-msg.bot .cb-ts {
  text-align: left;
}

.cb-msg.user .cb-ts {
  color: rgba(255, 255, 255, 0.75);
}

/* ── QUICK REPLIES ───────────────────────────────────────────────── */
.cb-qr-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
  animation: cb-msg-in .35s .1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.cb-qr-btn {
  padding: 7px 12px;
  border-radius: 20px;
  background: rgba(24, 87, 255, 0.1);
  border: 1px solid rgba(24, 87, 255, 0.3);
  color: #93c5fd;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
  white-space: nowrap;
}

.cb-qr-btn:hover {
  background: rgba(24, 87, 255, 0.25);
  border-color: rgba(24, 87, 255, 0.6);
  transform: translateY(-1px);
}

/* ── TYPING INDICATOR ───────────────────────────────────────────── */
.cb-typing {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-start;
}

.cb-typing-dots {
  background: var(--cb-bg2);
  border: 1px solid var(--cb-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.cb-typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--cb-muted);
  border-radius: 50%;
  animation: cb-dot 1.2s infinite ease-in-out;
}

.cb-typing-dots span:nth-child(2) {
  animation-delay: .2s;
}

.cb-typing-dots span:nth-child(3) {
  animation-delay: .4s;
}

@keyframes cb-dot {

  0%,
  80%,
  100% {
    transform: scale(0.7);
    opacity: .5;
  }

  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

/* ── WELCOME BANNER (first open) ────────────────────────────────── */
.cb-welcome {
  text-align: center;
  padding: 20px 16px 8px;
  flex-shrink: 0;
}

.cb-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary), #5b8dff);
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 8px 24px rgba(24, 87, 255, .4);
}

.cb-welcome h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 4px;
}

.cb-welcome p {
  font-size: 0.8rem;
  color: var(--cb-muted);
  margin: 0;
}

/* ── INPUT AREA ─────────────────────────────────────────────────── */
.cb-input-wrap {
  padding: 12px 14px;
  border-top: 1px solid var(--cb-border);
  background: var(--cb-bg2);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

#cb-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--cb-border);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--cb-text);
  font-size: 0.875rem;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 96px;
  line-height: 1.5;
  font-family: inherit;
  transition: border-color .2s;
  overflow-y: auto;
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE/Edge */
}

#cb-input::-webkit-scrollbar {
  display: none;
}

/* Chrome/Safari */
#cb-input::placeholder {
  color: var(--cb-muted);
}

#cb-input:focus {
  border-color: rgba(24, 87, 255, 0.45);
}

#cb-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--cb-primary);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}

#cb-send:hover {
  background: var(--cb-primary-dk);
}

#cb-send:active {
  transform: scale(0.93);
}

#cb-send:disabled {
  opacity: .45;
  cursor: default;
}

/* ── FOOTER ─────────────────────────────────────────────────────── */
.cb-footer {
  text-align: center;
  padding: 6px 12px 10px;
  font-size: 0.68rem;
  color: var(--cb-muted);
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
}

.cb-footer a {
  color: #93c5fd;
  text-decoration: none;
}

.cb-footer a:hover {
  text-decoration: underline;
}

/* ── MOBILE ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --cb-w: 100vw;
  }

  #cb-window {
    bottom: 0;
    right: 0;
    border-radius: var(--cb-radius) var(--cb-radius) 0 0;
    max-height: 90vh;
    height: 90vh;
  }

  #cb-fab {
    bottom: 18px;
    right: 18px;
  }
}