/**
 * heimasim SweetAlert2 弹窗 - 支持 light / dark 主题
 */
:root,
[data-theme="light"] {
  --swal-bg: #ffffff;
  --swal-border: rgba(15, 23, 42, 0.08);
  --swal-border-strong: #e2e8f0;
  --swal-text: #0f172a;
  --swal-muted: #64748b;
  --swal-faint: #94a3b8;
  --swal-accent: var(--brand-primary, #3b82f6);
  --swal-danger: #ef4444;
  --swal-danger-soft: rgba(239, 68, 68, 0.1);
  --swal-ghost-bg: #ffffff;
  --swal-ghost-hover: #f8fafc;
  --swal-backdrop: rgba(15, 23, 42, 0.45);
  --swal-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
  --swal-radius: 8px;
  --swal-radius-lg: 16px;
}

[data-theme="dark"] {
  --swal-bg: var(--card-bg);
  --swal-border: var(--card-border);
  --swal-border-strong: rgba(255, 255, 255, 0.12);
  --swal-text: var(--text-primary);
  --swal-muted: var(--text-secondary);
  --swal-faint: #6b7280;
  --swal-accent: var(--brand-primary);
  --swal-danger: #ff8a65;
  --swal-danger-soft: rgba(255, 138, 101, 0.14);
  --swal-ghost-bg: var(--control-bg);
  --swal-ghost-hover: var(--control-hover-bg);
  --swal-backdrop: rgba(0, 0, 0, 0.62);
  --swal-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.swal2-container.swal2-backdrop-show {
  background: var(--swal-backdrop) !important;
  backdrop-filter: blur(2px);
}

/* 标准弹窗（排除 toast、聊天页专用弹窗） */
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) {
  width: min(420px, 96vw);
  padding: 0;
  border-radius: var(--swal-radius-lg);
  border: 1px solid var(--swal-border);
  background: var(--swal-bg) !important;
  color: var(--swal-text) !important;
  box-shadow: var(--swal-shadow);
  overflow: hidden;
}

.swal2-popup.heimasim-stats-modal {
  width: min(920px, 96vw);
}

.swal2-popup.heimasim-stats-modal--result,
.swal2-popup.heimasim-swal-modal--alert {
  width: min(420px, 96vw);
}

.swal2-popup.swal-google-auth,
.swal2-popup.swal-wide,
.swal2-popup.heimasim-swal-modal--wide {
  width: min(550px, 96vw) !important;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-title {
  margin: 0;
  padding: 20px 24px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--swal-text);
  text-align: center;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-close {
  width: 32px;
  height: 32px;
  margin: 12px 12px 0 0;
  border: none !important;
  box-shadow: none !important;
  color: var(--swal-faint);
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-close:hover {
  color: var(--swal-text);
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-icon {
  margin: 20px auto 4px;
  transform: scale(0.92);
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-html-container {
  margin: 0;
  padding: 8px 24px 4px;
  max-height: min(60vh, 520px);
  overflow: auto;
  font-size: 14px;
  line-height: 1.6;
  color: var(--swal-muted);
  text-align: center;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-title + .swal2-html-container,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-title ~ .swal2-html-container {
  padding-top: 8px;
}

.swal2-popup.swal-google-auth .swal2-html-container,
.swal2-popup.heimasim-swal-modal--form .swal2-html-container {
  padding: 16px 24px;
  max-height: none;
  text-align: left;
  color: var(--swal-text);
}

.swal2-popup.heimasim-stats-modal .swal2-html-container {
  padding: 0;
  max-height: none;
  overflow: visible;
  text-align: left;
  color: var(--swal-text);
}

.swal2-popup.heimasim-stats-modal--result .swal2-html-container {
  padding: 0 0 4px;
  text-align: center;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-input,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-textarea {
  width: calc(100% - 48px) !important;
  margin: 8px 24px 0 !important;
  padding: 10px 12px;
  border: 1px solid var(--swal-border-strong) !important;
  border-radius: var(--swal-radius) !important;
  font-size: 14px;
  color: var(--swal-text);
  background: var(--swal-ghost-bg);
  box-shadow: none !important;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-input:focus,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-textarea:focus {
  border-color: rgba(59, 130, 246, 0.55) !important;
  outline: none;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-input.form-control {
  width: 100% !important;
  margin: 0 !important;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-validation-message {
  margin: 8px 24px 0;
  padding: 8px 12px;
  border-radius: var(--swal-radius);
  background: var(--swal-danger-soft);
  color: #dc2626;
  font-size: 13px;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-actions {
  margin: 0;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--swal-border);
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-actions:empty {
  display: none;
  padding: 0;
  border-top: none;
}

/* 按钮：heimasim-swal-btn / stats-btn / 默认 swal2-styled */
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .heimasim-swal-btn,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .stats-btn,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-styled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  min-height: 38px;
  margin: 0;
  padding: 8px 16px;
  border-radius: var(--swal-radius) !important;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: none !important;
  transition: filter 0.15s ease, background 0.15s ease;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .heimasim-swal-btn--primary,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .stats-btn--primary,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-confirm {
  border: 1px solid var(--brand-primary, #3b82f6) !important;
  background: var(--swal-accent) !important;
  color: #fff !important;
  box-shadow: 0 6px 14px rgba(59, 130, 246, 0.22);
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .heimasim-swal-btn--primary:hover,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .stats-btn--primary:hover,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-confirm:hover {
  filter: brightness(1.06);
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .heimasim-swal-btn--ghost,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-cancel {
  border: 1px solid var(--swal-border-strong) !important;
  background: var(--swal-ghost-bg) !important;
  color: var(--swal-text) !important;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .heimasim-swal-btn--ghost:hover,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-cancel:hover {
  background: var(--swal-ghost-hover) !important;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .heimasim-swal-btn--danger,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .stats-btn--danger,
.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-deny {
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  background: var(--swal-danger-soft) !important;
  color: #dc2626 !important;
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-timer-progress-bar-container {
  border-bottom-left-radius: var(--swal-radius-lg);
  border-bottom-right-radius: var(--swal-radius-lg);
}

.swal2-popup:not(.swal2-toast):not(.heimasim-chat-modal) .swal2-timer-progress-bar {
  background: var(--swal-accent);
}

/* 统计弹窗内容区（与 heimasim-statistics.css 共用 class） */
.swal2-popup.heimasim-stats-modal--result .swal2-title {
  padding: 20px 24px 8px !important;
  border-bottom: none;
}

.swal2-popup.heimasim-stats-modal--result .swal2-html-container {
  padding: 0;
}

.swal2-popup.heimasim-stats-modal--result .swal2-actions {
  justify-content: center;
  padding: 16px 24px 20px;
}

.swal2-popup.heimasim-stats-modal--result .swal2-confirm,
.swal2-popup.heimasim-stats-modal--result .heimasim-swal-btn--primary {
  width: 100%;
  max-width: 280px;
  min-width: 0;
}

.swal2-popup.heimasim-stats-modal .swal2-close,
.swal2-popup.heimasim-stats-modal--result .swal2-close,
.swal2-popup.heimasim-stats-modal--filter .swal2-close,
.heimasim-stats-modal__close {
  width: 32px;
  height: 32px;
  margin: 12px 12px 0 0;
  border: none !important;
  box-shadow: none !important;
  color: var(--swal-faint) !important;
}

.swal2-popup.heimasim-stats-modal .swal2-close:hover,
.swal2-popup.heimasim-stats-modal--result .swal2-close:hover,
.swal2-popup.heimasim-stats-modal--filter .swal2-close:hover {
  color: var(--swal-text) !important;
}

.swal2-popup.heimasim-stats-modal--filter .swal2-title {
  padding: 18px 24px 12px !important;
  border-bottom: 1px solid var(--swal-border);
  text-align: left;
}

.swal2-popup.heimasim-stats-modal--filter .swal2-html-container {
  padding: 0;
}

.stats-modal-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--swal-faint);
  text-align: center;
}

.stats-modal-header {
  padding: 20px 24px 0;
  border-bottom: 1px solid var(--swal-border);
  text-align: center;
}

.stats-modal-header .swal2-title {
  padding: 0 0 12px !important;
}

.stats-modal-body {
  padding: 16px 24px;
}
