/* ── CMP Chat Widget Styles ─────────────────────────────────── */

/* Floating bubble */
.cmp-chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 58px;
  height: 58px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99990;
  box-shadow: 0 4px 20px rgba(99,102,241,.45);
  transition: transform .2s, box-shadow .2s;
  border: none;
  outline: none;
}
.cmp-chat-bubble:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(99,102,241,.55); }
.cmp-chat-bubble svg { width: 26px; height: 26px; fill: #fff; }
.cmp-chat-bubble .cmp-badge {
  position: absolute;
  top: -3px; right: -3px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  display: none;
}
.cmp-chat-bubble .cmp-badge.visible { display: flex; }

/* Chat window */
.cmp-chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  z-index: 99989;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  animation: cmpSlideUp .22s ease;
}
.cmp-chat-window.open { display: flex; }

@keyframes cmpSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.cmp-chat-header {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.cmp-chat-header-avatar {
  width: 38px; height: 38px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.cmp-chat-header-info { flex: 1; }
.cmp-chat-header-info h4 { margin: 0; font-size: 14px; font-weight: 600; }
.cmp-chat-header-info p  { margin: 0; font-size: 11px; opacity: .8; }
.cmp-chat-header-close {
  background: rgba(255,255,255,.15);
  border: none; color: #fff;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cmp-chat-header-close:hover { background: rgba(255,255,255,.28); }

/* Department selector (shown before chat starts) */
.cmp-dept-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  gap: 10px;
}
.cmp-dept-screen h3 { margin: 0 0 4px; font-size: 15px; color: #1e293b; text-align: center; }
.cmp-dept-screen p  { margin: 0 0 16px; font-size: 12px; color: #64748b; text-align: center; }
.cmp-dept-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}
.cmp-dept-btn {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 10px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s, transform .1s;
  font-size: 13px;
  color: #334155;
  font-weight: 500;
}
.cmp-dept-btn:hover {
  border-color: #6366f1;
  background: #eef2ff;
  transform: translateY(-1px);
}
.cmp-dept-btn .cmp-dept-icon { font-size: 22px; display: block; margin-bottom: 4px; }

/* Messages area */
.cmp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.cmp-chat-messages::-webkit-scrollbar { width: 4px; }
.cmp-chat-messages::-webkit-scrollbar-track { background: transparent; }
.cmp-chat-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 2px; }

/* Individual messages */
.cmp-msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  animation: cmpFadeIn .18s ease;
}
@keyframes cmpFadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

.cmp-msg.bot, .cmp-msg.agent {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 3px;
  align-self: flex-start;
}
.cmp-msg.agent { background: #eef2ff; }
.cmp-msg.visitor {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  border-bottom-right-radius: 3px;
  align-self: flex-end;
}
.cmp-msg .cmp-msg-sender {
  font-size: 10px;
  opacity: .6;
  margin-bottom: 2px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Typing indicator */
.cmp-typing {
  display: flex; gap: 4px; align-items: center;
  padding: 10px 14px;
  background: #f1f5f9;
  border-radius: 12px;
  border-bottom-left-radius: 3px;
  align-self: flex-start;
  width: fit-content;
}
.cmp-typing span {
  width: 7px; height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: cmpBounce 1.2s infinite;
}
.cmp-typing span:nth-child(2) { animation-delay: .2s; }
.cmp-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cmpBounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-6px); }
}

/* Input area */
.cmp-chat-input-area {
  border-top: 1px solid #f1f5f9;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.cmp-chat-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 90px;
  transition: border-color .15s;
  line-height: 1.4;
}
.cmp-chat-input:focus { border-color: #6366f1; }
.cmp-chat-send {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .1s;
}
.cmp-chat-send:hover { opacity: .88; transform: scale(1.05); }
.cmp-chat-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.cmp-chat-send svg { width: 18px; height: 18px; fill: #fff; }

/* Footer department bar */
.cmp-chat-dept-bar {
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
  padding: 6px 12px;
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.cmp-chat-dept-bar strong { color: #6366f1; }

/* Status messages */
.cmp-chat-status {
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
  padding: 4px 0;
}
.cmp-chat-status.warm { color: #6366f1; font-weight: 600; }

/* Offline screen */
.cmp-offline-notice {
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: #92400e;
  margin: 8px 12px;
  text-align: center;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .cmp-chat-window { right: 12px; bottom: 80px; width: calc(100vw - 24px); }
  .cmp-chat-bubble { right: 16px; bottom: 16px; }
}
