/* ============================================
   CARE-IN-CLEANING — Support Widget
   Floating AI Chat + WhatsApp Portal
   ============================================ */

/* ---------- Floating Action Button ---------- */
.cic-widget-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #9333ea, #a855f7);
  box-shadow:
    0 4px 24px rgba(147, 51, 234, 0.4),
    0 0 40px rgba(147, 51, 234, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.cic-widget-fab:hover {
  transform: scale(1.08);
  box-shadow:
    0 6px 32px rgba(147, 51, 234, 0.5),
    0 0 60px rgba(147, 51, 234, 0.2);
}

.cic-widget-fab:active {
  transform: scale(0.96);
}

.cic-widget-fab.open {
  transform: rotate(90deg) scale(0.9);
  background: linear-gradient(135deg, #7e22ce, #9333ea);
}

/* FAB icon layers */
.cic-fab-icon {
  position: relative;
  width: 28px;
  height: 28px;
}

.cic-fab-icon svg {
  position: absolute;
  inset: 0;
  width: 28px;
  height: 28px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.cic-fab-icon .icon-chat {
  opacity: 1;
  transform: scale(1);
  color: #fff;
}

.cic-fab-icon .icon-close {
  opacity: 0;
  transform: scale(0.5) rotate(-90deg);
  color: #fff;
}

.cic-widget-fab.open .cic-fab-icon .icon-chat {
  opacity: 0;
  transform: scale(0.5);
}

.cic-widget-fab.open .cic-fab-icon .icon-close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* FAB pulse ring */
.cic-widget-fab::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(168, 85, 247, 0.3);
  animation: cic-pulse 2.5s ease-in-out infinite;
}

.cic-widget-fab.open::before {
  animation: none;
  opacity: 0;
}

@keyframes cic-pulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 0; }
}

/* FAB hover icons */
.cic-fab-hover-icons {
  position: absolute;
  display: flex;
  gap: 6px;
  right: 72px;
  opacity: 0;
  transform: translateX(8px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.cic-widget-fab:hover .cic-fab-hover-icons {
  opacity: 1;
  transform: translateX(0);
}

.cic-widget-fab.open .cic-fab-hover-icons {
  opacity: 0 !important;
}

.cic-fab-hover-icons span {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.cic-fab-hover-icons .hover-ai {
  background: rgba(147, 51, 234, 0.8);
  color: #fff;
}

.cic-fab-hover-icons .hover-wa {
  background: rgba(37, 211, 102, 0.85);
  color: #fff;
}

/* ---------- Chat Window ---------- */
.cic-widget-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9999;
  width: 380px;
  max-height: 600px;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.12),
    0 8px 24px rgba(147, 51, 234, 0.08),
    0 0 0 1px rgba(147, 51, 234, 0.05);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.cic-widget-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ---------- Window Header ---------- */
.cic-widget-header {
  background: linear-gradient(135deg, #1a0a2e, #2d1050);
  padding: 18px 20px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.cic-widget-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cic-widget-header-avatar img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: brightness(2);
}

.cic-widget-header-info {
  flex: 1;
}

.cic-widget-header-title {
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  line-height: 1.3;
}

.cic-widget-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.cic-widget-header-status .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  animation: cic-status-glow 2s ease-in-out infinite;
}

@keyframes cic-status-glow {
  0%, 100% { box-shadow: 0 0 4px rgba(34, 197, 94, 0.4); }
  50% { box-shadow: 0 0 12px rgba(34, 197, 94, 0.7); }
}

.cic-widget-header-status span {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  font-family: 'Inter', sans-serif;
}

.cic-widget-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.cic-widget-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* ---------- Tab System ---------- */
.cic-widget-tabs {
  display: flex;
  background: rgba(249, 250, 251, 0.95);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.cic-widget-tab {
  flex: 1;
  padding: 11px 12px;
  min-height: 44px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: #64748b;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.cic-widget-tab:hover {
  color: #475569;
  background: rgba(0, 0, 0, 0.02);
}

.cic-widget-tab.active {
  color: #9333ea;
  border-bottom-color: #9333ea;
}

.cic-widget-tab .tab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.cic-widget-tab.active .tab-icon {
  color: #9333ea;
}

/* ---------- Tab Panels ---------- */
.cic-widget-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.cic-widget-panel.active {
  display: flex;
}

/* ---------- AI Chat Panel ---------- */
.cic-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  scroll-behavior: smooth;
}

.cic-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.cic-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(147, 51, 234, 0.2);
  border-radius: 4px;
}

/* Message bubbles */
.cic-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: cic-msg-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cic-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.cic-msg.bot {
  align-self: flex-start;
}

.cic-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.cic-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.cic-msg.bot .cic-msg-avatar {
  background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
}

.cic-msg.user .cic-msg-avatar {
  background: linear-gradient(135deg, #9333ea, #a855f7);
  color: #fff;
  font-size: 12px;
}

.cic-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  line-height: 1.55;
  word-break: break-word;
}

.cic-msg.bot .cic-msg-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

.cic-msg.user .cic-msg-bubble {
  background: linear-gradient(135deg, #9333ea, #a855f7);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.cic-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.cic-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c084fc;
  animation: cic-typing-dot 1.2s ease-in-out infinite;
}

.cic-typing span:nth-child(2) { animation-delay: 0.15s; }
.cic-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cic-typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* WhatsApp handoff button inside chat */
.cic-msg-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 16px;
  background: #25d366;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.cic-msg-wa-btn:hover {
  background: #20bd5a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.cic-msg-wa-btn svg {
  width: 14px;
  height: 14px;
}

/* Chat input area */
.cic-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.8);
  flex-shrink: 0;
}

.cic-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  color: #1e293b;
  background: #fff;
  outline: none;
  resize: none;
  max-height: 80px;
  min-height: 40px;
  line-height: 1.4;
  transition: border-color 0.2s ease;
}

.cic-chat-input:focus {
  border-color: #c084fc;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.08);
}

.cic-chat-input::placeholder {
  color: #94a3b8;
}

.cic-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #9333ea, #a855f7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.cic-chat-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
}

.cic-chat-send:disabled {
  opacity: 0.5;
  transform: none;
  cursor: not-allowed;
}

.cic-chat-send svg {
  width: 18px;
  height: 18px;
}

/* ---------- WhatsApp Panel ---------- */
.cic-wa-panel {
  padding: 28px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.cic-wa-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.25);
}

.cic-wa-avatar svg {
  width: 36px;
  height: 36px;
  color: #fff;
}

.cic-wa-info h3 {
  font-family: 'Inter', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}

.cic-wa-info p {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.5;
}

.cic-wa-service-select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  color: #1e293b;
  background: #fff;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.cic-wa-service-select:focus {
  border-color: #c084fc;
}

.cic-wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 24px;
  background: #25d366;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.25);
}

.cic-wa-btn:hover {
  background: #20bd5a;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.35);
}

.cic-wa-btn svg {
  width: 22px;
  height: 22px;
}

.cic-wa-note {
  font-size: 0.72rem;
  color: #94a3b8;
  font-family: 'Inter', sans-serif;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .cic-widget-window {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 85dvh;
    border-radius: 0;
  }

  .cic-widget-window.open {
    border-radius: 20px 20px 0 0;
  }

  .cic-widget-fab {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  .cic-fab-hover-icons {
    display: none;
  }

  .cic-chat-messages {
    min-height: 0;
  }

  .cic-quick-actions.show {
    max-height: 140px;
  }
}

/* ---------- Quick Action Buttons ---------- */
.cic-quick-actions {
  padding: 0 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  flex-shrink: 0;
}

.cic-quick-actions.show {
  max-height: 120px;
  padding: 10px 16px;
}

.cic-quick-btn {
  padding: 10px 16px;
  min-height: 44px;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.cic-quick-btn:hover {
  border-color: #c084fc;
  color: #9333ea;
  background: #faf5ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(147, 51, 234, 0.12);
}

/* ---------- Proactive Engagement Bubble ---------- */
.cic-proactive-bubble {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9997;
  max-width: 280px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(147, 51, 234, 0.15);
  border-radius: 16px 16px 4px 16px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(147, 51, 234, 0.05);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: #1e293b;
  line-height: 1.5;
  cursor: pointer;
  animation: cic-proactive-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

@keyframes cic-proactive-in {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cic-proactive-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.cic-proactive-close:hover {
  color: #475569;
}

/* ---------- FAB Notification Badge ---------- */
.cic-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fff;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s ease;
}

.cic-fab-badge.show {
  opacity: 1;
  transform: scale(1);
}

.cic-widget-fab.has-proactive .cic-fab-badge {
  opacity: 1;
  transform: scale(1);
  animation: cic-badge-pulse 1.5s ease-in-out infinite;
}

@keyframes cic-badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ---------- Night Mode Status Dot ---------- */
.status-dot.night {
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
  animation: cic-night-glow 2s ease-in-out infinite;
}

@keyframes cic-night-glow {
  0%, 100% { box-shadow: 0 0 4px rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 12px rgba(245, 158, 11, 0.7); }
}

/* ---------- Lead Handoff Button ---------- */
.cic-lead-handoff {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.cic-handoff-btn {
  display: flex !important;
  width: 100%;
  padding: 12px 18px !important;
  border-radius: 12px !important;
  font-size: 0.85rem !important;
  font-weight: 700 !important;
  justify-content: center;
  animation: cic-handoff-glow 2s ease-in-out infinite;
}

@keyframes cic-handoff-glow {
  0%, 100% { box-shadow: 0 4px 16px rgba(37, 211, 102, 0.25); }
  50% { box-shadow: 0 4px 24px rgba(37, 211, 102, 0.45); }
}

/* ---------- Responsive (proactive) ---------- */
@media (max-width: 480px) {
  .cic-proactive-bubble {
    right: 12px;
    bottom: 88px;
    max-width: 260px;
  }
}
