/* ═══════════════════════════════════════════════════════════════════════════
   Chat Widget (floating bubble for users)
   ═══════════════════════════════════════════════════════════════════════════ */

#chat-widget-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Segoe UI', sans-serif;
}

/* FAB button */
.cw-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00d26a 0%, #00b85c 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s;
  position: relative;
  color: #fff;
}
.cw-fab:hover {
  transform: scale(1.08);
}
.cw-fab-active {
  background: linear-gradient(135deg, #333 0%, #222 100%);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}

/* Badge */
.cw-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #ff4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 2px 8px rgba(255, 68, 68, .4);
}

/* Panel */
.cw-badge[hidden] { display: none; }
.cw-panel {
  position: absolute;
  bottom: 64px;
  right: 0;
  width: 340px;
  height: 480px;
  background: #1a1a1e;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255,255,255,.06);
  animation: cw-slideUp .2s ease-out;
}

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

/* Header */
.cw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #111;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.cw-header-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: #fff;
}
.cw-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cw-sound {
  background: none;
  border: none;
  color: rgba(255,255,255,.4);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s;
}
.cw-sound:hover { color: #fff; }
.cw-sound[aria-pressed="false"] .cw-sound-waves,
.cw-sound[aria-pressed="true"] .cw-sound-slash { display: none; }
.cw-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.4);
  font-size: 22px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color .15s;
}
.cw-close:hover { color: #fff; }

/* Messages */
.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cw-messages::-webkit-scrollbar { width: 4px; }
.cw-messages::-webkit-scrollbar-track { background: transparent; }
.cw-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.cw-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}
.cw-msg-user {
  align-self: flex-end;
  align-items: flex-end;
}
.cw-msg-admin {
  align-self: flex-start;
  align-items: flex-start;
}

.cw-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.cw-msg-user .cw-msg-bubble {
  background: #2a2a2e;
  color: #e0e0e0;
  border-bottom-right-radius: 4px;
}
.cw-msg-admin .cw-msg-bubble {
  background: linear-gradient(135deg, #00d26a 0%, #00b85c 100%);
  color: #000;
  font-weight: 500;
  border-bottom-left-radius: 4px;
}

.cw-msg-time {
  font-size: 10px;
  color: rgba(255,255,255,.25);
  margin-top: 3px;
  padding: 0 4px;
}

/* Input */
.cw-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #111;
  border-top: 1px solid rgba(255,255,255,.06);
}
.cw-input {
  flex: 1;
  background: #222;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px;
  padding: 9px 14px;
  color: #e0e0e0;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.cw-input::placeholder { color: rgba(255,255,255,.25); }
.cw-input:focus { border-color: rgba(0, 210, 106, .5); }

.cw-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #00d26a;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  transition: background .15s;
  flex-shrink: 0;
}
.cw-send:hover { background: #00e676; }

/* Estado (errores / envío) y conversación vacía — 4.0.9 */
.cw-status {
  min-height: 0;
  padding: 0 14px;
  font-size: 11px;
  color: #f87171;
  background: #111;
}
.cw-status:not(:empty) { padding: 6px 14px; }
.cw-empty {
  margin: auto 8px;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255,255,255,.4);
}
.cw-msg-bubble { white-space: pre-wrap; overflow-wrap: anywhere; }
.cw-send:disabled { opacity: .5; cursor: default; }
