/* PGS Chatbot - Apple-Glass UI. Scoped under .pgs-cb. */
.pgs-cb, .pgs-cb * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
.pgs-cb {
  --pgs-accent: #C69B3C;
  --pgs-ink: #1f232b;
  --pgs-glass: rgba(255,255,255,0.62);
  --pgs-glass-strong: rgba(255,255,255,0.8);
  --pgs-border: rgba(255,255,255,0.55);
  --pgs-shadow: 0 24px 70px rgba(17,24,39,0.28);
  position: fixed; bottom: 18px; right: 18px;
  z-index: 2147483000;
  display: flex; flex-direction: column; align-items: flex-end; gap: 14px;
}

/* ---- Launcher (glass pill) ---- */
.pgs-cb-launcher {
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 22px 0 18px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,0.18);
  cursor: pointer; color: #fff;
  background: linear-gradient(135deg, rgba(40,44,54,0.92), rgba(24,27,33,0.88));
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 14px 38px rgba(17,24,39,0.32), inset 0 1px 0 rgba(255,255,255,0.12);
  font-size: 15px; font-weight: 600; line-height: 1;
  transition: transform .22s ease, box-shadow .22s ease;
}
.pgs-cb-launcher:hover { transform: translateY(-2px); box-shadow: 0 22px 60px rgba(17,24,39,0.4), inset 0 1px 0 rgba(255,255,255,0.18); }
.pgs-cb-launcher:active { transform: translateY(0); }
.pgs-cb-launcher:focus-visible { outline: 2px solid var(--pgs-accent); outline-offset: 3px; }
.pgs-cb-launcher.round { width: 60px; height: 60px; padding: 0; justify-content: center; border-radius: 20px; }
.pgs-cb-launcher-ic { display: inline-flex; align-items: center; justify-content: center; color: var(--pgs-accent); }
.pgs-cb-launcher-tx { white-space: nowrap; }
.pgs-cb.pgs-cb-open .pgs-cb-launcher { display: none; }

/* ---- Panel (frosted glass) ---- */
.pgs-cb-panel {
  width: 392px; max-width: calc(100vw - 28px);
  height: 620px; max-height: calc(100vh - 120px);
  border-radius: 26px; overflow: hidden;
  background: var(--pgs-glass);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--pgs-border);
  box-shadow: var(--pgs-shadow), inset 0 1px 0 rgba(255,255,255,0.5);
  display: flex; flex-direction: column;
  opacity: 0; transform: translateY(16px) scale(.98);
  transition: opacity .22s ease, transform .22s cubic-bezier(.16,1,.3,1);
}
.pgs-cb-panel.pgs-cb-panel-in { opacity: 1; transform: translateY(0) scale(1); }

/* ---- Header ---- */
.pgs-cb-header {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.66), rgba(255,255,255,0.32));
  border-bottom: 1px solid rgba(255,255,255,0.45);
}
.pgs-cb-header-glow {
  position: absolute; top: -60px; left: -10px; width: 180px; height: 160px;
  background: radial-gradient(closest-side, var(--pgs-accent), transparent);
  opacity: .28; filter: blur(20px); pointer-events: none;
}
.pgs-cb-hleft { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.pgs-cb-avatar {
  height: 42px; width: 42px; border-radius: 14px; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--pgs-accent), #e7c987 45%, #a9772b);
  color: #1f232b; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(198,155,60,0.45), inset 0 1px 0 rgba(255,255,255,0.5);
}
.pgs-cb-hinfo { min-width: 0; }
.pgs-cb-name { font-size: 15px; font-weight: 700; line-height: 1.25; color: var(--pgs-ink); letter-spacing: -0.2px; }
.pgs-cb-status { font-size: 11.5px; color: #5b6270; display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.pgs-cb-dot-online { height: 7px; width: 7px; border-radius: 50%; background: #34d399; display: inline-block; box-shadow: 0 0 0 3px rgba(52,211,153,0.22); }
.pgs-cb-hbtns { display: flex; align-items: center; gap: 6px; position: relative; z-index: 1; }
.pgs-cb-iconbtn {
  background: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.6);
  color: #3a4150; cursor: pointer; padding: 8px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, transform .15s ease;
}
.pgs-cb-iconbtn:hover { background: rgba(255,255,255,0.85); transform: translateY(-1px); }
.pgs-cb-iconbtn:focus-visible { outline: 2px solid var(--pgs-accent); outline-offset: 2px; }

/* ---- Message list ---- */
.pgs-cb-list {
  flex: 1; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02));
}
.pgs-cb-list::-webkit-scrollbar { width: 8px; }
.pgs-cb-list::-webkit-scrollbar-thumb { background: rgba(120,120,128,0.3); border-radius: 8px; }
.pgs-cb-msg {
  max-width: 86%; padding: 11px 15px; font-size: 14px; line-height: 1.55;
  word-wrap: break-word; white-space: pre-wrap;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.pgs-cb-bot {
  align-self: flex-start; color: var(--pgs-ink);
  background: var(--pgs-glass-strong); border: 1px solid rgba(255,255,255,0.7);
  border-radius: 18px; border-top-left-radius: 7px;
  box-shadow: 0 4px 14px rgba(17,24,39,0.08);
}
.pgs-cb-user {
  align-self: flex-end; color: #fff;
  background: linear-gradient(135deg, rgba(45,50,61,0.94), rgba(28,31,38,0.92));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px; border-top-right-radius: 7px;
  box-shadow: 0 6px 18px rgba(17,24,39,0.22);
}
.pgs-cb-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pgs-cb-msg a { color: #9a6a12; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.pgs-cb-msg a:hover { color: var(--pgs-accent); }
.pgs-cb-user a { color: #f3e2bb; }.pgs-cb-chip {
  font-size: 12.5px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.7); color: var(--pgs-ink);
  background: rgba(255,255,255,0.6); padding: 7px 13px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.pgs-cb-chip:hover { background: rgba(255,255,255,0.92); border-color: var(--pgs-accent); transform: translateY(-1px); }

/* ---- Pre-chat ---- */
.pgs-cb-prechat {
  background: var(--pgs-glass-strong); border: 1px solid rgba(255,255,255,0.7);
  border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 11px;
  box-shadow: 0 8px 24px rgba(17,24,39,0.1);
}
.pgs-cb-prechat-title { font-size: 16px; font-weight: 700; color: var(--pgs-ink); letter-spacing: -0.2px; }
.pgs-cb-prechat-sub { font-size: 13px; color: #5b6270; margin-top: -4px; }
.pgs-cb-prechat-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: #4b5563; }
.pgs-cb-prechat-input {
  border: 1px solid rgba(120,120,128,0.28); border-radius: 12px; padding: 10px 13px;
  font-size: 14px; outline: none; color: var(--pgs-ink); background: rgba(255,255,255,0.85);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.pgs-cb-prechat-input:focus { border-color: var(--pgs-accent); box-shadow: 0 0 0 3px rgba(198,155,60,0.25); }
.pgs-cb-prechat-err { color: #b91c1c; font-size: 12px; }
.pgs-cb-prechat-btn {
  margin-top: 4px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--pgs-accent), #a9772b); color: #1f232b;
  font-weight: 700; font-size: 14px; padding: 12px 14px; cursor: pointer;
  box-shadow: 0 8px 20px rgba(198,155,60,0.4);
  transition: transform .15s ease, box-shadow .15s ease;
}
.pgs-cb-prechat-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(198,155,60,0.5); }
.pgs-cb-prechat-skip { background: transparent; border: none; color: #6b7280; font-size: 13px; cursor: pointer; text-decoration: underline; padding: 2px; }
.pgs-cb-prechat-priv { font-size: 11px; color: #9aa0a8; margin-top: 2px; }

/* ---- Typing ---- */
.pgs-cb-typing { display: flex; gap: 4px; align-items: center; padding: 2px 0; }
.pgs-cb-typing span { height: 8px; width: 8px; border-radius: 50%; background: #9aa0a8; display: inline-block; animation: pgs-cb-blink 1.2s infinite both; }
.pgs-cb-typing span:nth-child(2) { animation-delay: .18s; }
.pgs-cb-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes pgs-cb-blink { 0%,80%,100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

/* ---- Composer ---- */
.pgs-cb-composer {
  display: flex; align-items: flex-end; gap: 9px; padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.45);
  background: linear-gradient(180deg, rgba(255,255,255,0.34), rgba(255,255,255,0.6));
}
.pgs-cb-input {
  flex: 1; resize: none; max-height: 110px;
  border: 1px solid rgba(120,120,128,0.28); border-radius: 14px; padding: 10px 14px;
  font-size: 14px; outline: none; color: var(--pgs-ink); background: rgba(255,255,255,0.85);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.pgs-cb-input:focus { border-color: var(--pgs-accent); box-shadow: 0 0 0 3px rgba(198,155,60,0.25); }
.pgs-cb-send {
  height: 42px; width: 42px; flex: 0 0 auto; border: none; border-radius: 14px;
  background: linear-gradient(135deg, var(--pgs-accent), #a9772b); color: #1f232b; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 18px rgba(198,155,60,0.4);
  transition: transform .15s ease, box-shadow .15s ease;
}
.pgs-cb-send:hover { transform: translateY(-1px); }
.pgs-cb-send:disabled, .pgs-cb-input:disabled { opacity: .5; }
.pgs-cb-foot {
  text-align: center; font-size: 10px; color: #8a8f98; padding: 7px 0 9px;
  background: rgba(255,255,255,0.5);
}

/* ---- Fallback: no backdrop-filter ---- */
@supports not ((-webkit-backdrop-filter: blur(2px)) or (backdrop-filter: blur(2px))) {
  .pgs-cb-panel { background: #ffffff; }
  .pgs-cb-header { background: #f5f1e8; }
  .pgs-cb-bot { background: #f7f3ea; }
  .pgs-cb-composer, .pgs-cb-foot { background: #ffffff; }
  .pgs-cb-launcher { background: #1f232b; }
}

/* ---- Dark mode ---- */
@media (prefers-color-scheme: dark) {
  .pgs-cb {
    --pgs-ink: #f2f3f5;
    --pgs-glass: rgba(28,28,32,0.6);
    --pgs-glass-strong: rgba(58,58,66,0.55);
    --pgs-border: rgba(255,255,255,0.12);
    --pgs-shadow: 0 24px 70px rgba(0,0,0,0.55);
  }
  .pgs-cb-header { background: linear-gradient(180deg, rgba(60,60,68,0.5), rgba(40,40,46,0.32)); border-bottom-color: rgba(255,255,255,0.08); }
  .pgs-cb-name { color: #f2f3f5; }
  .pgs-cb-status { color: #b6bcc8; }
  .pgs-cb-iconbtn { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.14); color: #e6e8ec; }
  .pgs-cb-iconbtn:hover { background: rgba(255,255,255,0.2); }
  .pgs-cb-bot { color: #f2f3f5; border-color: rgba(255,255,255,0.12); }
  .pgs-cb-msg a { color: #e7c987; }
  .pgs-cb-chip { color: #f2f3f5; background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.16); }
  .pgs-cb-chip:hover { background: rgba(255,255,255,0.2); }
  .pgs-cb-prechat { background: rgba(58,58,66,0.6); border-color: rgba(255,255,255,0.12); }
  .pgs-cb-prechat-title { color: #f2f3f5; }
  .pgs-cb-prechat-sub { color: #b6bcc8; }
  .pgs-cb-prechat-input, .pgs-cb-input { background: rgba(20,20,24,0.7); color: #f2f3f5; border-color: rgba(255,255,255,0.16); }
  .pgs-cb-composer { background: linear-gradient(180deg, rgba(40,40,46,0.4), rgba(30,30,34,0.6)); border-top-color: rgba(255,255,255,0.1); }
  .pgs-cb-foot { background: rgba(30,30,34,0.5); color: #8a8f98; }
}

/* ---- Mobile ---- */
@media (max-width: 560px) {
  .pgs-cb { bottom: 12px; right: 12px; left: 12px; }
  .pgs-cb-panel { width: 100%; height: 82vh; height: 82dvh; max-height: calc(100vh - 24px); border-radius: 22px; }
  .pgs-cb-launcher { height: 52px; font-size: 14px; }
  .pgs-cb-launcher.round { width: 56px; height: 56px; }
  .pgs-cb-msg { max-width: 90%; }
}
@media (prefers-reduced-motion: reduce) {
  .pgs-cb-typing span { animation: none; }
  .pgs-cb-launcher, .pgs-cb-panel, .pgs-cb-iconbtn, .pgs-cb-send, .pgs-cb-chip { transition: none; }
}
