/* ============================================================
   QuickQR 网页版 —— MD3 色板 + 强制移动端布局
   色板来源：QuickQR/Theme/AppTheme.swift
   布局：内容容器固定 430px 居中；桌面端仅两侧留白，无响应式断点
   ============================================================ */

:root {
  /* 主色 */
  --qr-primary: #0058BC;
  --qr-primary-container: #0070EB;
  --qr-on-primary: #FFFFFF;
  --qr-on-primary-container: #FEFCFF;
  /* 表面色 */
  --qr-surface: #FAF9FE;
  --qr-background: #FAF9FE;
  --qr-surface-container-lowest: #FFFFFF;
  --qr-surface-container: #EEEDF3;
  --qr-surface-container-high: #E9E7ED;
  /* 文本色 */
  --qr-on-surface: #1A1B1F;
  --qr-on-surface-variant: #414755;
  --qr-outline: #717786;
  --qr-outline-variant: #C1C6D7;
  /* 次要 / 固定色 */
  --qr-secondary: #4C4ACA;
  --qr-secondary-container: #6664E4;
  --qr-secondary-fixed: #E2DFFF;
  --qr-primary-fixed: #D8E2FF;
  /* 错误色 */
  --qr-error: #BA1A1A;

  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --app-width: 430px;
  --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 4px 10px rgba(0, 0, 0, 0.04);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
}

body {
  /* 桌面端留白底色略深，衬托 430px 移动端容器 */
  background: #E6E5EC;
  color: var(--qr-on-surface);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

/* ---------------- 强制移动端布局容器 ---------------- */
.app {
  max-width: var(--app-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--qr-background);
  padding: 0 20px 32px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  position: relative;
}

/* 仅桌面端（宽于 430px）给容器加阴影圆角，强化“手机页面”视觉 */
@media (min-width: 431px) {
  .app {
    min-height: 100vh;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.12);
  }
}

/* ---------------- 顶部栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  margin: 0 -20px;
  padding: 0 20px;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--qr-surface);
}

.topbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 4px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--qr-outline);
  cursor: pointer;
}
.topbar-btn:disabled {
  cursor: default;
}
.topbar-btn:not(:disabled) {
  color: var(--qr-primary);
}

.topbar-btn .icon {
  width: 15px;
  height: 15px;
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "PingFang SC", sans-serif;
  color: var(--qr-primary);
  letter-spacing: 0.2px;
}

.topbar-convert {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  font-size: 17px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", sans-serif;
  background: var(--qr-surface-container);
  color: var(--qr-outline);
  cursor: pointer;
}
.topbar-convert:disabled {
  cursor: default;
  background: var(--qr-surface-container);
  opacity: 0.6;
}
.topbar-convert:not(:disabled) {
  background: var(--qr-surface-container-high);
  color: var(--qr-primary);
}

/* ---------------- 通用图标 ---------------- */
.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ---------------- 二维码预览卡片 ---------------- */
.qr-preview-card {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 12px;
  padding: 16px;
  background: var(--qr-surface-container-lowest);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(193, 198, 215, 0.2);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.glow {
  position: absolute;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  filter: blur(48px);
  pointer-events: none;
}
.glow-a {
  background: rgba(216, 226, 255, 0.55);
  top: -30px;
  right: -20px;
}
.glow-b {
  background: rgba(226, 223, 255, 0.55);
  bottom: -30px;
  left: -20px;
}

.qr-box {
  position: relative;
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.qr-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
  image-rendering: pixelated;
}

.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--qr-outline);
}
.qr-placeholder .qr-icon {
  width: 56px;
  height: 56px;
}
.qr-placeholder span {
  font-size: 13px;
  font-weight: 500;
}

/* ---------------- 条码信息栏 ---------------- */
.barcode-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.barcode-text {
  flex: 1;
  min-width: 0;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--qr-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 14px;
  height: 44px;
  line-height: 44px;
  background: var(--qr-surface-container-lowest);
  border-radius: 10px;
  border: 1px solid rgba(193, 198, 215, 0.3);
}

.btn-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 96px;
  height: 44px;
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  background: var(--qr-surface-container);
  color: var(--qr-error);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn-clear .icon {
  width: 15px;
  height: 15px;
}

/* ---------------- 输入表单卡片 ---------------- */
.form-card {
  margin-top: 12px;
  padding: 16px;
  background: var(--qr-surface-container-lowest);
  border-radius: var(--radius-md);
  border: 1px solid rgba(193, 198, 215, 0.3);
  box-shadow: var(--shadow-soft);
}

.field {
  margin-bottom: 12px;
}
.field:last-of-type {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--qr-on-surface-variant);
  margin-bottom: 4px;
}

.field-row {
  display: flex;
  gap: 16px;
}
.field-inline {
  flex: 1;
  display: flex;
  align-items: center;
}
.field-inline .input {
  flex: 1;
}
.field-unit {
  margin-left: 8px;
  font-size: 15px;
  color: var(--qr-on-surface-variant);
}

.input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--qr-outline-variant);
  border-radius: var(--radius-sm);
  background: var(--qr-surface);
  font-size: 15px;
  color: var(--qr-on-surface);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder {
  color: var(--qr-outline-variant);
}
.input:focus {
  border-color: var(--qr-primary);
  box-shadow: 0 0 0 2px rgba(0, 88, 188, 0.12);
}

/* ---------------- 操作按钮 ---------------- */
.form-actions {
  display: flex;
  gap: 12px;
  padding-top: 4px;
}

.btn-primary,
.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 56px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.btn-primary {
  flex: 1;
  background: var(--qr-primary);
  color: var(--qr-on-primary);
}
.btn-primary:active {
  background: var(--qr-primary-container);
}

.btn-secondary {
  width: 128px;
  flex-shrink: 0;
  background: var(--qr-surface-container);
  color: var(--qr-primary);
  border: 1px solid rgba(193, 198, 215, 0.4);
}
.btn-secondary:active {
  background: var(--qr-surface-container-high);
}

/* ---------------- 底部说明 ---------------- */
.footer-note {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--qr-outline-variant);
}

/* ---------------- 弹窗（移动端底部 Sheet） ---------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: var(--app-width);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--qr-background);
  border-radius: 20px 20px 0 0;
  animation: sheet-up 0.25s ease-out;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
}

@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0.6; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--qr-surface);
  border-bottom: 1px solid rgba(193, 198, 215, 0.2);
  font-size: 17px;
  font-weight: 600;
  color: var(--qr-on-surface);
}

.modal-close {
  border: none;
  background: none;
  color: var(--qr-primary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.modal-footer {
  padding: 12px 20px 24px;
  background: var(--qr-background);
}
.btn-block {
  width: 100%;
}

/* 商品图片 */
.product-image-box {
  width: 100%;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(238, 237, 243, 0.4);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  overflow: hidden;
}
.product-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.product-image-ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--qr-outline);
}

/* 信息行 */
.info-row {
  margin-bottom: 12px;
}
.info-row label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--qr-on-surface-variant);
  margin-bottom: 6px;
}
.info-value {
  padding: 14px;
  background: var(--qr-surface-container-lowest);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(193, 198, 215, 0.3);
  font-size: 15px;
  color: var(--qr-on-surface);
  word-break: break-all;
}
.info-row-col {
  display: flex;
  gap: 12px;
}
.info-row-col .info-row {
  flex: 1;
  min-width: 0;
}
.info-price {
  font-size: 24px;
  font-weight: 700;
  color: var(--qr-primary);
  background: rgba(216, 226, 255, 0.35);
  border: none;
}

/* 未找到 */
.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 0;
  text-align: center;
}
.nf-icon {
  width: 56px;
  height: 56px;
  color: var(--qr-outline);
  margin-bottom: 16px;
}
.nf-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--qr-on-surface);
  margin-bottom: 8px;
}
.nf-desc {
  font-size: 13px;
  color: var(--qr-on-surface-variant);
}

/* ---------------- 扫码弹层 ---------------- */
.scan-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: #000;
  display: flex;
  flex-direction: column;
}

.scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}
.scan-header .modal-close {
  color: #fff;
}

.scan-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

#scan-reader {
  width: 100%;
  max-width: 380px;
}

.scan-hint {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
}

/* ---------------- Toast 提示 ---------------- */
.toast {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  max-width: calc(var(--app-width) - 60px);
  padding: 12px 20px;
  background: rgba(26, 27, 31, 0.92);
  color: #fff;
  font-size: 14px;
  border-radius: 12px;
  text-align: center;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------------- 辅助 ---------------- */
[hidden] {
  display: none !important;
}
