/*
 * shared.css —— 公共基础样式：重置、按钮、弹窗、提示条、骨架屏
 * 所有页面共用；页面私有样式在各自的 order.css / admin.css / print-codes.css 中定义。
 */

/* ---------- 1. 基础重置 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/*
 * hidden 属性必须真正隐藏。
 * 教训（2026-10-19 BUG-10）：.a-login 等容器设了 display:flex，
 * 优先级高于浏览器默认的 [hidden]{display:none}，
 * 导致 loginRoot.hidden=true 后登录页仍占据页面——用户"登录成功但停在登录界面"。
 * 任何容器都不允许用 display 覆盖 hidden，故在此用 !important 全局兜底。
 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1C1917;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body.xhj-no-scroll {
  overflow: hidden;
}

h1, h2, h3, h4, p, ul, ol {
  margin: 0;
  padding: 0;
}

ul, ol {
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

input, select, textarea {
  font: inherit;
  color: inherit;
}

table {
  border-collapse: collapse;
  width: 100%;
}

:focus-visible {
  outline: 3px solid #FB923C;
  outline-offset: 2px;
}

.xhj-hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ---------- 2. 按钮 ---------- */
.xhj-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #FFFFFF;
  color: #1C1917;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.xhj-btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.xhj-btn--default {
  background: #FFFFFF;
  border-color: #D6D3D1;
  color: #57534E;
}

.xhj-btn--default:hover:not(:disabled) {
  background: #F5F5F4;
}

.xhj-btn--primary {
  background: #C2410C;
  border-color: #C2410C;
  color: #FFFFFF;
}

.xhj-btn--primary:hover:not(:disabled) {
  background: #9A3412;
  border-color: #9A3412;
}

.xhj-btn--danger {
  background: #B91C1C;
  border-color: #B91C1C;
  color: #FFFFFF;
}

.xhj-btn--danger:hover:not(:disabled) {
  background: #991B1B;
  border-color: #991B1B;
}

.xhj-btn--ghost-danger {
  background: #FFFFFF;
  border-color: #B91C1C;
  color: #B91C1C;
}

.xhj-btn--ghost-danger:hover:not(:disabled) {
  background: #FEF2F2;
}

.xhj-btn--big {
  height: 48px;
  padding: 8px 20px;
  font-size: 18px;
  font-weight: 600;
}

.xhj-btn--block {
  width: 100%;
}

.xhj-btn__svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

/* ---------- 3. 遮罩与弹窗 ---------- */
.xhj-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(28, 25, 23, 0.45);
  overflow-y: auto;
}

.xhj-dialog {
  width: 520px;
  max-width: 100%;
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(28, 25, 23, 0.28);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}

.xhj-dialog__head {
  padding: 20px 24px 0;
}

.xhj-dialog__title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
}

.xhj-dialog__desc {
  margin-bottom: 16px;
  font-size: 18px;
  line-height: 1.6;
  color: #57534E;
}

.xhj-dialog__body {
  padding: 16px 24px;
  overflow-y: auto;
}

.xhj-dialog__body:empty {
  display: none;
}

.xhj-dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px 24px;
  flex-wrap: wrap;
}

/* ---------- 4. 提示条 ---------- */
.xhj-toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.xhj-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  border-left: 6px solid transparent;
  box-shadow: 0 6px 18px rgba(28, 25, 23, 0.18);
  background: #FFFFFF;
  font-size: 16px;
  line-height: 1.5;
}

.xhj-toast--success {
  border-left-color: #15803D;
  color: #166534;
  background: #DCFCE7;
}

.xhj-toast--error {
  border-left-color: #B91C1C;
  color: #7F1D1D;
  background: #FEE2E2;
}

.xhj-toast--info {
  border-left-color: #1D4ED8;
  color: #1E3A8A;
  background: #DBEAFE;
}

.xhj-toast__text {
  flex: 1 1 auto;
  word-break: break-all;
}

.xhj-toast__close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: currentColor;
}

/* ---------- 5. 骨架屏 ---------- */
.xhj-skeleton {
  background: #E7E5E4;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.xhj-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #E7E5E4 0%, #F5F5F4 50%, #E7E5E4 100%);
  animation: xhj-skeleton 1.5s ease-in-out infinite;
}

@keyframes xhj-skeleton {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
  .xhj-skeleton::after {
    animation: none;
  }

  .xhj-btn,
  .xhj-toast {
    transition: none;
  }
}
