/* ==========================================================================
   FLOATING CHAT WIDGET
   ========================================================================== */

/* --- Bubble --- */
.cw-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0085C7, #33a3d6, #60c0e8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9999;
  border: none;
  padding: 0;
  animation: cw-breathe 3s ease-in-out infinite;
  transition: opacity 0.5s ease-out, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: translateY(80px);
  opacity: 0;
}
.cw-bubble.cw-entered {
  transform: translateY(0);
  opacity: 1;
}
.cw-bubble.cw-entered:hover {
  transform: scale(1.08);
}
.cw-bubble.cw-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}
.cw-bubble-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 0 2.5px #fff;
  animation: cw-dot-ping 3s ease-in-out infinite;
}
@keyframes cw-dot-ping {
  0%, 100% { box-shadow: 0 0 0 2.5px #fff; transform: scale(1); }
  50% { box-shadow: 0 0 0 2.5px #fff, 0 0 0 6px rgba(34,197,94,0.4); transform: scale(1.15); }
}
.cw-bubble svg {
  animation: cw-icon-wiggle 4s ease-in-out infinite;
}
@keyframes cw-icon-wiggle {
  0%, 70%, 100% { transform: rotate(0deg); }
  75% { transform: rotate(12deg); }
  80% { transform: rotate(-8deg); }
  85% { transform: rotate(5deg); }
  90% { transform: rotate(0deg); }
}
@keyframes cw-breathe {
  0%, 100% { box-shadow: 0 4px 24px rgba(0,133,199,0.5); }
  50% { box-shadow: 0 4px 32px rgba(0,133,199,0.7), 0 0 48px rgba(0,133,199,0.15); }
}

/* --- Nudge tooltip --- */
.cw-nudge {
  position: fixed;
  bottom: 96px;
  right: 24px;
  background: #fff;
  color: #1a1a1a;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.cw-nudge.cw-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.cw-nudge::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 28px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 2px 2px 4px rgba(0,0,0,0.05);
}
.cw-nudge-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  margin-left: 8px;
  font-size: 12px;
  padding: 0;
}

/* --- Panel --- */
.cw-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 370px;
  height: 540px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}
.cw-panel.cw-open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* --- Panel header --- */
.cw-header {
  background: linear-gradient(135deg, #0085C7, #33a3d6);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.cw-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cw-header-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cw-header-info h3 {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  margin: 0;
}
.cw-header-info span {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  gap: 4px;
}
.cw-status-dot {
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}
.cw-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cw-header-restart,
.cw-header-close {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 16px;
  border: none;
  padding: 0;
  transition: background 0.15s;
}
.cw-header-restart:hover,
.cw-header-close:hover {
  background: rgba(255,255,255,0.25);
}

/* --- Messages area --- */
.cw-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f9fafb;
}

/* --- Messages --- */
.cw-msg {
  display: flex;
  gap: 8px;
  animation: cw-msg-in 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes cw-msg-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.cw-msg-bot { align-items: flex-start; }
.cw-msg-user { justify-content: flex-end; }
.cw-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0085C7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cw-msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 16px;
}
.cw-msg-bot .cw-msg-bubble {
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}
.cw-msg-user .cw-msg-bubble {
  background: #0085C7;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* --- Typing indicator --- */
.cw-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  align-items: center;
}
.cw-typing-dot {
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: cw-bounce 1.2s ease-in-out infinite;
}
.cw-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.cw-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes cw-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* --- Options --- */
.cw-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
  animation: cw-msg-in 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
.cw-opt-btn {
  padding: 8px 14px;
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 100px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
  font-family: inherit;
}
.cw-opt-btn:hover {
  border-color: #0085C7;
  color: #0085C7;
  background: rgba(0,133,199,0.05);
}
.cw-opt-btn.cw-selected {
  background: #0085C7;
  border-color: #0085C7;
  color: #fff;
}
.cw-opt-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.cw-opt-btn.cw-selected:disabled {
  opacity: 1;
}

/* --- Contact form --- */
.cw-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  animation: cw-msg-in 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
.cw-form input,
.cw-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 0;
  font-size: 13px;
  color: #1a1a1a;
  font-family: inherit;
  transition: border-color 0.15s;
}
.cw-form textarea {
  resize: vertical;
  min-height: 60px;
}
.cw-form input:focus,
.cw-form textarea:focus {
  outline: none;
  border-color: #0085C7;
}
.cw-form input::placeholder,
.cw-form textarea::placeholder {
  color: #9ca3af;
}
.cw-form-submit {
  padding: 10px;
  background: #0085C7;
  color: #fff;
  border: none;
  border-radius: 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.cw-form-submit:hover {
  background: #006da3;
}

/* --- Success card --- */
.cw-success {
  text-align: center;
  padding: 24px 16px;
  animation: cw-success-pop 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
.cw-success-icon {
  width: 48px;
  height: 48px;
  background: #22c55e;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 20px;
  color: #fff;
}
.cw-success h3 {
  margin-bottom: 8px;
  color: #1a1a1a;
  font-size: 16px;
}
.cw-success p {
  color: #6b7280;
  font-size: 13px;
  line-height: 1.5;
}
@keyframes cw-success-pop {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

/* --- Footer --- */
.cw-footer {
  padding: 10px 16px;
  background: #fff;
  border-top: 1px solid #f0f0f0;
  text-align: center;
  font-size: 11px;
  color: #9ca3af;
  flex-shrink: 0;
}

/* --- Mobile --- */
@media (max-width: 639px) {
  .cw-bubble {
    bottom: 16px;
    right: 16px;
  }
  .cw-nudge {
    display: none !important;
  }
  .cw-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    height: calc(100% - 24px);
    border-radius: 16px 16px 0 0;
  }
}
