/* ==========================================================================
   BIZHUB ADMIN DESK
   Presence pill, live support room, admin toast and launcher.
   Scoped under .ad-* so it never collides with marketplace styles.
   ========================================================================== */

:root {
  --ad-navy: #131921;
  --ad-navy-2: #232f3e;
  --ad-orange: #ff9900;
  --ad-yellow: #febd69;
  --ad-green: #22c55e;
  --ad-ink: #0f172a;
  --ad-muted: #64748b;
  --ad-line: #e2e8f0;
}

/* ---------- Header identity (admin browsing the marketplace) ---------- */
.bh-account-admin {
  border: 1px solid rgba(254, 189, 105, 0.55) !important;
  background: rgba(254, 189, 105, 0.12) !important;
  border-radius: 8px;
  padding: 4px 10px !important;
}
.bh-account-admin .bh-account-name {
  color: #febd69 !important;
  font-weight: 900;
  letter-spacing: 0.02em;
}
.bh-admin-crown {
  font-size: 13px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}
.bh-admin-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(254, 189, 105, 0.18);
  border: 1px solid rgba(254, 189, 105, 0.5);
  color: #febd69;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

/* ---------- Presence pill ---------- */
.ad-pill {
  position: fixed;
  left: 50%;
  top: 96px;
  transform: translateX(-50%) translateY(-8px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(34, 197, 94, 0.45);
  background: linear-gradient(180deg, #ffffff 0%, #f4fbf6 100%);
  color: var(--ad-ink);
  font: 700 12.5px/1.2 Arial, Helvetica, sans-serif;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  z-index: 100001;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.18), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  transition: opacity 0.28s ease, transform 0.28s ease, box-shadow 0.2s ease;
}
.ad-pill:hover {
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.24), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}
.ad-pill.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.ad-pill[hidden] { display: none; }
.ad-pill-dot {
  position: relative;
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--ad-green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}
.ad-pill-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(34, 197, 94, 0.55);
  animation: adPing 1.6s ease-out infinite;
}
@keyframes adPing {
  0% { transform: scale(0.6); opacity: 0.9; }
  70% { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}
.ad-pill-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e0245e;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  display: grid;
  place-items: center;
  line-height: 1;
}
.ad-pill-badge[hidden] { display: none; }

/* ---------- Overlay + modal ---------- */
.ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(9, 14, 22, 0.62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.ad-overlay[hidden] { display: none; }

.ad-modal {
  width: 100%;
  max-width: 580px;
  max-height: min(88dvh, 760px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 30px 80px rgba(2, 6, 23, 0.45);
  animation: adRise 0.24s ease-out;
}
@keyframes adRise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ad-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px 16px;
  background: linear-gradient(135deg, #131921 0%, #232f3e 62%, #2d3d50 100%);
  color: #fff;
}
.ad-head::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ad-orange), var(--ad-yellow), var(--ad-orange));
}
.ad-head-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.ad-head-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 18px;
}
.ad-head h2 {
  margin: 0;
  font: 900 16px/1.2 Arial, Helvetica, sans-serif;
  letter-spacing: 0.01em;
  color: #fff;
}
.ad-head-sub {
  margin: 3px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font: 700 11.5px/1.2 Arial, Helvetica, sans-serif;
  color: #cbd5e1;
}
.ad-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  flex: none;
}
.ad-dot.is-online {
  background: var(--ad-green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
}
.ad-close {
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease;
}
.ad-close:hover { background: rgba(255, 255, 255, 0.18); }

.ad-notice {
  padding: 8px 18px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  font: 600 11.5px/1.4 Arial, Helvetica, sans-serif;
}

/* ---------- Message stream ---------- */
.ad-stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px 18px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.ad-empty {
  margin: auto;
  text-align: center;
  color: var(--ad-muted);
  font: 600 13px/1.6 Arial, Helvetica, sans-serif;
  max-width: 300px;
}
.ad-empty strong {
  display: block;
  color: var(--ad-ink);
  font-size: 14px;
  margin-bottom: 4px;
}

.ad-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 86%;
  align-self: flex-start;
}
.ad-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.ad-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font: 800 11px/1.2 Arial, Helvetica, sans-serif;
  color: var(--ad-muted);
}
.ad-msg-name { color: #334155; }
.ad-msg-time { font-weight: 600; color: #94a3b8; }
.ad-role {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.ad-role-vendor { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.ad-role-customer { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.ad-role-delivery { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.ad-role-guest { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.ad-role-admin { background: #131921; color: #febd69; border-color: #131921; }
.ad-lock {
  padding: 1px 6px;
  border-radius: 999px;
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ad-reply-ref {
  font: 700 10.5px/1.3 Arial, Helvetica, sans-serif;
  color: #7c3aed;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  padding: 3px 8px;
}
.ad-bubble {
  padding: 10px 13px;
  border-radius: 14px 14px 14px 4px;
  background: #fff;
  border: 1px solid var(--ad-line);
  color: var(--ad-ink);
  font: 400 14px/1.45 Arial, Helvetica, sans-serif;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.ad-msg.is-mine .ad-bubble {
  background: #fff7ed;
  border-color: #fed7aa;
  border-radius: 14px 14px 4px 14px;
}
.ad-msg.is-admin .ad-bubble {
  background: #eef6ff;
  border-color: #bfdbfe;
}
.ad-msg.is-private .ad-bubble {
  background: #f5f3ff;
  border-color: #ddd6fe;
}
.ad-bubble.is-deleted {
  background: #f8fafc;
  border-style: dashed;
  color: #94a3b8;
  font-style: italic;
  font-size: 12.5px;
}
.ad-text { white-space: pre-wrap; }
.ad-media { margin-top: 8px; }
.ad-media img {
  display: block;
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  cursor: zoom-in;
  border: 1px solid rgba(15, 23, 42, 0.08);
}
.ad-media video {
  display: block;
  width: 100%;
  max-height: 240px;
  border-radius: 10px;
  background: #000;
}
.ad-media audio { display: block; width: 240px; max-width: 100%; }
.ad-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 11px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--ad-line);
  color: #1d4ed8;
  font: 700 12.5px/1.3 Arial, Helvetica, sans-serif;
  text-decoration: none;
  word-break: break-all;
}
.ad-file:hover { background: #eff6ff; }

.ad-msg-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.ad-msg:hover .ad-msg-actions,
.ad-msg:focus-within .ad-msg-actions { opacity: 1; }
.ad-mini {
  border: 1px solid var(--ad-line);
  background: #fff;
  color: #475569;
  border-radius: 7px;
  padding: 2px 8px;
  font: 800 10px/1.6 Arial, Helvetica, sans-serif;
  cursor: pointer;
}
.ad-mini:hover { background: #f1f5f9; }
.ad-mini-danger { color: #b91c1c; border-color: #fecaca; }
.ad-mini-danger:hover { background: #fef2f2; }

/* ---------- Typing ---------- */
.ad-typing {
  padding: 0 18px 6px;
  background: #fff;
  color: var(--ad-muted);
  font: 700 11.5px/1.4 Arial, Helvetica, sans-serif;
  min-height: 18px;
}
.ad-typing[hidden] { display: none; }
.ad-typing-dots::after {
  content: "";
  animation: adDots 1.2s steps(4, end) infinite;
}
@keyframes adDots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

/* ---------- Admin control bar ---------- */
.ad-admin-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: #f8fafc;
  border-top: 1px solid var(--ad-line);
}
.ad-admin-bar[hidden] { display: none; }
.ad-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 800 11.5px/1.2 Arial, Helvetica, sans-serif;
  color: #334155;
  cursor: pointer;
  user-select: none;
}
.ad-switch input {
  width: 15px;
  height: 15px;
  accent-color: #7c3aed;
  cursor: pointer;
}
.ad-reply-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  color: #6d28d9;
  font: 800 10.5px/1.4 Arial, Helvetica, sans-serif;
}
.ad-reply-chip[hidden] { display: none; }
.ad-reply-chip button {
  border: 0;
  background: transparent;
  color: #7c3aed;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

/* ---------- Attachments + voice preview ---------- */
.ad-attach-preview,
.ad-voice-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  font: 700 12px/1.3 Arial, Helvetica, sans-serif;
  color: #92400e;
}
.ad-attach-preview[hidden],
.ad-voice-preview[hidden] { display: none; }
.ad-attach-preview .ad-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ad-voice-preview audio { height: 32px; max-width: 210px; }
.ad-chip-x {
  border: 1px solid #fcd34d;
  background: #fff;
  color: #92400e;
  border-radius: 7px;
  padding: 2px 8px;
  font: 800 11px/1.6 Arial, Helvetica, sans-serif;
  cursor: pointer;
}
.ad-recording {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: #fef2f2;
  border-top: 1px solid #fecaca;
  font: 800 12px/1.3 Arial, Helvetica, sans-serif;
  color: #b91c1c;
}
.ad-recording[hidden] { display: none; }
.ad-rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  animation: adRec 1s ease-in-out infinite;
}
@keyframes adRec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
.ad-rec-time { font-variant-numeric: tabular-nums; }

/* ---------- Composer ---------- */
.ad-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 14px 13px;
  background: #fff;
  border-top: 1px solid var(--ad-line);
}
.ad-composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
  font: 400 14px/1.45 Arial, Helvetica, sans-serif;
  color: var(--ad-ink);
  background: #fff;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.ad-composer textarea:focus {
  border-color: var(--ad-orange);
  box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.16);
}
.ad-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ad-tool {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--ad-line);
  border-radius: 10px;
  background: #f8fafc;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.ad-tool:hover { background: #f1f5f9; border-color: #cbd5e1; }
.ad-tool.is-active {
  background: #fef2f2;
  border-color: #fecaca;
}
.ad-send {
  margin-left: auto;
  min-width: 92px;
  height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffb020 0%, #ff9900 100%);
  color: #131921;
  font: 900 13px/1 Arial, Helvetica, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 153, 0, 0.28);
  transition: filter 0.16s ease, transform 0.12s ease;
}
.ad-send:hover { filter: brightness(1.04); }
.ad-send:active { transform: translateY(1px); }
.ad-send:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

/* ---------- Admin toast ---------- */
.ad-toast {
  position: fixed;
  right: 16px;
  top: 96px;
  z-index: 2147483001;
  width: min(340px, calc(100vw - 32px));
  display: flex;
  gap: 11px;
  padding: 12px 13px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid var(--ad-orange);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.24);
  cursor: pointer;
  animation: adToastIn 0.26s ease-out;
}
.ad-toast[hidden] { display: none; }
@keyframes adToastIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
.ad-toast-icon {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  font-size: 16px;
}
.ad-toast-body { min-width: 0; flex: 1; }
.ad-toast-title {
  font: 900 12.5px/1.3 Arial, Helvetica, sans-serif;
  color: var(--ad-ink);
  margin: 0 0 2px;
}
.ad-toast-text {
  font: 600 11.5px/1.4 Arial, Helvetica, sans-serif;
  color: var(--ad-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-toast-close {
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  align-self: flex-start;
}

/* ---------- Admin launcher ---------- */
.ad-launcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 99998;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 15px;
  border: 1px solid rgba(254, 189, 105, 0.5);
  border-radius: 999px;
  background: linear-gradient(135deg, #131921 0%, #232f3e 100%);
  color: #fff;
  font: 900 12.5px/1 Arial, Helvetica, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(2, 6, 23, 0.38);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.ad-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.46);
}
.ad-launcher-badge {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e0245e;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  display: grid;
  place-items: center;
}
.ad-launcher-badge[hidden] { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .ad-overlay {
    padding: 10px;
    align-items: flex-end;
  }
  .ad-modal {
    max-height: 92dvh;
    border-radius: 18px 18px 14px 14px;
  }
  .ad-head { padding: 13px 14px 14px; }
  .ad-head h2 { font-size: 15px; }
  .ad-stream { padding: 13px 12px 15px; }
  .ad-msg { max-width: 92%; }
  .ad-composer { padding: 10px 11px 12px; }
  .ad-send { min-width: 76px; padding: 0 14px; }
  .ad-pill {
    font-size: 12px;
    padding: 6px 12px;
    max-width: calc(100vw - 24px);
  }
  .ad-toast {
    right: 10px;
    left: 10px;
    width: auto;
  }
  .ad-launcher {
    right: 12px;
    bottom: 12px;
    padding: 10px 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ad-pill-dot::after,
  .ad-rec-dot,
  .ad-typing-dots::after { animation: none; }
  .ad-modal,
  .ad-toast { animation: none; }
  .ad-pill { transition: opacity 0.15s linear; }
}
