/* =============================================
   Coutechtronics Chat Widget
   ============================================= */

/* --- Trigger Button --- */
#cou-chat-trigger {
  position: fixed;
  bottom: 104px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9990;
  box-shadow: 0 4px 20px rgba(37,99,235,0.45);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.35s ease, transform 0.35s ease, background 0.2s;
  pointer-events: none;
}
#cou-chat-trigger.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
#cou-chat-trigger:hover {
  background: #1d4ed8;
}
#cou-chat-trigger svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#cou-chat-trigger .cou-notif-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  background: #f97316;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: couPulse 1.8s ease-in-out infinite;
}
@keyframes couPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* --- Chat Window --- */
#cou-chat-window {
  position: fixed;
  bottom: 172px;
  right: 24px;
  width: 340px;
  height: 480px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 48px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  z-index: 9991;
  overflow: hidden;
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#cou-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* --- Header --- */
.cou-chat-header {
  background: #0f172a;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.cou-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cou-chat-avatar svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}
.cou-chat-header-info {
  flex: 1;
}
.cou-chat-header-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.cou-chat-header-status {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 5px;
}
.cou-chat-header-status::before {
  content: "";
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}
.cou-chat-close {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.cou-chat-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}
.cou-chat-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* --- Messages Area --- */
.cou-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.cou-chat-messages::-webkit-scrollbar { width: 4px; }
.cou-chat-messages::-webkit-scrollbar-track { background: transparent; }
.cou-chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* --- Message Bubbles --- */
.cou-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: couMsgIn 0.25s ease;
}
@keyframes couMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cou-msg--bot { align-self: flex-start; }
.cou-msg--user { align-self: flex-end; }

.cou-msg__bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}
.cou-msg--bot .cou-msg__bubble {
  background: #fff;
  color: #0f172a;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.cou-msg--user .cou-msg__bubble {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* --- Typing Indicator --- */
.cou-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  align-self: flex-start;
  animation: couMsgIn 0.25s ease;
}
.cou-typing span {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  display: inline-block;
  animation: couTypingBounce 1.2s ease-in-out infinite;
}
.cou-typing span:nth-child(2) { animation-delay: 0.2s; }
.cou-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes couTypingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* --- Quick Reply Pills --- */
.cou-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  align-self: flex-start;
  max-width: 90%;
}
.cou-qr-btn {
  background: #fff;
  color: #2563eb;
  border: 1.5px solid #2563eb;
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.cou-qr-btn:hover {
  background: #2563eb;
  color: #fff;
}

/* --- Input Row --- */
.cou-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}
.cou-chat-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  color: #0f172a;
  background: #f8f9fa;
  transition: border-color 0.2s;
  resize: none;
}
.cou-chat-input:focus {
  border-color: #2563eb;
  background: #fff;
}
.cou-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #2563eb;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.cou-chat-send:hover { background: #1d4ed8; }
.cou-chat-send svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Mobile Full Screen --- */
@media (max-width: 500px) {
  #cou-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  #cou-chat-trigger {
    bottom: 96px;
    right: 18px;
  }
}
