/* =============================================
   Chat Demo — Premium Live Simulation Widget
   ============================================= */

/* --- In-page widget --- */
.chat-demo-inpage {
  background: #0f172a; border-radius: 20px; border: 1px solid #1e293b;
  overflow: hidden; max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.chat-demo-inpage .chat-demo-body { min-height: 280px; max-height: 360px; }

/* --- Header --- */
.chat-demo-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 1px solid #1e293b;
  position: relative;
}
.chat-demo-header::after {
  content: ''; position: absolute; bottom: 0; left: 20px; right: 20px;
  height: 1px; background: linear-gradient(90deg, transparent, #2563eb44, transparent);
}
.chat-demo-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 2px solid #2563eb33;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.chat-demo-header strong { font-size: 15px; display: block; color: #f1f5f9; }
.chat-demo-header .chat-subname { font-size: 11px; color: #64748b; }
.chat-demo-status { font-size: 11px; font-weight: 500; }
.chat-demo-status.online { color: #22c55e; }
.chat-demo-status .dot {
  display: inline-block; width: 7px; height: 7px;
  background: #22c55e; border-radius: 50%; margin-right: 4px;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Messages area --- */
.chat-demo-body {
  flex: 1; padding: 18px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  background: #0f172a;
}
.chat-demo-body::-webkit-scrollbar { width: 4px; }
.chat-demo-body::-webkit-scrollbar-track { background: transparent; }
.chat-demo-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* --- Chat bubbles --- */
.chat-msg {
  max-width: 88%; padding: 10px 14px;
  font-size: 13.5px; line-height: 1.55; position: relative;
  word-wrap: break-word;
  animation: msgIn .35s cubic-bezier(0.21, 1.02, 0.73, 1);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-msg.bot {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white; align-self: flex-start;
  border-radius: 6px 18px 18px 18px;
  box-shadow: 0 2px 8px rgba(37,99,235,0.2);
}
.chat-msg.user {
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
  color: #e2e8f0; align-self: flex-end;
  border-radius: 18px 6px 18px 18px;
  border: 1px solid #334155;
}
.chat-msg .chat-time {
  display: block; font-size: 9.5px; opacity: 0.5;
  margin-top: 5px; text-align: right;
  letter-spacing: 0.3px;
}

/* --- Typing indicator --- */
.typing-indicator {
  align-self: flex-start; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 2px;
}
.typing-indicator .avatar-mini {
  width: 28px; height: 28px; border-radius: 50%;
  background: #1e293b; border: 1px solid #334155;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.typing-dots {
  display: flex; gap: 3px; align-items: center;
  background: #1e293b; padding: 10px 16px;
  border-radius: 18px; border: 1px solid #334155;
}
.typing-dots span {
  width: 7px; height: 7px; background: #64748b;
  border-radius: 50%; display: inline-block;
  animation: typingBounce 1.4s infinite both;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); background: #64748b; }
  30% { transform: translateY(-6px); background: #94a3b8; }
}

/* --- Input area --- */
.chat-demo-input {
  display: flex; gap: 8px; padding: 12px 14px 14px;
  background: #0f172a; border-top: 1px solid #1e293b;
}
.chat-demo-input input {
  flex: 1; padding: 11px 16px; border-radius: 24px;
  border: 1px solid #1e293b; background: #1e293b;
  color: #e2e8f0; font-size: 13px; outline: none;
  transition: all .2s;
}
.chat-demo-input input:focus {
  border-color: #2563eb55; box-shadow: 0 0 0 3px #2563eb15;
  background: #263548;
}
.chat-demo-input input::placeholder { color: #475569; }
.chat-demo-input button {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; cursor: pointer; transition: all .2s;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
  flex-shrink: 0;
}
.chat-demo-input button:hover {
  transform: scale(1.05); box-shadow: 0 4px 12px rgba(37,99,235,0.4);
}
.chat-demo-input button:active { transform: scale(0.95); }

/* --- Homepage inline widget --- */
.chat-demo-widget-inline {
  flex: 1; background: #0f172a; border-radius: 20px;
  border: 1px solid #1e293b; overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.chat-demo-widget-inline .chat-demo-body {
  min-height: 320px; max-height: 400px;
}
.chat-demo-widget-inline .chat-demo-header {
  background: linear-gradient(135deg, #1a2744 0%, #0f172a 100%);
}
.chat-demo-widget-inline .chat-demo-avatar {
  border-color: #2563eb55;
  background: linear-gradient(135deg, #1a2744, #0f172a);
}

/* --- Agent selector on homepage --- */
.demo-selector {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 140px;
}
.agent-select-btn {
  background: #0f172a; border: 1px solid #1e293b;
  color: #64748b; padding: 11px 16px; border-radius: 12px;
  cursor: pointer; text-align: left; transition: all .25s;
  font-size: 12.5px; line-height: 1.4; font-weight: 500;
  position: relative; overflow: hidden;
}
.agent-select-btn::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: #2563eb; transform: scaleY(0); transition: transform .25s;
}
.agent-select-btn:hover {
  border-color: #334155; background: #131d31;
  color: #94a3b8; transform: translateX(3px);
}
.agent-select-btn.active {
  background: #1a2744; border-color: #2563eb55; color: #93c5fd;
  box-shadow: 0 0 0 1px #2563eb22;
}
.agent-select-btn.active::before { transform: scaleY(1); }
.agent-select-btn small {
  display: block; font-size: 10px; color: #475569; font-weight: 400;
  margin-top: 1px;
}
.agent-select-btn.active small { color: #60a5fa; }

/* --- Floating trigger (for agent detail pages) --- */
.chat-demo-trigger {
  position: fixed; bottom: 20px; right: 20px; z-index: 999;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: none; color: white; font-size: 24px; cursor: pointer;
  box-shadow: 0 4px 20px rgba(37,99,235,0.4);
  transition: all .3s;
}
.chat-demo-trigger:hover { transform: scale(1.1); }
.chat-demo-trigger .badge {
  position: absolute; top: -4px; right: -4px;
  background: #16a34a; color: white; font-size: 10px;
  padding: 2px 6px; border-radius: 10px; font-weight: 700;
}

/* Floating widget */
.chat-demo-widget {
  position: fixed; bottom: 84px; right: 20px; z-index: 999;
  width: 380px; max-height: 540px; background: #0f172a;
  border-radius: 20px; border: 1px solid #1e293b;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  display: none; flex-direction: column; overflow: hidden;
}
.chat-demo-widget.open { display: flex; }

/* --- Responsive --- */
@media (max-width: 640px) {
  .demo-wrapper { flex-direction: column; }
  .demo-selector { flex-direction: row; flex-wrap: wrap; min-width: 0; }
  .agent-select-btn {
    flex: 1; min-width: 80px; font-size: 11px; padding: 8px 10px;
    text-align: center;
  }
  .agent-select-btn::before { display: none; }
  .agent-select-btn small { display: none; }
}
@media (max-width: 480px) {
  .chat-demo-widget { width: calc(100% - 32px); right: 16px; bottom: 76px; }
  .chat-demo-inpage { max-width: 100%; }
}
