
/* =========================================================
   B Plus Gaing - Floating Chat Widget (CSS)
   - Round draggable launcher (bottom-right default)
   - Chat panel with image upload preview
   - Designed to be standalone + safe to embed without
     touching existing app styles
   ========================================================= */

:root{
  --bpg-chat-bg: rgba(12,14,22,0.92);
  --bpg-chat-card: rgba(255,255,255,0.08);
  --bpg-chat-border: rgba(255,255,255,0.14);
  --bpg-chat-text: #eef2ff;
  --bpg-chat-muted: rgba(238,242,255,0.65);
  --bpg-chat-accent: #ffd400; /* match admin yellow vibe */
  --bpg-chat-danger: #ff4d6d;
  --bpg-chat-ok: #2ee59d;
  --bpg-chat-shadow: 0 22px 70px rgba(0,0,0,0.45);
  --bpg-chat-radius: 18px;
}

/* Host */
#bpgChatWidget{
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 999999;
  width: 0;
  height: 0;
  pointer-events: none; /* children handle */
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

/* Launcher button */
#bpgChatLauncher{
  pointer-events: auto;
  position: absolute;
  right: 0;
  bottom: 0;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16);
  background: radial-gradient(120px 120px at 30% 20%, rgba(255,212,0,0.35), transparent 55%),
              radial-gradient(140px 140px at 80% 30%, rgba(46,229,157,0.18), transparent 55%),
              rgba(255,255,255,0.06);
  box-shadow: 0 18px 44px rgba(0,0,0,0.35);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  cursor: grab;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#bpgChatLauncher:active{
  cursor: grabbing;
  transform: translateY(1px);
}

#bpgChatLauncher .bpgChatIcon{
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: var(--bpg-chat-text);
  font-weight: 900;
  font-size: 18px;
  line-height: 1;
}

#bpgChatLauncher .bpgChatBadge{
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255,212,0,0.9);
  color: #111;
  font-size: 11px;
  font-weight: 900;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 26px rgba(0,0,0,0.35);
}

/* Panel */
#bpgChatPanel{
  pointer-events: auto;
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(360px, 92vw);
  height: min(520px, 74vh);
  display: none;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(0,0,0,0.25), rgba(0,0,0,0.05)),
              var(--bpg-chat-bg);
  border: 1px solid var(--bpg-chat-border);
  border-radius: 22px;
  box-shadow: var(--bpg-chat-shadow);
  overflow: hidden;
}

#bpgChatPanel.bpgOpen{
  display: flex;
}

/* Header */
#bpgChatHeader{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

#bpgChatTitle{
  display:flex;
  flex-direction: column;
  gap: 2px;
}

#bpgChatTitle .t1{
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.2px;
  color: var(--bpg-chat-text);
}

#bpgChatTitle .t2{
  font-size: 11px;
  color: var(--bpg-chat-muted);
  font-weight: 700;
}

#bpgChatStatus{
  font-size: 11px;
  color: var(--bpg-chat-muted);
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.18);
}

#bpgChatStatus.ok{ color: var(--bpg-chat-ok); border-color: rgba(46,229,157,0.25); }
#bpgChatStatus.bad{ color: #ffb3c1; border-color: rgba(255,77,109,0.25); }

/* Messages */
#bpgChatBody{
  flex: 1;
  overflow: auto;
  padding: 12px;
  display:flex;
  flex-direction: column;
  gap: 10px;
}

.bpgMsgRow{
  display:flex;
  gap: 8px;
  align-items:flex-end;
}
.bpgMsgRow.me{ justify-content: flex-end; }
.bpgMsgRow.them{ justify-content: flex-start; }

.bpgBubble{
  max-width: 78%;
  padding: 9px 10px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--bpg-chat-text);
  font-size: 13px;
  line-height: 1.35;
  word-wrap: break-word;
  box-shadow: 0 12px 26px rgba(0,0,0,0.18);
}

.bpgMsgRow.me .bpgBubble{
  background: linear-gradient(135deg, rgba(255,212,0,0.22), rgba(46,229,157,0.10));
  border-color: rgba(255,255,255,0.14);
}

.bpgMeta{
  margin-top: 6px;
  font-size: 10px;
  color: var(--bpg-chat-muted);
  font-weight: 700;
}

.bpgImg{
  display:block;
  margin-top: 8px;
  border-radius: 12px;
  max-width: 100%;
  border: 1px solid rgba(255,255,255,0.12);
}

/* Composer */
#bpgChatComposer{
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.14);
  display:flex;
  flex-direction: column;
  gap: 8px;
}

#bpgChatComposerRow{
  display:flex;
  gap: 8px;
  align-items: center;
}

#bpgChatInput{
  flex: 1;
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--bpg-chat-text);
  padding: 0 12px;
  outline: none;
  font-size: 13px;
}

#bpgChatInput:focus{
  border-color: rgba(255,212,0,0.55);
  box-shadow: 0 0 0 3px rgba(255,212,0,0.14);
}

.bpgBtn{
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--bpg-chat-text);
  font-weight: 900;
  padding: 0 12px;
  cursor: pointer;
}

.bpgBtn.primary{
  background: linear-gradient(135deg, rgba(255,212,0,0.95), rgba(255,255,255,0.88));
  color: #111;
  border-color: rgba(255,212,0,0.35);
}

.bpgBtn:disabled{
  opacity: 0.6;
  cursor: not-allowed;
}

/* Image preview row */
#bpgChatPreview{
  display:none;
  align-items:center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 16px;
  border: 1px dashed rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.05);
}
#bpgChatPreview img{
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.12);
}
#bpgChatPreview .ptext{
  flex:1;
  min-width: 0;
  color: var(--bpg-chat-muted);
  font-size: 11px;
  font-weight: 800;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#bpgChatPreview .x{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display:grid;
  place-items:center;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.10);
  cursor:pointer;
  color: var(--bpg-chat-text);
  font-weight: 900;
}

/* Hide on print */
@media print{
  #bpgChatWidget{ display:none !important; }
}

/* ===== HOT FIX: FORCE CHAT ICON VISIBLE (AUTO) ===== */
#bpgChatWidget,
#bpgChatLauncher,
#bpgChatPanel{
  position: fixed !important;
  z-index: 2147483647 !important;
  pointer-events: auto !important;
}

#bpgChatLauncher{
  display: grid !important;
  visibility: visible !important;
  opacity: 1 !important;
  right: 18px !important;
  bottom: 18px !important;
  left: auto !important;
  top: auto !important;
}


/* ---- Demo/Login corner note (non-destructive) ---- */
#bpgChatHeaderRight{
  display:flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

#bpgChatCornerNote{
  display:none;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.2px;
  color: var(--bpg-chat-muted);
  opacity: 0.95;
  white-space: nowrap;
}

#bpgChatCornerNote.show{ display:block; }
#bpgChatCornerNote.warn{ color: #ffd166; }
#bpgChatCornerNote.demo{ color: #7bdff2; }
