/* =============================================
   Font Faces — 项目字体注册
   ============================================= */
@font-face {
  font-family: "HYQiHei";
  src: url("./assets/fonts/HYQIHEI-70S.OTF") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "HYQiHei";
  src: url("./assets/fonts/HYQIHEI-85S.OTF") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "HYQiHei";
  src: url("./assets/fonts/HYQIHEI-95W.OTF") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "HYQiHei";
  src: url("./assets/fonts/HYQIHEI-105JF.TTF") format("truetype");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "MFDianHei";
  src: url("./assets/fonts/MFDianHei.otf") format("opentype");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

/* 可选的单独字重别名（便于精确指定） */
@font-face { font-family: "HYQiHei-25JF"; src: url("./assets/fonts/HYQIHEI-25JF.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-35S"; src: url("./assets/fonts/HYQIHEI-35S.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-40S"; src: url("./assets/fonts/HYQIHEI-40S.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-45S"; src: url("./assets/fonts/HYQIHEI-45S.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-50S"; src: url("./assets/fonts/HYQIHEI-50S.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-55S"; src: url("./assets/fonts/HYQIHEI-55S.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-60S"; src: url("./assets/fonts/HYQIHEI-60S.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-65S"; src: url("./assets/fonts/HYQIHEI-65S.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-70S"; src: url("./assets/fonts/HYQIHEI-70S.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-75W"; src: url("./assets/fonts/HYQIHEI-75W.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-80W"; src: url("./assets/fonts/HYQIHEI-80W.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-85S"; src: url("./assets/fonts/HYQIHEI-85S.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-90W"; src: url("./assets/fonts/HYQIHEI-90W.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-95W"; src: url("./assets/fonts/HYQIHEI-95W.OTF") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HYQiHei-105JF"; src: url("./assets/fonts/HYQIHEI-105JF.TTF") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }

/* =============================================
   Design Tokens — 浅色模式（默认）
   ============================================= */
:root {
  /* Layout */
  --sidebar-width: 86px;
  --topbar-height: 44px;
  --content-padding: 24px;
  /* 单卡最大宽度；整页内容区随浏览器全宽，仅保留左右内边距 */
  --page-content-padding-x: 40px;
  --template-grid-gap: 16px;
  --template-grid-min: 280px;
  --template-grid-max: 316.8px;

  /* Colors - base */
  --white: #FFFFFF;
  --text-primary: #333333;
  --text-secondary: #999999;
  --text-placeholder: #CCCCCC;
  --empty-state-text: #CCCCCC;
  --text-muted: rgba(0, 0, 0, 0.40);
  --text-strong: rgba(0, 0, 0, 0.90);
  --text-input: #1A1A1A;

  /* Colors - surfaces & lines */
  --surface: rgba(255, 255, 255, 0.6);
  --surface-strong: rgba(255, 255, 255, 0.82);
  --surface-glass: rgba(255, 255, 255, 0.30);
  --surface-hover: rgba(255, 255, 255, 0.60);
  --surface-outline: rgba(255, 255, 255, 0.80);
  --line: #EEEEEE;
  --line-soft: #E5E5E5;
  --line-card: #F7F7F7;
  --line-muted: #DDDDDD;

  /* Brand */
  --green: #07C160;
  --green-dark: #06B058;
  --green-selected: #00C250;
  --green-bg-light: #F2FCF6;
  --accent-green-hover: #06AE56;
  --red: #EF5350;

  /* Focus / Interaction */
  --focus-ring: #B4ECCE;
  --focus-shadow-color: rgba(180, 236, 206, 0.25);
  --link-blue: #456CD0;

  /* Backgrounds */
  --page-bg: #FCFFFD;
  --bg-page: #FAFAFA;
  --modal-bg: #F7F7F7;
  --form-field-bg: #FFFFFF;

  /* Overlay */
  --overlay-dark: rgba(0, 0, 0, 0.50);

  /* Shadows */
  --shadow-soft: 0px 8px 16px -2px rgba(0, 0, 0, 0.04);
  --shadow-green: 0px 8px 16px -2px rgba(7, 193, 96, 0.08);
  --shadow-dropdown: 0px 2px 8px -1px rgba(0, 0, 0, 0.12);

  /* Radius */
  --radius-card: 16px;
  --radius-composer: 24px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --radius-xxs: 3px;

  /* Spacing */
  --space-24: 24px;
  --space-20: 20px;
  --space-16: 16px;
  --space-12: 12px;
  --space-8: 8px;
  --space-6: 6px;

  /* Typography - font size */
  --font-10: 10px;
  --font-12: 12px;
  --font-14: 14px;
  --font-16: 16px;

  /* Typography - line height */
  --line-17: 17px;
  --line-20: 20px;
  --line-22: 22px;

  /* ── Toast 短暂提示气泡 ── */
  /* 样式 */
  --toast-bg: rgba(0, 0, 0, 0.90);
  --toast-color: #FFFFFF;
  --toast-radius: 12px;
  --toast-padding: 16px;
  --toast-gap: 8px;
  --toast-font-size: var(--font-14);
  --toast-font-weight: 500;
  --toast-line-height: var(--line-20);
  --toast-icon-size: 20px;
  /* 交互 / 动画 */
  --toast-slide-distance: 24px;
  --toast-fade-duration: 0.35s;
  --toast-fade-easing: ease;
  --toast-slide-easing: cubic-bezier(0.22, 0.61, 0.36, 1);
  --toast-display-duration: 2000;          /* 显示停留时间 ms（JS 读取） */
}

/* =============================================
   Design Tokens — 深色模式
   ============================================= */
[data-theme="dark"] {
  /* Colors - base */
  --white: #2C2C2C;
  --card-bg: #0C0C0C;
  --text-primary: #E0E0E0;
  --text-secondary: #888888;
  --text-placeholder: #555555;
  --empty-state-text: #666666;
  --text-muted: rgba(255, 255, 255, 0.40);
  --text-strong: rgba(255, 255, 255, 0.90);
  --text-input: #F0F0F0;

  /* Colors - surfaces & lines */
  --surface: rgba(44, 44, 44, 0.6);
  --surface-strong: rgba(44, 44, 44, 0.82);
  --surface-glass: rgba(44, 44, 44, 0.30);
  --surface-hover: rgba(44, 44, 44, 0.60);
  --surface-outline: rgba(44, 44, 44, 0.80);
  --line: #3A3A3A;
  --line-soft: #444444;
  --line-card: #333333;
  --line-muted: #4A4A4A;

  /* Brand */
  --green: #07C160;
  --green-dark: #06B058;
  --green-selected: #00C250;
  --green-bg-light: #1A3326;
  --accent-green-hover: #06AE56;
  --red: #EF5350;

  /* Focus / Interaction */
  --focus-ring: #2E7D4F;
  --focus-shadow-color: rgba(46, 125, 79, 0.25);
  --link-blue: #6B8FE0;

  /* Backgrounds */
  --page-bg: #1A1A1A;
  --bg-page: #222222;
  --modal-bg: #F7F7F7;

  /* Overlay */
  --overlay-dark: rgba(0, 0, 0, 0.65);

  /* Shadows */
  --shadow-soft: 0px 8px 16px -2px rgba(0, 0, 0, 0.20);
  --shadow-green: 0px 8px 16px -2px rgba(7, 193, 96, 0.15);
  --shadow-dropdown: 0px 2px 8px -1px rgba(0, 0, 0, 0.30);

  /* Form background — 比 --white 增加 5% 黑色 */
  --form-bg: #292929;
  --form-field-bg: rgba(255, 255, 255, 0.03);

  /* Loading - small spinner */
  --loading-spinner-size-sm: 22px;
  --loading-spinner-stroke-sm: 3px;
  --loading-spinner-duration: 0.9s;
  --loading-spinner-track: rgba(255, 255, 255, 0.30);
  --loading-spinner-head: #FFFFFF;
}

/* Responsive tokens */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 88px;
  }
}

@media (max-width: 768px) {
  :root {
    --content-padding: 16px;
    --page-content-padding-x: 24px;
  }
}

/* =============================================
   全站弹窗面板 — 统一背景
   ============================================= */
.size-modal,
.download-preview-modal,
.logo-upload-modal,
.reset-confirm-modal,
.reset-confirm-modal-actions,
.edit-exit-save-modal,
.edit-exit-save-modal-actions,
.ai-entry-save-modal,
.ai-entry-save-modal-actions,
.qr-upload-hint-modal,
.qr-upload-hint-modal-footer,
.auth-required-dialog,
.login-modal-dialog,
.upload-template-dialog,
.admin-upload-dialog,
.admin-delete-dialog,
.admin-delete-footer,
.manage-tags-dialog,
.edit-details-dialog,
.edit-details-footer,
.edit-ads-dialog,
.template-delete-dialog,
.template-delete-footer,
  .auth-required-footer,
  .tile-popup-menu {
  background: var(--modal-bg);
}

/* 上传模板 / 上传设计：内容区 #FAFAFA，底栏 #FFFFFF（覆盖全站 --modal-bg） */
.admin-upload-modal {
  --upload-modal-surface: #FAFAFA;
  --upload-modal-footer-bg: #FFFFFF;
}

.admin-upload-modal .admin-upload-dialog {
  background: var(--upload-modal-footer-bg, #FFFFFF);
}

.admin-upload-modal :is(.admin-upload-header, .admin-upload-body) {
  background: var(--upload-modal-surface, #FAFAFA);
}

.admin-upload-modal .admin-upload-footer {
  background: var(--upload-modal-footer-bg, #FFFFFF);
}

/* 管理标签：内容区沿用弹窗灰底，底栏按钮区 #FFFFFF */
.manage-tags-modal .manage-tags-footer {
  background: #FFFFFF;
}

/* =============================================
   深色模式 — 弹窗区域强制使用浅色 Design Tokens
   （避免继承 [data-theme="dark"] / html[data-theme="dark"] 的全局变量）
   ============================================= */
html[data-theme="dark"] :is(
  .auth-required-modal,
  .admin-upload-modal,
  .admin-delete-modal,
  .admin-delete-confirm-modal,
  .edit-details-modal,
  .edit-ads-modal,
  .manage-tags-modal,
  .template-delete-modal,
  .login-modal-overlay,
  .size-modal-overlay,
  .download-preview-modal-overlay,
  .logo-upload-modal-overlay,
  .reset-confirm-modal-overlay,
  .edit-exit-save-modal-overlay,
  .ai-entry-save-modal-overlay,
  .qr-upload-hint-modal-overlay,
  .tile-popup-menu
) {
  --white: #FFFFFF;
  --text-primary: #333333;
  --text-secondary: #999999;
  --text-placeholder: #CCCCCC;
  --empty-state-text: #CCCCCC;
  --text-muted: rgba(0, 0, 0, 0.40);
  --text-strong: rgba(0, 0, 0, 0.90);
  --text-input: #1A1A1A;
  --line: #EEEEEE;
  --line-soft: #E5E5E5;
  --line-card: #F7F7F7;
  --line-muted: #DDDDDD;
  --surface: rgba(255, 255, 255, 0.6);
  --surface-strong: rgba(255, 255, 255, 0.82);
  --surface-glass: rgba(255, 255, 255, 0.30);
  --surface-hover: rgba(255, 255, 255, 0.60);
  --surface-outline: rgba(255, 255, 255, 0.80);
  --focus-ring: #B4ECCE;
  --focus-shadow-color: rgba(180, 236, 206, 0.25);
  --form-bg: #FFFFFF;
  --green-bg-light: #F2FCF6;
  --shadow-dropdown: 0px 2px 8px -1px rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
}

/* =============================================
   编辑页 / 后台 — 右上角主题切换（固定位置，两页一致）
   ============================================= */
.page-corner-theme-toggle {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1400;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: #EEEEEE;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.2s ease;
}

.page-corner-theme-toggle:hover {
  background: #E0E0E0;
}

.page-corner-theme-toggle .theme-toggle-icon {
  width: 14px;
  height: 14px;
  display: block;
  transition: filter 0.2s ease, opacity 0.2s ease;
}

html:not([data-theme="dark"]) .page-corner-theme-toggle .theme-toggle-icon {
  filter: brightness(0) saturate(100%);
  opacity: 1;
}

html[data-theme="dark"] .page-corner-theme-toggle {
  background: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .page-corner-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

html[data-theme="dark"] .page-corner-theme-toggle .theme-toggle-icon {
  opacity: 0.6;
  filter: brightness(0) invert(0.6);
}

html[data-theme="dark"] .page-corner-theme-toggle:hover .theme-toggle-icon {
  opacity: 1;
  filter: brightness(0) invert(1);
}

/* 后台顶栏：右侧按钮组贴右上角，切换按钮距浏览器右缘 40px，组内间距 12px */
html[data-page="admin"] .admin-topbar {
  position: relative;
}

html[data-page="admin"] .admin-topbar-right {
  position: absolute;
  right: var(--page-content-padding-x, 40px);
  bottom: 0;
  height: 36px;
  padding-right: 0;
  gap: 12px;
}

html[data-page="admin"] .page-corner-theme-toggle {
  position: static;
  top: auto;
  right: auto;
  flex-shrink: 0;
}

/* =============================================
   Template card grid — 首页 / 后台管理共用
   列宽在 min~max 之间用 1fr 均分容器，宽屏自动增加列数填满一行
   ============================================= */
.cards-grid,
.admin-template-grid {
  display: grid;
  width: 100%;
  box-sizing: border-box;
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(100%, var(--template-grid-min, 280px)), 1fr)
  );
  gap: var(--template-grid-gap, 16px);
}

.cards-grid .template-card,
.admin-template-grid > .admin-template-card,
.admin-template-grid > .template-card,
.cards-grid > .template-stack-unit,
.admin-template-grid > .template-stack-unit {
  width: 100%;
  min-width: 0;
  max-width: var(--template-grid-max, 316.8px);
  justify-self: start;
}

/* Cards: keep semi-transparent backgrounds, no backdrop blur */
.template-card,
.admin-template-card,
.design-library-card,
.design-library-modal-card,
.td-card,
.login-card,
.download-preview-card,
.download-preview-result-card,
.logo-upload-modal-card,
.badge-card {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* =============================================
   Card preview — 全站卡片预览图居中对齐
   ============================================= */
.admin-card-preview,
.card-thumbnail,
.template-card-preview,
.admin-card-preview-front,
.card-thumbnail-front {
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-card-preview img:not(.admin-card-preview-zoom),
.admin-card-preview-front img:not(.admin-card-preview-zoom),
.card-thumbnail .js-template-preview-image,
.card-thumbnail-front .js-template-preview-image,
.template-card-preview img,
.template-card-preview .js-template-preview-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
  flex-shrink: 0;
}

.admin-card-preview-placeholder {
  margin: auto;
  text-align: center;
}

/* =============================================
   Site Footer — 与首页 new-index 底部间距/小字一致
   ============================================= */
.site-footer-section {
  display: block;
  margin-top: 60px;
  padding: 0 40px 40px;
  text-align: center;
  height: 163px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.site-footer-text {
  margin: 0;
  font-size: 12px;
  font-weight: 400;
  color: #CCCCCC;
  line-height: 16.8px;
}

@media (max-width: 768px) {
  .site-footer-section {
    padding: 0 16px 24px;
    height: auto;
    min-height: 96px;
  }
}

/* =============================================
   全站隐藏滚动条（保留滚动能力）
   ============================================= */
html,
body {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

* {
  scrollbar-width: none;
  -ms-overflow-style: none;
  scrollbar-gutter: auto;
}

*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
  background: transparent;
}

*::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner {
  display: none;
  background: transparent;
}

/* =============================================
   Empty state hint text — 全站统一
   浅色 #CCCCCC / 深色 #666666（见 --empty-state-text）
   ============================================= */
.empty-state-hint,
.admin-empty,
.admin-page-empty,
.empty-state,
.cards-empty,
.template-grid-empty,
.design-library-modal-empty,
.edit-ads-empty,
.download-preview-empty {
  color: var(--empty-state-text, #CCCCCC);
}

.cards-empty {
  padding: 80px 0;
  text-align: center;
  font-size: 12px;
  line-height: 17px;
}

/* =============================================
   Button tokens — 中按钮 / 灰色（设计 Token 组件）
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
  text-decoration: none;
  transition: filter 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.btn-medium {
  height: 36px;
  border-radius: var(--radius-md);
  font-size: var(--font-12);
  line-height: 16.8px;
}

.btn-medium.btn-icon-left {
  width: auto;
  padding: 0 var(--space-16);
  justify-content: flex-start;
  gap: var(--space-6);
}

.btn-medium.btn-icon-left img {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-medium.btn-icon-only {
  width: 36px;
  min-width: 36px;
  padding: 0;
}

.btn-medium.btn-icon-only img {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-gray {
  background: var(--line);
  color: var(--text-primary);
}

.btn-gray:not(:disabled):hover,
.btn-gray:not(:disabled):focus-visible {
  filter: brightness(0.97);
}

.btn-gray:disabled {
  cursor: not-allowed;
  pointer-events: none;
}

.btn-gray:disabled span,
.btn-gray:disabled img {
  opacity: 0.5;
}

.btn-gray:disabled:hover,
.btn-gray:disabled:focus-visible {
  filter: none;
}

html[data-theme="dark"] .btn-gray {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

html[data-theme="dark"] .btn-gray:not(:disabled):hover,
html[data-theme="dark"] .btn-gray:not(:disabled):focus-visible {
  filter: brightness(1.15);
  color: #FFFFFF;
}

html[data-theme="dark"] .btn-gray:disabled img {
  filter: brightness(0) invert(0.6);
  opacity: 0.5;
}
