/* ── Floating Chat Widget ─────────────────────────────────── */
/* FAB already styled in dashboard.css */

#chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 400px;
  max-height: 70vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  z-index: 9997;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(.95);
  opacity: 0;
  pointer-events: none;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .2s;
}
#chat-panel.visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}
#chat-panel-header {
  background: linear-gradient(135deg, #1a4fd0, #2a6be8);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#chat-panel-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
#chat-panel-header p { margin: 3px 0 0; font-size: 11px; opacity: .8; }
#chat-panel-close {
  background: rgba(255,255,255,.18);
  border: none;
  border-radius: 50%;
  width: 30px; height: 30px;
  cursor: pointer;
  color: #fff;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
#chat-panel-close:hover { background: rgba(255,255,255,.28); }

#chat-agent-selector {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  overflow-y: auto;
  max-height: 72px;
  flex-shrink: 0;
  background: #fafafa;
}
.agent-chip {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid #ddd;
  background: #fff;
  font-size: 11.5px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.agent-chip:hover { border-color: #1a4fd0; color: #1a4fd0; }
.agent-chip.active { background: #1a4fd0; color: #fff; border-color: #1a4fd0; }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.msg {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 13px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}
.msg.user { align-self: flex-end; background: #1a4fd0; color: #fff; border-bottom-right-radius: 4px; }
.msg.agent { align-self: flex-start; background: #f1f3f8; color: #1a1a2e; border-bottom-left-radius: 4px; }
.msg-system { align-self: center; background: #f0f0f0; color: #888; font-size: 12px; font-style: italic; }
.msg-time { font-size: 10px; opacity: .6; margin-top: 3px; display: block; }

.typing-indicator {
  display: flex; gap: 4px; padding: 10px 13px;
  background: #f1f3f8; border-radius: 13px;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.typing-indicator span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #888; animation: bounce-dot 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce-dot { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }

#chat-input-area {
  padding: 10px 12px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
  background: #fafafa;
}
#chat-input-area p { font-size: 10.5px; color: #999; margin: 0 0 5px; }
#chat-input-row { display: flex; gap: 7px; align-items: flex-end; }
#chat-input {
  flex: 1;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13.5px;
  resize: none;
  max-height: 76px;
  outline: none;
  transition: border-color .2s;
  font-family: inherit;
  background: #fff;
}
#chat-input:focus { border-color: #1a4fd0; }
#chat-send-btn {
  background: #1a4fd0; color: #fff; border: none;
  border-radius: 10px; padding: 8px 15px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
  white-space: nowrap;
}
#chat-send-btn:hover { background: #1638b0; }
#chat-send-btn:active { transform: scale(.97); }
#chat-send-btn:disabled { background: #ccc; cursor: not-allowed; }

#chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; color: #aaa; padding: 24px;
  text-align: center;
}
#chat-empty p { font-size: 13px; line-height: 1.5; }
