/* ══════════════════════════════════════════════════════════
   CHATBOT TYPING EFFECTS & WHATSAPP STYLES
   ══════════════════════════════════════════════════════════ */

:root {
  --wa-bg-bot: #f0f0f0;
  --wa-bg-user: #dcf8c6;
  --wa-accent: #25d366;
  --wa-text-dark: #111111;
  --wa-text-muted: #999999;
  --wa-bubble-radius: 18px;
  --wa-animation-speed: 200ms;
    --wa-header: #075E54;
    --wa-accent-dark: #128C7E;
    --wa-danger: #FF4C4C;
}

/* ── Panel Navigation ── */
#chatbot-window {
    overflow: hidden; /* Prevent panels from showing outside overflow */
}

.cb-panels-container {
    display: flex;
    width: 200%;
    height: 100%;
    transition: transform 0.3s ease-in-out;
}

.cb-panel {
    width: 50%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#chatbot-window.show-list .cb-panels-container {
    transform: translateX(0);
}

#chatbot-window.show-chat .cb-panels-container {
    transform: translateX(-50%);
}

/* ── Header Improvements ── */
#chatbot-header {
    background: var(--wa-header) !important;
    height: 64px;
    padding: 0 12px;
}

.cb-header-side {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cb-header-action {
    background: none;
    border: none;
    color: white;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.2s, opacity 0.15s;
}

.cb-header-action:hover {
    background: rgba(255, 255, 255, 0.1);
}

.cb-back-btn {
    padding: 8px 10px;
    border-radius: 4px;
}

.cb-back-label {
    display: none;
    font-size: 14px;
    font-weight: 500;
}

@media (min-width: 480px) {
    .cb-back-label { display: block; }
}

.cb-clear-btn:hover svg {
    color: var(--wa-danger);
    stroke: var(--wa-danger);
}

/* CSS Tooltip for Clear Button */
.cb-clear-btn::after {
    content: "Clear conversation";
    position: absolute;
    top: 50px;
    right: 0;
    background: #444;
    color: white;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
}

.cb-clear-btn:hover::after {
    opacity: 1;
}

/* ── WhatsApp Style Confirmation Prompt ── */
.cb-confirm-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.cb-confirm-card {
    background: white;
    width: 280px;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    text-align: center;
}

.cb-confirm-text {
    font-size: 16px;
    font-weight: 600;
    color: #111;
    margin-bottom: 24px;
}

.cb-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.cb-confirm-btn {
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}

.cb-confirm-btn:active { transform: scale(0.95); }

.cb-btn-cancel {
    background: white;
    border: 1.5px solid #ccc;
    color: #555;
}

.cb-btn-clear {
    background: var(--wa-danger);
    color: white;
    border: none;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Send Button Dynamic ── */
#chatbot-send {
    width: 52px !important;
    height: 52px !important;
    background: var(--wa-accent) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25) !important;
    border-radius: 50% !important;
    padding: 0;
    overflow: hidden;
    position: relative;
    transition: transform 0.1s !important;
}

#chatbot-send:active {
    transform: scale(0.92) !important;
}

.cb-send-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: scale 0.15s ease, opacity 0.15s ease;
}

.cb-send-icon.hidden {
    scale: 0.8;
    opacity: 0;
    pointer-events: none;
}

/* ── List Panel Rows ── */
.cb-list-header {
    background: var(--wa-header);
    color: white;
    padding: 18px 24px;
    font-size: 18px;
    font-weight: 600;
}

.cb-contact-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.cb-contact-row:hover {
    background: #f5f5f5;
}

.cb-contact-avatar {
    width: 48px;
    height: 48px;
    background: #ccc;
    border-radius: 50%;
    flex-shrink: 0;
}

.cb-contact-info {
    flex: 1;
    min-width: 0;
}

.cb-contact-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.cb-contact-name {
    font-weight: 600;
    font-size: 15px;
    color: #111;
}

.cb-contact-time {
    font-size: 11px;
    color: var(--wa-text-muted);
}

.cb-contact-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cb-contact-preview {
    font-size: 13px;
    color: var(--wa-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 12px;
}

.cb-unread-badge {
    background: var(--wa-accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* ── Container Overrides / Extensions ── */
#chatbot-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  scroll-behavior: smooth;
  background: #e5ddd5 !important; /* WhatsApp background color */
}

/* ── Bubble Base ── */
.cb-bubble {
  position: relative;
  max-width: 85%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  opacity: 0;
  transform: translateY(10px);
  animation: bubbleFadeIn var(--wa-animation-speed) ease-out forwards;
}

@keyframes bubbleFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Bot Bubble ── */
.cb-bubble-bot {
  align-self: flex-start;
  background: var(--wa-bg-bot);
  color: var(--wa-text-dark);
  border-radius: 0 var(--wa-bubble-radius) var(--wa-bubble-radius)
    var(--wa-bubble-radius);
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

/* ── User Bubble ── */
.cb-bubble-user {
  align-self: flex-end;
  background: var(--wa-bg-user);
  color: var(--wa-text-dark);
  border-radius: var(--wa-bubble-radius) 0 var(--wa-bubble-radius)
    var(--wa-bubble-radius);
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

/* ── Meta Info (Timestamp + Double Tick) ── */
.cb-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--wa-text-muted);
}

.cb-ticks {
  display: flex;
  color: #34b7f1; /* WhatsApp Blue Ticks */
}

/* ── Typing Indicator ── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #929292;
  border-radius: 50%;
  animation: dotWave 1.3s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotWave {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
}

/* ── Blinking Cursor ── */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background-color: var(--wa-text-dark);
  margin-left: 2px;
  vertical-align: middle;
  animation: cursorBlink 0.7s step-end infinite;
}

@keyframes cursorBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* ── Bold Titles ── */
.cb-bold-title {
  display: block;
  font-weight: 700;
  color: #111;
  margin-bottom: 4px;
  font-size: 15px;
}

/* ── Quick Reply Chips ── */
.cb-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 10px;
  align-self: flex-start;
}

.cb-reply-chip {
  background: white;
  border: 1.5px solid var(--wa-accent);
  color: var(--wa-accent);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.cb-reply-chip:hover {
  background: var(--wa-accent);
  color: white;
  transform: translateY(-1px);
}

.cb-bubble-bot.typing-active {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
}

#chatbot-window.show-chat #chatbot-messages {
    overflow-y: auto !important;
}


/* ── Mobile Tweaks ── */
@media (max-width: 480px) {
  .cb-bubble {
    max-width: 90%;
  }
}
