/* HSZ Chat Widget - Core styles */
#hsz-chat-root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  color: #1f2937;
  box-sizing: border-box;
}
#hsz-chat-root *, #hsz-chat-root *::before, #hsz-chat-root *::after { box-sizing: border-box; }

/* ===== Floating button ===== */
#hsz-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF6B35, #F7931E);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 107, 53, 0.4), 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}
#hsz-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(255, 107, 53, 0.5), 0 4px 12px rgba(0,0,0,0.15);
}
#hsz-chat-btn:active { transform: scale(0.95); }
#hsz-chat-btn .hsz-btn-icon { display: flex; align-items: center; justify-content: center; }
#hsz-chat-btn .hsz-pulse {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  background: #FF6B35;
  animation: hsz-pulse 2s infinite;
  z-index: -1;
  opacity: 0.6;
}
@keyframes hsz-pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}
#hsz-chat-btn .hsz-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: #d63638;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: hsz-badge-pop 0.3s ease;
}
@keyframes hsz-badge-pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ===== Panel ===== */
#hsz-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 100000;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 0 1px rgba(0,0,0,0.1);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
#hsz-chat-panel:not([hidden]) {
  display: flex;
  animation: hsz-panel-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 14px;
}
@keyframes hsz-panel-in {
  0% { opacity: 0; transform: translateY(20px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
[dir="rtl"] #hsz-chat-panel { right: auto; left: 24px; }

/* Header */
.hsz-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0D2B4E, #16427A);
  color: #fff;
  flex-shrink: 0;
}
.hsz-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #FF6B35, #F7931E);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.hsz-header-info { flex: 1; min-width: 0; }
.hsz-header-name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.hsz-header-status { font-size: 12px; opacity: 0.9; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.hsz-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
}
.hsz-status-dot.hsz-online { background: #10b981; box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3); animation: hsz-blink 2s infinite; }
.hsz-status-dot.hsz-offline { background: #94a3b8; }
@keyframes hsz-blink { 0%, 100% { box-shadow: 0 0 0 2px rgba(16,185,129,0.3);} 50% { box-shadow: 0 0 0 4px rgba(16,185,129,0.1);} }
.hsz-icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.hsz-icon-btn:hover { background: rgba(255,255,255,0.25); }
.hsz-icon-btn.hsz-sound-on { background: rgba(16, 185, 129, 0.4); }

/* Body */
.hsz-panel-body {
  flex: 1;
  overflow-y: auto;
  background: #f9fafb;
  position: relative;
  padding: 0;
}
.hsz-panel-body::-webkit-scrollbar { width: 6px; }
.hsz-panel-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.hsz-panel-body::-webkit-scrollbar-track { background: transparent; }

.hsz-chat-body { padding: 12px; }

/* Messages */
.hsz-msgs { display: flex; flex-direction: column; gap: 8px; }
.hsz-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: hsz-msg-in 0.25s ease;
}
@keyframes hsz-msg-in {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
.hsz-msg-admin { align-self: flex-start; }
.hsz-msg-visitor { align-self: flex-end; flex-direction: row-reverse; }
.hsz-msg-system { align-self: center; max-width: 90%; }
.hsz-msg-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #FF6B35, #F7931E);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.hsz-msg-content { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hsz-msg-visitor .hsz-msg-content { align-items: flex-end; }
[dir="rtl"] .hsz-msg-admin { flex-direction: row-reverse; }
[dir="rtl"] .hsz-msg-visitor { flex-direction: row; }

.hsz-msg-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  background: #fff;
  color: #1f2937;
  word-wrap: break-word;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  border: 1px solid #e5e7eb;
  max-width: 100%;
}
.hsz-msg-visitor .hsz-msg-bubble {
  background: linear-gradient(135deg, #0D2B4E, #16427A);
  color: #fff;
  border: none;
  border-bottom-right-radius: 4px;
}
.hsz-msg-admin .hsz-msg-bubble {
  border-bottom-left-radius: 4px;
}
.hsz-msg-system .hsz-msg-bubble {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  font-size: 13px;
  text-align: center;
  border-radius: 8px;
  padding: 6px 12px;
}
.hsz-msg-time {
  font-size: 10px;
  color: #9ca3af;
  padding: 0 4px;
}
.hsz-msg-translation {
  background: #f0f9ff;
  color: #075985;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  max-width: 100%;
}
.hsz-msg-img-link { display: block; }
.hsz-msg-img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
  cursor: pointer;
}
.hsz-msg-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #0D2B4E;
  text-decoration: none;
  font-size: 13px;
}
.hsz-msg-file:hover { background: #e5e7eb; }

/* Quickbar */
.hsz-quickbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  max-height: 90px;
  overflow-y: auto;
}
.hsz-chip {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #0D2B4E;
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  font-family: inherit;
}
.hsz-chip:hover {
  background: #0D2B4E;
  color: #fff;
  border-color: #0D2B4E;
}

/* Footer / Input */
.hsz-panel-footer {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 8px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
}
.hsz-panel-footer .hsz-icon-btn {
  background: #f3f4f6;
  color: #6b7280;
  width: 36px; height: 36px;
}
.hsz-panel-footer .hsz-icon-btn:hover { background: #e5e7eb; color: #0D2B4E; }
#hsz-msg-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 36px;
  line-height: 1.4;
  background: #f9fafb;
  color: #1f2937;
}
#hsz-msg-input:focus { border-color: #0D2B4E; background: #fff; }
.hsz-send-btn {
  background: linear-gradient(135deg, #FF6B35, #F7931E);
  color: #fff;
  border: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.hsz-send-btn:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(255,107,53,0.4); }
.hsz-send-btn:active { transform: scale(0.95); }

.hsz-footer-skip { padding: 8px 12px; text-align: center; width: 100%; }
.hsz-link {
  background: none;
  border: none;
  color: #6b7280;
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.hsz-link:hover { color: #0D2B4E; }

/* Attach preview */
.hsz-attach-preview {
  position: absolute;
  bottom: 100%;
  left: 8px; right: 8px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  margin-bottom: 4px;
}
.hsz-attach-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.hsz-attach-item.hsz-err { color: #d63638; }
.hsz-attach-remove {
  background: none; border: none; color: #6b7280; cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px;
}
.hsz-attach-remove:hover { color: #d63638; }

/* Pre-chat */
.hsz-prechat {
  padding: 24px 20px;
  text-align: center;
}
.hsz-prechat-emoji { font-size: 40px; margin-bottom: 8px; }
.hsz-prechat-title { font-size: 18px; font-weight: 700; color: #0D2B4E; margin: 0 0 4px 0; }
.hsz-prechat-sub { color: #6b7280; font-size: 13px; margin: 0 0 20px 0; }
.hsz-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.hsz-form label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hsz-form input, .hsz-form select {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: #1f2937;
  outline: none;
  transition: border 0.15s;
}
.hsz-form input:focus, .hsz-form select:focus { border-color: #0D2B4E; }
.hsz-btn-primary {
  background: linear-gradient(135deg, #FF6B35, #F7931E);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}
.hsz-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255,107,53,0.3); }
.hsz-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

/* FAQ */
.hsz-faq { padding: 16px; }
.hsz-card-title { font-size: 16px; font-weight: 700; color: #0D2B4E; margin: 0 0 12px 0; }
.hsz-faq-item { margin-bottom: 8px; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; background: #fff; }
.hsz-faq-q {
  width: 100%;
  background: none;
  border: none;
  padding: 12px 14px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #0D2B4E;
  font-family: inherit;
  line-height: 1.4;
}
.hsz-faq-q:hover { background: #f9fafb; }
.hsz-faq-arrow { font-size: 18px; color: #FF6B35; font-weight: 700; flex-shrink: 0; margin-left: 8px; }
.hsz-faq-a { padding: 0 14px 14px 14px; font-size: 13px; color: #4b5563; line-height: 1.5; }

/* Payment & Contact info cards */
.hsz-info-card { padding: 16px; }
.hsz-info-sub { color: #6b7280; font-size: 13px; margin: 0 0 16px 0; }
.hsz-pay-list, .hsz-contact-list { display: flex; flex-direction: column; gap: 8px; }
.hsz-pay-item, .hsz-contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
  cursor: pointer;
}
.hsz-pay-item:hover, .hsz-contact-row:hover {
  border-color: #0D2B4E;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.hsz-pay-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.hsz-pay-name { font-weight: 600; color: #0D2B4E; font-size: 14px; }
.hsz-pay-detail { font-size: 12px; color: #6b7280; margin-top: 2px; }
.hsz-pay-detail[hidden] { display: none; }
.hsz-pay-detail.hsz-shown { display: block; }
.hsz-ct-icon { font-size: 22px; flex-shrink: 0; }
.hsz-ct-label { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; }
.hsz-ct-val { font-size: 14px; color: #0D2B4E; font-weight: 500; margin-top: 2px; word-break: break-all; }
.hsz-info-note {
  margin-top: 16px;
  padding: 10px 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  font-size: 12px;
  color: #9a3412;
}

/* Rating */
.hsz-rating { padding: 24px 20px; text-align: center; }
.hsz-stars { display: flex; justify-content: center; gap: 8px; margin: 16px 0; }
.hsz-star {
  background: none;
  border: none;
  font-size: 36px;
  cursor: pointer;
  filter: grayscale(1);
  opacity: 0.3;
  transition: all 0.15s;
  padding: 4px;
}
.hsz-star:hover, .hsz-star.hsz-star-on { filter: grayscale(0); opacity: 1; transform: scale(1.15); }
.hsz-rate-thanks { color: #10b981; font-weight: 600; margin-top: 12px; }

/* Mobile */
@media (max-width: 480px) {
  #hsz-chat-panel:not([hidden]) {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  [dir="rtl"] #hsz-chat-panel { right: 0; left: 0; }
  #hsz-chat-btn { right: 16px; bottom: 16px; }
  [dir="rtl"] #hsz-chat-btn { right: auto; left: 16px; }
}

/* ===== 注册/登录（访客必须注册才能实时对话）===== */
.hsz-auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; background: #f3f4f6; border-radius: 8px; padding: 4px; }
.hsz-auth-tab { flex: 1; border: 0; background: transparent; padding: 8px 0; border-radius: 6px; font-size: 13px; font-weight: 600; color: #6b7280; cursor: pointer; transition: all .15s; }
.hsz-auth-tab:hover { color: #0D2B4E; }
.hsz-auth-tab-on { background: #fff; color: #0D2B4E; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.hsz-auth-switch { text-align: center; color: #6b7280; font-size: 12px; margin: 14px 0 0 0; }
.hsz-auth-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 6px; padding: 8px 10px; font-size: 12px; margin-bottom: 4px; }
.hsz-country-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; background: transparent; color: #2563eb; font-size: 12.5px; padding: 4px 2px; margin: 2px 0 8px 0; cursor: pointer; text-align: start; }
.hsz-country-toggle:hover { text-decoration: underline; }
.hsz-country-toggle .hsz-caret { color: #9ca3af; }
.hsz-userbar { display: flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 11.5px; color: #6b7280; background: #f8fafc; border-bottom: 1px solid #eef2f6; }
.hsz-userbar b { color: #0D2B4E; }
.hsz-userbar .hsz-logout { margin-inline-start: auto; font-size: 11.5px; }
.hsz-userbar .hsz-link { font-size: 11.5px; }

/* ===== 个人中心（已登录注册访客）===== */
.hsz-account { padding: 4px 0 8px; }
.hsz-acc-head { padding: 4px 0 2px; }
.hsz-acc-title { font-size: 17px; font-weight: 700; color: #0D2B4E; margin: 2px 0 2px; }
.hsz-acc-email { font-size: 12.5px; color: #6b7280; margin-bottom: 12px; word-break: break-all; }
.hsz-acc-tabs { display: flex; gap: 4px; margin-bottom: 14px; background: #f3f4f6; border-radius: 8px; padding: 4px; }
.hsz-acc-tab { flex: 1; border: 0; background: transparent; padding: 8px 0; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: #6b7280; cursor: pointer; transition: all .15s; }
.hsz-acc-tab:hover { color: #0D2B4E; }
.hsz-acc-tab.active { background: #fff; color: #0D2B4E; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.hsz-acc-pane { display: block; }
.hsz-acc-msg { border-radius: 6px; padding: 8px 10px; font-size: 12px; margin: 10px 0 0; }
.hsz-acc-msg.hsz-ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.hsz-acc-msg.hsz-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.hsz-acc-pane select { width: 100%; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; background: #fff; color: #111827; }
.hsz-acc-pane select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
