/**
 * PDF Studio - 基础样式与设计系统 Tokens
 * 遵循 YINUNU 规范，严禁外部字体，纯系统字体栈，深浅主题自适应
 */

:root {
  --primary: #dc2626;
  --primary-hover: #b91c1c;
  --primary-active: #991b1b;
  --primary-light: #fef2f2;
  --primary-border: #fca5a5;
  --primary-glow: rgba(220, 38, 38, 0.2);

  --accent-blue: #2563eb;
  --accent-green: #16a34a;
  --accent-amber: #d97706;

  /* 浅色主题 Tokens (Default) */
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f1f5f9;
  --bg-elevated: #ffffff;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --header-height: 56px;
  --footer-border: rgba(0, 0, 0, 0.06);

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --primary: #ef4444;
  --primary-hover: #dc2626;
  --primary-active: #b91c1c;
  --primary-light: rgba(239, 68, 68, 0.15);
  --primary-border: #7f1d1d;
  --primary-glow: rgba(239, 68, 68, 0.3);

  --bg-page: #0b1120;
  --bg-surface: #131c31;
  --bg-surface-alt: #1e293b;
  --bg-elevated: #1e293b;
  --border-color: #334155;
  --border-hover: #475569;
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.7);

  --footer-border: rgba(255, 255, 255, 0.08);
}

/* CSS Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  color: var(--text-main);
  background-color: var(--bg-page);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ================= Top App Header ================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.header-inner {
  max-width: 1400px;
  height: 100%;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-portal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

.brand-portal-link:hover {
  transform: scale(1.06);
  opacity: 0.95;
}

.brand-portal-logo {
  height: 28px;
  width: 112px;
  aspect-ratio: 4 / 1;
  border-radius: var(--radius-sm);
  object-fit: contain;
  display: block;
}

.brand-divider {
  width: 1px;
  height: 20px;
  background-color: var(--border-color);
}

.brand-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-icon-box {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin: 0;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  letter-spacing: 0.02em;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.nav-link svg.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--text-main);
  background-color: var(--bg-surface-alt);
}

.nav-link.active {
  color: var(--primary);
  background-color: var(--primary-light);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ================= Buttons & Icons ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

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

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 1px 2px 0 rgba(220, 38, 38, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-surface-alt);
  border-color: var(--border-hover);
}

.btn-danger {
  background-color: #ef4444;
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background-color: #dc2626;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background-color: var(--bg-surface-alt);
  color: var(--text-main);
  border-color: var(--border-hover);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
}

/* ================= YINUNU Footer ================= */
.yinunu-footer {
  margin-top: auto;
  padding: 2.5rem 1.5rem 2rem;
  border-top: 1px solid var(--footer-border);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.8;
  background-color: var(--bg-surface);
}

.yinunu-footer-brand {
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.yinunu-footer-links {
  margin-bottom: 0.45rem;
}

.yinunu-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.yinunu-footer-links a:hover {
  color: var(--text-main);
  text-decoration: underline;
}

.yinunu-footer-sep {
  margin: 0 0.5rem;
  opacity: 0.4;
}

.yinunu-footer-copy {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* ================= Toast Notification ================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 380px;
}

.toast.toast-success {
  border-left: 4px solid var(--accent-green);
}

.toast.toast-error {
  border-left: 4px solid var(--primary);
}

.toast.toast-info {
  border-left: 4px solid var(--accent-blue);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ================= Global Modal Backdrop ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.2s ease;
  overflow: hidden;
}

.modal-backdrop.active .modal-box {
  transform: scale(1);
}

.modal-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--bg-surface-alt);
}

@media (max-width: 640px) {
  .header-inner {
    padding: 0 0.5rem;
    gap: 0.5rem;
  }
  .brand-badge {
    display: none;
  }
  .brand-title {
    font-size: 0.95rem;
  }
  .brand-portal-logo {
    width: 82px;
    height: 20px;
  }
  .header-nav {
    gap: 0.25rem;
  }
  .nav-link {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
  }
  .nav-link .nav-text {
    display: none; /* 窄屏隐藏文本，平滑降级为图标按钮模式，杜绝文字挤压竖排 */
  }
  .nav-link svg.icon {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 380px) {
  .header-inner {
    padding: 0 0.35rem;
    gap: 0.25rem;
  }
  .brand-wrapper {
    gap: 0.35rem;
  }
  .brand-divider {
    display: none; /* 极窄屏隐藏分割线 */
  }
  .brand-title {
    display: none; /* 极窄屏隐藏长文本标题，保留 4:1 品牌 Logo 与图标，彻底防止撑破顶栏 */
  }
  .brand-portal-logo {
    width: 76px;
    height: 19px;
  }
  .brand-icon-box {
    width: 28px;
    height: 28px;
  }
}


/* ---------- YINUNU 通用模态弹窗（产品矩阵 & 隐私条款） ---------- */
.yinunu-products-modal[hidden] {
  display: none !important;
}

.yinunu-products-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.yinunu-products-modal * {
  box-sizing: border-box;
}

.yinunu-products-modal a {
  text-decoration: none;
}

.yinunu-products-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.yinunu-products-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  background: #181c2a !important;
  color: #f1f5f9 !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: yinunuFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes yinunuFadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.yinunu-products-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: transparent !important;
}

.yinunu-products-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.yinunu-products-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: #f8fafc !important;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.yinunu-products-subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: #94a3b8 !important;
  line-height: 1.4;
}

.yinunu-products-close {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  font-size: 1.5rem;
  line-height: 1;
  color: #94a3b8 !important;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.yinunu-products-close:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

.yinunu-products-body {
  padding: 1.25rem 1.5rem 1.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: transparent !important;
  color: #f1f5f9 !important;
}

.yinunu-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.yinunu-product-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 8px;
  text-decoration: none !important;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.yinunu-product-item:hover {
  transform: translateY(-2px);
  border-color: #38bdf8 !important;
  background: rgba(56, 189, 248, 0.06) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.yinunu-product-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f1f5f9 !important;
  margin-bottom: 0.35rem;
  transition: color 0.15s ease;
}

.yinunu-product-url {
  font-size: 0.75rem;
  color: #94a3b8 !important;
  word-break: break-all;
  transition: color 0.15s ease;
}

.yinunu-product-item:hover .yinunu-product-name {
  color: #38bdf8 !important;
}

.yinunu-product-item:hover .yinunu-product-url {
  color: #cbd5e1 !important;
}

/* ---------- 隐私条款专属样式 ---------- */
.yinunu-privacy-body {
  font-size: 0.85rem;
  line-height: 1.75;
  color: #cbd5e1 !important;
}

.yinunu-privacy-lead {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1) !important;
  color: #f1f5f9 !important;
}

.yinunu-privacy-body h4 {
  margin: 1.1rem 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #38bdf8 !important;
}

.yinunu-privacy-body p {
  margin: 0.4rem 0;
  color: #cbd5e1 !important;
}

.yinunu-privacy-body strong {
  color: #f8fafc !important;
  font-weight: 600;
}

.yinunu-privacy-bullet {
  padding-left: 0.8rem;
  position: relative;
}

.yinunu-privacy-bullet::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #38bdf8 !important;
}

.yinunu-privacy-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.85rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: rgba(0, 0, 0, 0.18) !important;
}

.yinunu-privacy-agree-btn {
  background: #0284c7 !important;
  color: #ffffff !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 6px;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.yinunu-privacy-agree-btn:hover {
  background: #0369a1 !important;
  opacity: 0.95;
  transform: translateY(-1px);
}

@media (max-width: 480px) {
  .yinunu-products-card { max-height: 90vh; }
  .yinunu-products-grid { grid-template-columns: 1fr; }
  .yinunu-privacy-footer { justify-content: stretch; }
  .yinunu-privacy-agree-btn { width: 100%; text-align: center; }
}
