/* ═══════════════════════════════════════════
   SPEP Live Chat — chat.css
   ═══════════════════════════════════════════ */

/* ── Bubble ── */
#chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  background: #0f766e;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9000;
  box-shadow: 0 4px 18px rgba(15,118,110,.45);
  transition: transform .2s, box-shadow .2s;
  user-select: none;
}
#chat-bubble:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(15,118,110,.55); }
#chat-bubble-icon { font-size: 22px; line-height: 1; }
#chat-badge {
  display: none;
  position: absolute;
  top: -3px;
  right: -3px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  z-index: 1;
}
#chat-badge.visible { display: flex; }

/* ── Panel ── */
#chat-panel {
  display: none;
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 320px;
  height: 480px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.16);
  z-index: 8999;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
#chat-panel.open { display: flex; }

/* ── Header ── */
#chat-header {
  background: #0f766e;
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#chat-header-title { font-size: 14px; font-weight: 700; }
#chat-online { font-size: 11px; opacity: .8; }
#chat-close {
  cursor: pointer;
  font-size: 18px;
  opacity: .75;
  line-height: 1;
  padding: 2px 4px;
}
#chat-close:hover { opacity: 1; }

/* ── Filters ── */
#chat-filters {
  display: flex;
  padding: 8px 10px;
  gap: 0;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
  flex-shrink: 0;
}
.chat-filter-btn {
  flex: 1;
  padding: 5px 0;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  transition: all .15s;
}
.chat-filter-btn:first-child { border-radius: 6px 0 0 6px; }
.chat-filter-btn:last-child  { border-radius: 0 6px 6px 0; }
.chat-filter-btn + .chat-filter-btn { border-left: none; }
.chat-filter-btn.active { background: #0f766e; color: #fff; border-color: #0f766e; }

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

#chat-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  margin: auto;
  padding: 24px 16px;
  line-height: 1.6;
}

.chat-msg { display: flex; flex-direction: column; gap: 3px; }
.chat-msg.highlighted {
  background: #f0fdf4;
  border-radius: 8px;
  padding: 6px 8px;
  margin: -2px -4px;
  border-left: 3px solid #0f766e;
}

.chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.chat-msg-name { font-size: 12px; font-weight: 700; color: #0f172a; }
.chat-msg-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.chat-msg-tag.crsp  { background: #d1fae5; color: #065f46; }
.chat-msg-tag.cih   { background: #ede9fe; color: #5b21b6; }
.chat-msg-time { font-size: 10px; color: #94a3b8; margin-left: auto; }
.chat-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: #cbd5e1;
  padding: 0 2px;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s, color .15s;
  flex-shrink: 0;
}
.chat-msg:hover .chat-del-btn { opacity: 1; }
.chat-del-btn:hover { color: #dc2626; }
/* Admin: X always visible on every message */
#chat-panel.is-admin .chat-del-btn { opacity: .45; }
#chat-panel.is-admin .chat-del-btn:hover { opacity: 1; color: #dc2626; }

.chat-msg-text {
  font-size: 13px;
  color: #334155;
  line-height: 1.55;
  word-break: break-word;
}
.chat-mention { color: #0f766e; font-weight: 700; }

/* ── Private (DM) messages ── */
.chat-msg.private-msg {
  background: #f0fdf9;
  border-left: 3px solid #0f766e;
  border-radius: 8px;
  padding: 6px 8px;
  margin: -2px -4px;
}
.chat-private-badge {
  font-size: 9px;
  font-weight: 700;
  color: #0f766e;
  background: #d1fae5;
  border-radius: 20px;
  padding: 1px 6px;
  letter-spacing: .3px;
  flex-shrink: 0;
}

/* ── Guest bar ── */
#chat-guest-bar {
  padding: 10px 14px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  text-align: center;
  font-size: 12.5px;
  color: #64748b;
  flex-shrink: 0;
}
#chat-guest-bar a {
  color: #0f766e;
  font-weight: 700;
  text-decoration: none;
}
#chat-guest-bar a:hover { text-decoration: underline; }

/* ── Input area ── */
#chat-input-area {
  display: none;
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
  position: relative;
}
#chat-input-area.visible { display: flex; }

#chat-input-row {
  display: flex;
  gap: 7px;
  align-items: flex-end;
}

#chat-tag-select {
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 5px 6px;
  color: #334155;
  background: #f8fafc;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
}

#chat-input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: #0f172a;
  outline: none;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
  max-height: 80px;
  overflow-y: auto;
  transition: border-color .15s;
}
#chat-input:focus { border-color: #0f766e; }
#chat-input::placeholder { color: #94a3b8; }

#chat-send {
  background: #0f766e;
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
  line-height: 1;
}
#chat-send:hover { background: #0d6460; }

/* ── @mention dropdown ── */
#mention-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 12px;
  right: 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  z-index: 100;
  max-height: 160px;
  overflow-y: auto;
}
#mention-dropdown.open { display: block; }

.mention-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #334155;
  transition: background .1s;
}
.mention-item:hover { background: #f0fdf4; }
.mention-item:first-child { border-radius: 10px 10px 0 0; }
.mention-item:last-child  { border-radius: 0 0 10px 10px; }

.mention-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #0f766e;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mention-name { font-weight: 600; color: #0f172a; }

/* ── @mention toast banner ── */
#chat-mention-toast {
  display: none;
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 280px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #0f766e;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
  z-index: 9100;
  padding: 12px 14px;
  cursor: pointer;
  animation: toastSlideIn .3s ease;
}
#chat-mention-toast.visible { display: block; }
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-from {
  font-size: 11px;
  font-weight: 700;
  color: #0f766e;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.toast-from-dot {
  width: 7px; height: 7px;
  background: #0f766e;
  border-radius: 50%;
  display: inline-block;
}
.toast-text {
  font-size: 13px;
  color: #334155;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast-close {
  position: absolute;
  top: 8px; right: 10px;
  font-size: 12px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}
.toast-close:hover { color: #475569; }

/* ══════════════════════════════════════════
   EMBEDDED MODE (viewer.html dashboard)
   ══════════════════════════════════════════ */
#chat-embed-target {
  margin-bottom: 20px;
}
#chat-embed-target #chat-panel {
  /* override fixed positioning */
  position: static !important;
  width: 100% !important;
  height: 420px !important;
  bottom: auto !important;
  right: auto !important;
  border-radius: 14px !important;
  box-shadow: none !important;
  /* dark dashboard palette */
  background: #1e293b !important;
  border: 1px solid #334155 !important;
}
/* Header */
#chat-embed-target #chat-header {
  background: #0f172a !important;
  border-bottom: 1px solid #334155;
  border-radius: 14px 14px 0 0;
}
/* Filter tabs */
#chat-embed-target #chat-filters {
  background: #0f172a !important;
  border-bottom: 1px solid #334155 !important;
}
#chat-embed-target .chat-filter-btn {
  background: #1e293b !important;
  color: #94a3b8 !important;
  border-color: #334155 !important;
}
#chat-embed-target .chat-filter-btn.active {
  background: #0f766e !important;
  color: #fff !important;
  border-color: #0f766e !important;
}
/* Messages area */
#chat-embed-target #chat-messages {
  background: #1e293b !important;
}
#chat-embed-target #chat-messages::-webkit-scrollbar-thumb {
  background: #334155 !important;
}
#chat-embed-target .chat-msg-name  { color: #e2e8f0 !important; }
#chat-embed-target .chat-msg-time  { color: #475569 !important; }
#chat-embed-target .chat-msg-text  { color: #cbd5e1 !important; }
#chat-embed-target #chat-empty     { color: #475569 !important; }
/* Private badge */
#chat-embed-target .chat-msg.private-msg {
  background: #0f2d2b !important;
  border-left-color: #0f766e !important;
}
/* Input area */
#chat-embed-target #chat-input-area {
  background: #0f172a !important;
  border-top: 1px solid #334155 !important;
  border-radius: 0 0 14px 14px;
}
#chat-embed-target #chat-input {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
#chat-embed-target #chat-input:focus { border-color: #0f766e !important; }
#chat-embed-target #chat-input::placeholder { color: #475569 !important; }
#chat-embed-target #chat-tag-select {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #94a3b8 !important;
}
/* Guest bar */
#chat-embed-target #chat-guest-bar {
  background: #0f172a !important;
  border-top: 1px solid #334155 !important;
  color: #64748b !important;
}
/* @mention dropdown */
#chat-embed-target #mention-dropdown {
  background: #1e293b !important;
  border-color: #334155 !important;
}
#chat-embed-target .mention-item { color: #cbd5e1 !important; }
#chat-embed-target .mention-item:hover { background: #0f2d2b !important; }
#chat-embed-target .mention-name { color: #e2e8f0 !important; }

/* ── Mobile ── */
@media(max-width: 480px) {
  #chat-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 76px;
    height: 420px;
  }
  #chat-bubble { bottom: 16px; right: 12px; }
}
