/* ===== Chat Bar (trigger) ===== */
#cw-btn {
  position: fixed;
  bottom: 0;
  right: 28px;
  z-index: 9999;
  width: 320px;
  height: 48px;
  border-radius: 10px 10px 0 0;
  background: #e8192c;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 -2px 16px rgba(232,25,44,.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 10px;
  transition: background .2s;
  font-family: 'Inter', sans-serif;
}
#cw-btn:hover { background: #c4111f; }

#cw-btn-left {
  display: flex;
  align-items: center;
  gap: 9px;
}
#cw-btn-left svg { width: 20px; height: 20px; flex-shrink: 0; }
#cw-btn-label {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .2px;
}

#cw-badge {
  background: #fff;
  color: #e8192c;
  font-size: 11px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-family: 'Inter', sans-serif;
}

#cw-btn-arrow {
  opacity: .7;
  transition: transform .2s;
  flex-shrink: 0;
}
#cw-btn-arrow svg { width: 16px; height: 16px; display: block; }
#cw-btn.cw-bar-open #cw-btn-arrow { transform: rotate(180deg); }

/* ===== Chat Window ===== */
#cw-window {
  position: fixed;
  bottom: 48px;
  right: 28px;
  z-index: 9998;
  width: 320px;
  max-height: 500px;
  background: #fff;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -4px 30px rgba(0,0,0,.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s ease, opacity .25s ease;
  font-family: 'Inter', sans-serif;
}
#cw-window.cw-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#cw-header {
  background: #111;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#cw-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e8192c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
}
#cw-header-info { flex: 1; }
#cw-header-name { font-weight: 700; font-size: 14px; letter-spacing: .2px; }
#cw-header-status { font-size: 11px; color: #9ca3af; margin-top: 1px; }
#cw-header-status.online { color: #4ade80; }
#cw-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: color .15s;
}
#cw-close:hover { color: #fff; }

/* Messages */
#cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
#cw-messages::-webkit-scrollbar { width: 4px; }
#cw-messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 2px; }

.cw-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}
.cw-msg--visitor { align-self: flex-end; align-items: flex-end; }
.cw-msg--agent,
.cw-msg--bot { align-self: flex-start; align-items: flex-start; }

.cw-msg__bubble {
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}
.cw-msg--visitor .cw-msg__bubble {
  background: #e8192c;
  color: #fff;
  border-bottom-right-radius: 3px;
}
.cw-msg--agent .cw-msg__bubble {
  background: #f3f3f3;
  color: #111;
  border-bottom-left-radius: 3px;
}
.cw-msg--bot .cw-msg__bubble {
  background: #f9f9f9;
  color: #4b5563;
  border-bottom-left-radius: 3px;
  border: 1px solid #e5e7eb;
}

.cw-msg__time {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 3px;
  padding: 0 3px;
}
.cw-msg__sender {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 2px;
  padding: 0 3px;
}

/* Typing indicator */
#cw-typing {
  display: none;
  align-self: flex-start;
  padding: 8px 13px;
  background: #f3f3f3;
  border-radius: 10px;
  border-bottom-left-radius: 3px;
}
#cw-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  margin: 0 2px;
  animation: cw-bounce .9s infinite;
}
#cw-typing span:nth-child(2) { animation-delay: .15s; }
#cw-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes cw-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Formulario inicial */
#cw-form {
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}
#cw-form p {
  font-size: 12px;
  color: #6b7280;
  margin: 0 0 10px;
}
.cw-form__row { margin-bottom: 8px; }
.cw-form__row input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
}
.cw-form__row input:focus { border-color: #e8192c; }
.cw-form__row input::placeholder { color: #9ca3af; }
.cw-form__btn {
  width: 100%;
  padding: 10px;
  background: #e8192c;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .4px;
  text-transform: uppercase;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background .2s;
  margin-top: 2px;
}
.cw-form__btn:hover { background: #c4111f; }

/* Input de chat */
#cw-input-area {
  display: flex;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  gap: 8px;
  align-items: flex-end;
}
#cw-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  outline: none;
  resize: none;
  max-height: 90px;
  min-height: 38px;
  line-height: 1.4;
  transition: border-color .15s;
}
#cw-input:focus { border-color: #e8192c; }
#cw-send {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #e8192c;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s;
}
#cw-send:hover { background: #c4111f; }
#cw-send svg { width: 17px; height: 17px; color: #fff; }

/* Saludo inicial */
#cw-greeting {
  background: #fef9c3;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 13px;
  color: #854d0e;
  margin-bottom: 4px;
  line-height: 1.4;
}

/* Responsive */
@media (max-width: 420px) {
  #cw-btn { right: 0; width: 100%; border-radius: 0; }
  #cw-window { right: 0; width: 100%; border-radius: 0; bottom: 48px; }
}
