/* ═══════════════════════════════════════════════════════════════
   BASSATINES CHATBOT WIDGET — Styles
   Scoped under #bassatine-chatbot-root to avoid conflicts
   ═══════════════════════════════════════════════════════════════ */

#bassatine-chatbot-root {
  --cb-primary: #1B4332;
  --cb-primary-light: #2D6A4F;
  --cb-primary-dark: #0B2618;
  --cb-accent: #D4A762;
  --cb-accent-light: #E8C992;
  --cb-bg: #FAFAF7;
  --cb-bg-chat: #F0EDE6;
  --cb-text: #1A1A1A;
  --cb-text-light: #6B6B6B;
  --cb-white: #FFFFFF;
  --cb-font: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
  font-family: var(--cb-font);
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 9999;
  line-height: 1.5;
}

/* ─── Floating Action Button ─── */

#cb-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary), var(--cb-primary-light));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(27,67,50,0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 10000;
}
#cb-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(27,67,50,0.45);
}
#cb-fab svg {
  width: 28px;
  height: 28px;
  fill: var(--cb-white);
}
#cb-fab .cb-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cb-accent);
  color: var(--cb-white);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--cb-white);
}
#cb-fab .cb-badge.cb-hidden { display: none; }

#cb-fab .cb-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--cb-primary);
  opacity: 0;
  animation: cb-pulseRing 2s ease-out infinite;
}

/* ─── Chat Window ─── */

#cb-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 120px);
  max-width: calc(100vw - 16px);
  border-radius: 20px;
  background: var(--cb-bg);
  box-shadow: 0 12px 48px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 10001;
}
#cb-window.cb-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ─── Header ─── */

.cb-header {
  background: linear-gradient(135deg, var(--cb-primary-dark), var(--cb-primary));
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.cb-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-accent), var(--cb-accent-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--cb-white);
  flex-shrink: 0;
}
.cb-header-info {
  flex: 1;
  min-width: 0;
}
.cb-header-title {
  color: var(--cb-white);
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.cb-header-subtitle {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  margin: 0;
}
.cb-header-close {
  background: rgba(255,255,255,0.15);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.cb-header-close:hover { background: rgba(255,255,255,0.25); }
.cb-header-close svg { width: 16px; height: 16px; fill: var(--cb-white); }

/* ─── Messages Area ─── */

.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--cb-bg-chat);
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}
.cb-messages::-webkit-scrollbar { width: 5px; }
.cb-messages::-webkit-scrollbar-track { background: transparent; }
.cb-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; }

/* ─── Message Bubbles ─── */

.cb-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: cb-fadeSlideIn 0.3s ease-out;
}
.cb-msg.cb-bot { justify-content: flex-start; padding-right: 36px; }
.cb-msg.cb-user { justify-content: flex-end; padding-left: 36px; }

.cb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary), var(--cb-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--cb-white);
  flex-shrink: 0;
}

.cb-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  max-width: 100%;
}
.cb-bot .cb-bubble {
  background: var(--cb-white);
  color: var(--cb-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.cb-user .cb-bubble {
  background: var(--cb-primary);
  color: var(--cb-white);
  border-bottom-right-radius: 4px;
}

.cb-msg-time {
  font-size: 11px;
  color: var(--cb-text-light);
  margin-top: 2px;
  opacity: 0.7;
  padding: 0 4px;
}
.cb-bot .cb-msg-time { text-align: left; }
.cb-user .cb-msg-time { text-align: right; }

/* ─── Typing Indicator ─── */

.cb-typing {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-right: 36px;
}
.cb-typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--cb-white);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.cb-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cb-text-light);
  animation: cb-typingDot 1.4s ease-in-out infinite;
}
.cb-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.cb-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ─── Quick Replies ─── */

.cb-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0;
}
.cb-quick-btn {
  background: var(--cb-white);
  border: 1.5px solid var(--cb-accent);
  color: var(--cb-primary);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--cb-font);
  white-space: nowrap;
}
.cb-quick-btn:hover {
  background: var(--cb-accent);
  color: var(--cb-white);
  border-color: var(--cb-accent);
}

/* ─── Action Cards ─── */

.cb-action-card {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--cb-accent-light);
  background: #FFFDF7;
  font-size: 13px;
  animation: cb-fadeSlideIn 0.3s ease-out;
}
.cb-action-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--cb-primary);
}
.cb-action-btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--cb-font);
  transition: opacity 0.15s;
}
.cb-action-btn:hover { opacity: 0.85; }
.cb-action-btn.cb-btn-accent {
  background: var(--cb-accent);
  color: var(--cb-white);
}
.cb-action-btn.cb-btn-primary {
  background: var(--cb-primary);
  color: var(--cb-white);
}

/* ─── Lot Summary Card ─── */

.cb-lots-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.cb-lot-stat {
  padding: 8px 10px;
  border-radius: 8px;
  background: #E8F5E9;
  text-align: center;
}
.cb-lot-stat-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--cb-primary);
}
.cb-lot-stat-label {
  font-size: 11px;
  color: var(--cb-text-light);
}

/* ─── Contact Form ─── */

.cb-contact-form {
  margin-top: 8px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--cb-accent-light);
  background: #FFFDF7;
  animation: cb-fadeSlideIn 0.3s ease-out;
}
.cb-contact-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--cb-primary);
  margin-bottom: 4px;
}
.cb-contact-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #D1D5DB;
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--cb-font);
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 8px;
  box-sizing: border-box;
}
.cb-contact-form input:focus {
  border-color: var(--cb-accent);
}
.cb-contact-form input.cb-input-error {
  border-color: #C1292E;
}
.cb-contact-form .cb-form-error {
  color: #C1292E;
  font-size: 12px;
  margin-top: -4px;
  margin-bottom: 6px;
}
.cb-contact-form button {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  background: var(--cb-primary);
  color: var(--cb-white);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: var(--cb-font);
  transition: opacity 0.15s;
}
.cb-contact-form button:hover { opacity: 0.9; }
.cb-contact-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Confirmation Card ─── */

.cb-confirm-card {
  margin-top: 8px;
  padding: 14px;
  border-radius: 12px;
  background: #E8F5E9;
  border: 1px solid #A5D6A7;
  text-align: center;
  animation: cb-fadeSlideIn 0.3s ease-out;
}
.cb-confirm-icon {
  font-size: 28px;
  margin-bottom: 4px;
}
.cb-confirm-text {
  font-size: 13px;
  color: var(--cb-primary);
  font-weight: 500;
}

/* ─── Input Area ─── */

.cb-input-area {
  padding: 12px 14px;
  background: var(--cb-white);
  border-top: 1px solid #E5E7EB;
  flex-shrink: 0;
}
.cb-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cb-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #E5E7EB;
  border-radius: 24px;
  font-size: 14px;
  font-family: var(--cb-font);
  outline: none;
  transition: border-color 0.15s;
}
.cb-input-row input:focus {
  border-color: var(--cb-accent);
}
.cb-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--cb-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.cb-send-btn:hover { background: var(--cb-primary-light); }
.cb-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cb-send-btn svg { width: 18px; height: 18px; fill: var(--cb-white); }

.cb-powered {
  text-align: center;
  font-size: 11px;
  color: var(--cb-text-light);
  margin-top: 6px;
  opacity: 0.6;
}

/* ─── Animations ─── */

@keyframes cb-fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cb-typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

@keyframes cb-pulseRing {
  0% { transform: scale(1); opacity: 0.4; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ─── Mobile Responsive ─── */

@media (max-width: 480px) {
  #cb-window {
    width: calc(100vw - 16px);
    height: calc(100vh - 80px);
    max-height: calc(100vh - 80px);
    bottom: 8px;
    right: 8px;
    border-radius: 16px;
  }
  #cb-fab {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }
  .cb-input-row input {
    font-size: 16px; /* Prevent iOS zoom */
  }
  .cb-contact-form input {
    font-size: 16px;
  }
}
