/* Chat Widget — WhatsApp Style */
#chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Floating bubble */
.cw-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #25D366;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transition: transform 0.2s, box-shadow 0.2s;
}

.cw-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.cw-bubble.hidden {
  display: none;
}

/* Chat window */
.cw-window {
  display: none;
  flex-direction: column;
  width: 380px;
  height: 520px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  background: #e5ddd5;
}

.cw-window.open {
  display: flex;
}

/* Header */
.cw-header {
  background: #128C7E;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.cw-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.cw-name {
  font-weight: 600;
  font-size: 1rem;
}

.cw-status {
  font-size: 0.75rem;
  opacity: 0.8;
}

.cw-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.8;
}

.cw-close:hover {
  opacity: 1;
}

/* Tabs */
.cw-tabs {
  display: flex;
  background: #075E54;
}

.cw-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  border-bottom: 3px solid transparent;
}

.cw-tab.active {
  color: #fff;
  border-bottom-color: #25D366;
}

.cw-tab:hover {
  color: rgba(255,255,255,0.9);
}

/* Messages area */
.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #e5ddd5 url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4cfc6' fill-opacity='0.3'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.cw-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.cw-msg-user {
  background: #dcf8c6;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.cw-msg-bot {
  background: #fff;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.cw-msg-photo {
  padding: 4px;
  max-width: 85%;
}

.cw-msg-photo img {
  display: block;
  max-width: 100%;
  border-radius: 6px;
}

/* Typing indicator */
.cw-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.cw-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: cw-bounce 1.4s infinite both;
}

.cw-typing span:nth-child(2) { animation-delay: 0.16s; }
.cw-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes cw-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input area */
.cw-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #f0f0f0;
}

.cw-input-area input {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 24px;
  font-size: 0.9rem;
  outline: none;
  background: #fff;
}

.cw-input-area button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #25D366;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.cw-input-area button:hover {
  background: #128C7E;
}

/* Activity Log */
.cw-activity-log {
  align-self: flex-start;
  background: #f0f4ff;
  border: 1px solid #d0d8f0;
  border-radius: 8px;
  padding: 8px 10px;
  max-width: 90%;
  font-size: 0.8rem;
  animation: cw-slideIn 0.3s ease;
}

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

.cw-activity-header {
  font-weight: 700;
  color: #555;
  margin-bottom: 6px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cw-activity-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-top: 1px solid #e0e4f0;
}

.cw-activity-item:first-of-type {
  border-top: none;
}

.cw-activity-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
}

.cw-activity-text {
  flex: 1;
  color: #444;
}

.cw-activity-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.cw-badge-read {
  background: #e3f2fd;
  color: #1565c0;
}

.cw-badge-write {
  background: #e8f5e9;
  color: #2e7d32;
}

/* Mobile */
@media (max-width: 480px) {
  .cw-window {
    width: calc(100vw - 16px);
    height: calc(100vh - 80px);
    border-radius: 12px;
    position: fixed;
    bottom: 8px;
    right: 8px;
  }
}
