/* ==========================================================================
   PinyiGear Chat Widget — industrial skin (brand blue #1c4fa0)
   Overrides the blue/orange legacy theme to match the site skin:
   graphite + brand red, hard 2–4px edges, mono uppercase labels.
   Deployed as /css/py-chat-widget.css (static, served by Hugo).
   Inline styles inside py-chat-widget.js are beaten with !important, so the
   widget JS itself stays untouched (no functional risk).
   ========================================================================== */

:root {
  --py-ink: #0f1216;
  --py-ink-soft: #1a2027;
  --py-brand: #1c4fa0;
  --py-brand-dark: #14417f;
  --py-line: #dce0e5;
  --py-line-2: #b4bcc5;
  --py-bg: #f5f6f8;
  --py-muted: #9aa2ab;
  --py-mono: ui-monospace, SFMono-Regular, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

#py-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--py-ink);
}

/* ---- Launcher ------------------------------------------------------------ */
#py-chat-bubble {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  background: var(--py-brand);
  color: #fff;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgb(15 18 22 / 30%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

#py-chat-bubble:hover { transform: translateY(-2px); background: var(--py-brand-dark); }

#py-chat-close-bubble {
  display: none;
  width: 56px;
  height: 56px;
  border-radius: 4px;
  background: var(--py-ink);
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgb(15 18 22 / 30%);
  align-items: center;
  justify-content: center;
}

/* ---- Panel --------------------------------------------------------------- */
#py-chat-panel {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border: 1px solid var(--py-line-2);
  border-radius: 4px;
  box-shadow: 0 18px 48px rgb(15 18 22 / 28%);
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
}

#py-chat-panel.gy-open { display: flex; }

@media (max-width: 480px) {
  #py-chat-panel { width: calc(100vw - 32px); height: calc(100vh - 110px); bottom: 80px; right: 16px; }
}

/* ---- Header -------------------------------------------------------------- */
#py-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--py-ink);
  border-top: 3px solid var(--py-brand);
  color: #fff;
  flex-shrink: 0;
}

#py-chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 3px;
  background: rgb(255 255 255 / 8%);
  border: 1px solid rgb(255 255 255 / 16%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

#py-chat-header h3 {
  margin: 0;
  font-family: var(--py-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#py-chat-header p {
  margin: 3px 0 0;
  font-family: var(--py-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--py-muted);
}

#py-agent-btn {
  flex-shrink: 0;
  background: var(--py-brand) !important;
  border-radius: 2px !important;
  color: #fff !important;
  border: none !important;
  font-family: var(--py-mono);
  font-size: 10.5px !important;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 7px 10px !important;
}

#py-agent-btn:hover { background: var(--py-brand-dark) !important; }

/* ---- Messages ------------------------------------------------------------ */
#py-chat-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #fff; }

.gy-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 3px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
}

.gy-msg-bot {
  background: #eef0f3;
  border: 1px solid var(--py-line);
  color: var(--py-ink-soft);
  align-self: flex-start;
}

.gy-msg-user {
  background: var(--py-ink);
  color: #fff;
  align-self: flex-end;
}

.gy-typing {
  display: flex;
  gap: 4px;
  padding: 11px 13px;
  background: #eef0f3;
  border: 1px solid var(--py-line);
  border-radius: 3px;
  align-self: flex-start;
}

.gy-typing span { width: 7px; height: 7px; border-radius: 1px; background: var(--py-brand); animation: gy-bounce 1.4s infinite; }
.gy-typing span:nth-child(2) { animation-delay: 0.2s; }
.gy-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes gy-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

#py-chat-limit {
  display: none;
  text-align: center;
  padding: 7px 12px;
  background: #fff4e5;
  border-top: 1px solid #f0d9b0;
  color: #7a4a00;
  font-family: var(--py-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ---- Composer ------------------------------------------------------------ */
#py-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--py-line);
  background: #fff;
  flex-shrink: 0;
}

#py-chat-input {
  flex: 1;
  border: 1px solid var(--py-line);
  border-radius: 2px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
}

#py-chat-input:focus { border-color: var(--py-ink); box-shadow: 0 0 0 2px rgb(212 0 0 / 16%); }

#py-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 2px;
  background: var(--py-brand);
  color: #fff;
  border: none;
  font-size: 17px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

#py-chat-send:hover { background: var(--py-brand-dark); }
#py-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Engineer / callback form ------------------------------------------- */
#py-agent-form { background: var(--py-bg) !important; padding: 14px !important; }

#py-agent-form input,
#py-agent-form textarea {
  border: 1px solid var(--py-line) !important;
  border-radius: 2px !important;
  font-family: inherit;
  font-size: 13.5px !important;
  background: #fff;
}

#py-agent-form input:focus,
#py-agent-form textarea:focus { border-color: var(--py-ink) !important; outline: none; }

#py-agent-submit {
  background: var(--py-brand) !important;
  border-radius: 2px !important;
  color: #fff !important;
  border: none !important;
  font-family: var(--py-mono);
  font-size: 12.5px !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#py-agent-submit:hover { background: var(--py-brand-dark) !important; }

#py-agent-back {
  font-family: var(--py-mono);
  font-size: 11px !important;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--py-muted) !important;
}

#py-agent-back:hover { color: var(--py-ink) !important; }

#py-agent-status { font-family: var(--py-mono); font-size: 11.5px !important; letter-spacing: 0.03em; }

/* 联系卡（2026-10-22）：电话/邮箱/WhatsApp 可点，微信一键复制 */
.py-contact{padding:9px 14px;background:#f4f8f4;border-bottom:1px solid #e2ece2;font-size:12.5px;line-height:1.85;flex:0 0 auto}
.py-contact-t{font-weight:600;color:#1a7a3a;margin-bottom:2px}
.py-contact a{display:block;color:#1a5fb4;text-decoration:none;word-break:break-word}
.py-contact a:hover{text-decoration:underline}
.py-copy-note{color:#1a7a3a;font-size:12px}
