/* =============================================
   MAGIC CLEANING — CHATBOT STYLES
   Conversion-optimized floating widget
   ============================================= */

:root {
  --cb-primary: #2478e2;
  --cb-primary-dark: #1a5bb5;
  --cb-primary-light: #5a9ef0;
  --cb-secondary: #0F172A;
  --cb-bg: #f0f4f8;
  --cb-surface: #ffffff;
  --cb-surface-dark: #1e293b;
  --cb-text: #0F172A;
  --cb-text-light: #64748b;
  --cb-text-muted: #94a3b8;
  --cb-border: rgba(36,120,226,0.12);
  --cb-success: #10b981;
  --cb-radius: 20px;
  --cb-shadow: 0 12px 48px rgba(15,23,42,0.18), 0 4px 16px rgba(15,23,42,0.08);
  --cb-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── TOGGLE BUTTON ── */
.cb-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 99998;
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-dark) 100%);
  box-shadow: 0 6px 24px rgba(36,120,226,0.4), 0 2px 8px rgba(36,120,226,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
  animation: cb-pulse 3s ease-in-out infinite;
  overflow: hidden;
}
.cb-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(36,120,226,0.55), 0 4px 12px rgba(36,120,226,0.3);
  animation: none;
}
.cb-toggle:active {
  transform: scale(0.95);
}
.cb-toggle svg {
  width: 32px;
  height: 32px;
  transition: transform 0.3s ease;
}
.cb-toggle:hover svg {
  transform: rotate(-8deg) scale(1.08);
}
.cb-toggle .cb-icon-close {
  display: none;
}
.cb-toggle.cb-open .cb-icon-main { display: none; }
.cb-toggle.cb-open .cb-icon-close { display: block; }

@keyframes cb-pulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(36,120,226,0.4), 0 0 0 0 rgba(36,120,226,0.3); }
  50% { box-shadow: 0 6px 24px rgba(36,120,226,0.4), 0 0 0 14px rgba(36,120,226,0); }
}

/* ── NOTIFICATION BADGE ── */
.cb-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  font-family: var(--cb-font);
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  animation: cb-badgePop 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
}
.cb-badge.cb-show { display: flex; }

@keyframes cb-badgePop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ── CHAT CONTAINER ── */
.cb-container {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 540px;
  max-height: calc(100vh - 130px);
  background: var(--cb-bg);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.85) translateY(20px);
  transform-origin: bottom right;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
  border: 1px solid var(--cb-border);
}
.cb-container.cb-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* ── HEADER ── */
.cb-header {
  background: linear-gradient(135deg, var(--cb-secondary) 0%, #1a2744 100%);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.cb-header::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 60%;
  height: 180%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(36,120,226,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.cb-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary), var(--cb-primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  border: 2px solid rgba(255,255,255,0.15);
}
.cb-header-avatar svg {
  width: 22px;
  height: 22px;
}
.cb-header-info {
  flex: 1;
  position: relative;
  z-index: 1;
}
.cb-header-name {
  font-family: var(--cb-font);
  font-weight: 700;
  font-size: 0.95rem;
  color: white;
  margin: 0;
  letter-spacing: -0.01em;
}
.cb-header-status {
  font-family: var(--cb-font);
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.cb-header-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cb-success);
  animation: cb-dotPulse 2s ease-in-out infinite;
}
@keyframes cb-dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.cb-header-close {
  background: rgba(255,255,255,0.08);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
  z-index: 1;
}
.cb-header-close:hover {
  background: rgba(255,255,255,0.15);
}
.cb-header-close svg {
  width: 16px;
  height: 16px;
  color: rgba(255,255,255,0.7);
}

/* ── MESSAGES AREA ── */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  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(0,0,0,0.12); border-radius: 4px; }

/* ── MESSAGE BUBBLES ── */
.cb-msg {
  max-width: 85%;
  padding: 12px 16px;
  font-family: var(--cb-font);
  font-size: 0.88rem;
  line-height: 1.55;
  animation: cb-msgIn 0.3s cubic-bezier(0.4,0,0.2,1);
  word-wrap: break-word;
}
.cb-msg a {
  color: var(--cb-primary-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cb-msg-bot {
  align-self: flex-start;
  background: var(--cb-surface-dark);
  color: rgba(255,255,255,0.92);
  border-radius: 4px 16px 16px 16px;
}
.cb-msg-bot a { color: #93c5fd; }
.cb-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--cb-primary), var(--cb-primary-dark));
  color: white;
  border-radius: 16px 4px 16px 16px;
}
.cb-msg-bot ul, .cb-msg-bot ol {
  margin: 6px 0;
  padding-left: 18px;
}
.cb-msg-bot li { margin-bottom: 3px; }

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

/* ── TYPING INDICATOR ── */
.cb-typing {
  align-self: flex-start;
  background: var(--cb-surface-dark);
  border-radius: 4px 16px 16px 16px;
  padding: 14px 20px;
  display: flex;
  gap: 5px;
  align-items: center;
  animation: cb-msgIn 0.3s ease;
}
.cb-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  animation: cb-typingBounce 1.4s ease-in-out infinite;
}
.cb-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.cb-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes cb-typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── QUICK BUTTONS ── */
.cb-quick {
  padding: 8px 16px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.cb-quick-btn {
  font-family: var(--cb-font);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--cb-primary);
  background: transparent;
  border: 1.5px solid var(--cb-primary);
  border-radius: 20px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.cb-quick-btn:hover {
  background: var(--cb-primary);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(36,120,226,0.3);
}

/* ── INPUT AREA ── */
.cb-input-area {
  padding: 12px 16px 14px;
  background: var(--cb-surface);
  border-top: 1px solid var(--cb-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}
.cb-textarea {
  flex: 1;
  font-family: var(--cb-font);
  font-size: 0.88rem;
  color: var(--cb-text);
  background: var(--cb-bg);
  border: 1.5px solid var(--cb-border);
  border-radius: 14px;
  padding: 10px 14px;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 40px;
  line-height: 1.4;
  transition: border-color 0.2s;
}
.cb-textarea:focus {
  border-color: var(--cb-primary);
}
.cb-textarea::placeholder {
  color: var(--cb-text-muted);
}
.cb-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--cb-primary), var(--cb-primary-dark));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  flex-shrink: 0;
}
.cb-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(36,120,226,0.4);
}
.cb-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.cb-send-btn svg {
  width: 18px;
  height: 18px;
}

/* ── RESPONSIVE (MOBILE) ── */
@media (max-width: 480px) {
  .cb-container {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    transform-origin: bottom center;
  }
  .cb-container.cb-visible {
    border-radius: 0;
  }
  .cb-toggle {
    bottom: 16px;
    right: 16px;
    width: 58px;
    height: 58px;
  }
  .cb-toggle svg {
    width: 28px;
    height: 28px;
  }
}
