/* ============================================================
   CHATBOT STYLES - 831 Cleaning Services
   ============================================================ */

:root {
  --cb-primary: #023181;
  --cb-accent: #1148A9;
  --cb-cta: #E41B38;
  --cb-surface: #f8fafc;
  --cb-dark-surface: #1e293b;
  --cb-text: #334155;
  --cb-text-light: #94a3b8;
  --cb-radius: 20px;
  --cb-shadow: 0 25px 50px rgba(2, 49, 129, 0.25);
}

/* ── Floating Toggle Button ── */
.cb-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--cb-primary), var(--cb-accent));
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(2, 49, 129, 0.4);
  transition: background 0.5s ease, box-shadow 0.4s ease;
  animation: cb-float 3s ease-in-out infinite, cb-glow 2.5s ease-in-out infinite;
  overflow: visible;
}

.cb-toggle:hover {
  box-shadow: 0 6px 30px rgba(2, 49, 129, 0.6);
}

.cb-toggle.cb-open {
  animation: none;
  background: linear-gradient(135deg, var(--cb-cta), #ff4d6a);
  box-shadow: 0 4px 25px rgba(228, 27, 56, 0.4);
}

/* ── Sparkle icon (closed) ── */
.cb-icon-sparkle {
  width: 28px;
  height: 28px;
  animation: cb-sparkle-spin 6s linear infinite;
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.5));
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.cb-toggle:hover .cb-icon-sparkle {
  animation: cb-sparkle-spin 2s linear infinite;
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.8));
}

/* ── Close icon (open) ── morphing X ── */
.cb-icon-close {
  width: 26px;
  height: 26px;
  animation: cb-close-morph-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  filter: drop-shadow(0 0 3px rgba(255,255,255,0.4));
}

.cb-toggle:hover .cb-icon-close {
  animation: cb-close-wiggle 0.5s ease-in-out;
}

/* ── Orbiting particles ring ── */
.cb-orbit-ring {
  position: absolute;
  width: 84px;
  height: 84px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: cb-orbit-spin 8s linear infinite;
}

.cb-open .cb-orbit-ring {
  animation: cb-orbit-spin 4s linear infinite reverse;
}

.cb-orbit-dot {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: white;
  opacity: 0.7;
}

.cb-orbit-dot:nth-child(1) { top: 0; left: 50%; transform: translateX(-50%); animation: cb-dot-twinkle 2s ease-in-out infinite; }
.cb-orbit-dot:nth-child(2) { bottom: 0; left: 50%; transform: translateX(-50%); animation: cb-dot-twinkle 2s ease-in-out 0.5s infinite; }
.cb-orbit-dot:nth-child(3) { left: 0; top: 50%; transform: translateY(-50%); animation: cb-dot-twinkle 2s ease-in-out 1s infinite; width: 4px; height: 4px; }
.cb-orbit-dot:nth-child(4) { right: 0; top: 50%; transform: translateY(-50%); animation: cb-dot-twinkle 2s ease-in-out 1.5s infinite; width: 4px; height: 4px; }

.cb-open .cb-orbit-dot {
  background: #ff8fa3;
}

/* ── Burst particles on open ── */
.cb-burst {
  position: absolute;
  pointer-events: none;
  top: 50%;
  left: 50%;
}

.cb-burst-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0;
}

.cb-burst-particle:nth-child(1) { background: #ffd700; animation: cb-burst-1 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }
.cb-burst-particle:nth-child(2) { background: #ff6b6b; animation: cb-burst-2 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.05s forwards; }
.cb-burst-particle:nth-child(3) { background: #48dbfb; animation: cb-burst-3 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s forwards; }
.cb-burst-particle:nth-child(4) { background: #ff9ff3; animation: cb-burst-4 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.07s forwards; }
.cb-burst-particle:nth-child(5) { background: #54a0ff; animation: cb-burst-5 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.12s forwards; }
.cb-burst-particle:nth-child(6) { background: #5f27cd; animation: cb-burst-6 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.03s forwards; }

/* ── Keyframes ── */
@keyframes cb-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes cb-glow {
  0%, 100% { box-shadow: 0 4px 20px rgba(2, 49, 129, 0.4); }
  50% { box-shadow: 0 4px 30px rgba(17, 72, 169, 0.6), 0 0 0 8px rgba(17, 72, 169, 0.08), 0 0 20px rgba(17, 72, 169, 0.2); }
}

@keyframes cb-sparkle-spin {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.1); }
  50% { transform: rotate(180deg) scale(1); }
  75% { transform: rotate(270deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes cb-close-morph-in {
  0% { transform: rotate(-180deg) scale(0); opacity: 0; }
  60% { transform: rotate(15deg) scale(1.2); opacity: 1; }
  100% { transform: rotate(0deg) scale(1); opacity: 1; }
}

@keyframes cb-close-wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(12deg); }
  75% { transform: rotate(-12deg); }
}

@keyframes cb-orbit-spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes cb-dot-twinkle {
  0%, 100% { opacity: 0.3; transform-origin: center; scale: 0.8; }
  50% { opacity: 1; scale: 1.3; }
}

@keyframes cb-burst-1 { 0% { opacity: 1; transform: translate(0,0) scale(1); } 100% { opacity: 0; transform: translate(-30px, -35px) scale(0); } }
@keyframes cb-burst-2 { 0% { opacity: 1; transform: translate(0,0) scale(1); } 100% { opacity: 0; transform: translate(28px, -30px) scale(0); } }
@keyframes cb-burst-3 { 0% { opacity: 1; transform: translate(0,0) scale(1); } 100% { opacity: 0; transform: translate(35px, 15px) scale(0); } }
@keyframes cb-burst-4 { 0% { opacity: 1; transform: translate(0,0) scale(1); } 100% { opacity: 0; transform: translate(-25px, 28px) scale(0); } }
@keyframes cb-burst-5 { 0% { opacity: 1; transform: translate(0,0) scale(1); } 100% { opacity: 0; transform: translate(10px, -40px) scale(0); } }
@keyframes cb-burst-6 { 0% { opacity: 1; transform: translate(0,0) scale(1); } 100% { opacity: 0; transform: translate(-35px, -5px) scale(0); } }

/* ── Notification Badge ── */
.cb-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cb-cta);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Montserrat', sans-serif;
  animation: cb-badge-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid white;
}

@keyframes cb-badge-in {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* ── Chat Window ── */
.cb-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 520px;
  max-height: 80vh;
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  z-index: 9997;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--cb-surface);
  font-family: 'Montserrat', sans-serif;
  transform-origin: bottom right;
}

.cb-window.cb-hidden {
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cb-window.cb-visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Header ── */
.cb-header {
  background: linear-gradient(135deg, var(--cb-primary), var(--cb-accent));
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cb-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.cb-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.cb-header-title {
  color: white;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}

.cb-header-status {
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.cb-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: cb-online-pulse 2s ease-in-out infinite;
}

@keyframes cb-online-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.cb-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.2s;
}

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

.cb-close svg {
  width: 20px;
  height: 20px;
  color: white;
}

/* ── Messages Area ── */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--cb-surface);
}

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

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

.cb-messages::-webkit-scrollbar-thumb {
  background: var(--cb-accent);
  border-radius: 4px;
  opacity: 0.3;
}

/* ── Message Bubbles ── */
.cb-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: cb-message-in 0.3s ease-out;
}

.cb-message-user {
  align-self: flex-end;
  align-items: flex-end;
}

.cb-message-bot {
  align-self: flex-start;
  align-items: flex-start;
}

.cb-bubble {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.cb-bubble-user {
  background: linear-gradient(135deg, var(--cb-accent), var(--cb-primary));
  color: white;
  border-radius: 16px 16px 4px 16px;
}

.cb-bubble-bot {
  background: white;
  color: var(--cb-text);
  border-radius: 16px 16px 16px 4px;
  border: 1px solid #e2e8f0;
}

.cb-bubble a {
  color: var(--cb-accent);
  text-decoration: underline;
}

.cb-bubble-user a {
  color: #93c5fd;
}

.cb-bubble strong {
  font-weight: 700;
}

.cb-bubble ul, .cb-bubble ol {
  margin: 4px 0;
  padding-left: 18px;
}

.cb-bubble li {
  margin: 2px 0;
}

.cb-time {
  font-size: 10px;
  color: var(--cb-text-light);
  margin-top: 4px;
  padding: 0 4px;
}

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

/* ── Typing Indicator ── */
.cb-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
}

.cb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cb-accent);
  animation: cb-dot-bounce 1.4s ease-in-out infinite;
}

.cb-dot:nth-child(2) { animation-delay: 0.2s; }
.cb-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Quick Action Buttons ── */
.cb-quick-actions {
  padding: 8px 16px 4px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex-shrink: 0;
  background: var(--cb-surface);
}

.cb-quick-actions::-webkit-scrollbar {
  display: none;
}

.cb-quick-btn {
  white-space: nowrap;
  padding: 6px 12px;
  border: 1.5px solid var(--cb-accent);
  color: var(--cb-accent);
  background: transparent;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}

.cb-quick-btn:hover {
  background: var(--cb-accent);
  color: white;
  transform: translateY(-1px);
}

/* ── Input Area ── */
.cb-input-area {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: white;
  flex-shrink: 0;
}

.cb-input-area textarea {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: 'Montserrat', sans-serif;
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 100px;
  line-height: 1.4;
  color: var(--cb-text);
  transition: border-color 0.2s;
}

.cb-input-area textarea:focus {
  border-color: var(--cb-accent);
}

.cb-input-area textarea::placeholder {
  color: var(--cb-text-light);
}

.cb-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--cb-cta);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.cb-send:hover:not(:disabled) {
  background: #c41530;
  transform: scale(1.05);
}

.cb-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cb-send svg {
  width: 18px;
  height: 18px;
}

/* ── Responsive: Mobile ── */
@media (max-width: 639px) {
  .cb-toggle {
    bottom: 80px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  .cb-toggle svg {
    width: 24px;
    height: 24px;
  }

  .cb-window {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    transform-origin: bottom right;
  }
}
