/* ============================================================
   第一问卷 公共样式基线
   所有页面在自身 <style> 之前引入本文件。
   约定：页面自身样式优先级更高（后加载覆盖），
   此文件只提供设计 tokens 与跨页共享组件的兜底样式。
   ============================================================ */

:root {
  /* 品牌色 */
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --primary-darker: #1D4ED8;
  --secondary: #8B5CF6;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;

  /* 灰阶（Tailwind Slate） */
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  /* 品牌 Logo 渐变 */
  --brand-gradient: linear-gradient(135deg, #3B82F6, #8B5CF6);

  /* 布局 */
  --nav-height: 72px;
  --sidebar-width: 240px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.15);
}

/* ---------- 按钮（兜底，页面未定义时生效） ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--gray-200);
  color: var(--gray-700);
}

/* ---------- 卡片（兜底） ---------- */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ---------- 公共顶部导航用户区（游客 / 已登录） ---------- */
.nav-user-actions {
  display: none;
  align-items: center;
  gap: 12px;
}

.nav-guest-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--gray-100);
  border-radius: 8px;
}

.nav-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.nav-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
}

/* ============================================================
   浮动语言切换器（由 js/lang-switcher.js 注入，所有页面可用）
   ============================================================ */
.qf-lang-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10000;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.qf-lang-fab .lang-switcher-trigger {
  background: #fff;
  border: 1px solid var(--gray-200);
  color: var(--gray-700);
  box-shadow: var(--shadow-md);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
}

.qf-lang-fab .lang-switcher-trigger:hover,
.qf-lang-fab .lang-switcher-trigger.active {
  background: #fff;
  border-color: var(--primary);
  color: var(--primary-dark);
}

.qf-lang-fab .lang-dropdown {
  bottom: calc(100% + 8px);
  top: auto;
  right: 0;
}

@media (max-width: 640px) {
  .qf-lang-fab {
    right: 12px;
    bottom: 12px;
  }
}

/* ============================================================
   窄屏「建议在电脑上编辑」提示层
   元素由 js/mobile-tip.js 动态插入，只有引入该脚本的编辑类页面才会出现。
   默认隐藏，窄屏才显示；不阻断操作，可关闭。
   ============================================================ */
.mobile-edit-tip {
  display: none;
}

@media (max-width: 768px) {
  .mobile-edit-tip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    color: #92400E;
    font-size: 13px;
    line-height: 1.5;
    border-bottom: 1px solid #FCD34D;
  }

  .mobile-edit-tip .met-icon {
    font-size: 16px;
    flex-shrink: 0;
  }

  .mobile-edit-tip .met-text {
    flex: 1;
    min-width: 0;
  }

  .mobile-edit-tip .met-close {
    flex-shrink: 0;
    border: 1px solid #F59E0B;
    background: #fff;
    color: #92400E;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
  }
}

/* ============================================================
   移动端通用基线（所有页面共享）
   只放「不会破坏桌面端、且能普遍防呆」的规则：
   防横向溢出、防长串文本撑破容器、表单控件自适应、iOS 不自动放大字号。
   具体布局（多列降列、间距收缩）仍由各页面自己的 @media 负责。
   ============================================================ */
html {
  /* iOS 横屏/旋转时禁止字体被自动放大导致布局跳动 */
  -webkit-text-size-adjust: 100%;
}

body {
  /* 长英文单词或 URL 不撑破容器 */
  overflow-wrap: break-word;
}

img,
video {
  max-width: 100%;
}

input,
select,
textarea {
  max-width: 100%;
}

pre,
code {
  max-width: 100%;
  overflow-x: auto;
}

@media (max-width: 768px) {
  input,
  select,
  textarea {
    /* flex 子项默认 min-width:auto，窄屏下会拒绝收缩撑破父容器 */
    min-width: 0;
  }
}

/* ============================================================
   公共页脚组件（由 js/footer.js 渲染，替换各页面自带的 footer）
   用独立的 qf-footer-* class，避免被页面内联的 .footer 样式影响，
   保证所有页面页脚样式完全一致。
   ============================================================ */
.qf-footer {
  background: #0F172A;
  color: #fff;
  padding: 64px 48px 32px;
}

.qf-footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(4, 1fr);
  gap: 48px;
  max-width: 1200px;
  margin: 0 auto 48px;
}

.qf-footer-brand {
  max-width: 300px;
}

.qf-footer-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  text-decoration: none;
  margin-bottom: 16px;
}

.qf-footer-desc {
  font-size: 14px;
  color: #94A3B8;
  line-height: 1.7;
  margin: 0;
}

.qf-footer-col h4 {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin: 0 0 20px;
}

.qf-footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.qf-footer-links li {
  margin-bottom: 12px;
}

.qf-footer-links a {
  color: #94A3B8;
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}

.qf-footer-links a:hover {
  color: #fff;
}

.qf-footer-bottom {
  border-top: 1px solid #1E293B;
  padding-top: 32px;
  max-width: 1200px;
  margin: 0 auto;
  font-size: 14px;
  color: #94A3B8;
}

@media (max-width: 1024px) {
  .qf-footer {
    padding: 48px 24px 28px;
  }

  .qf-footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
    margin-bottom: 32px;
  }
}

@media (max-width: 768px) {
  .qf-footer {
    padding: 40px 20px 24px;
  }

  .qf-footer-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 24px;
  }

  .qf-footer-brand {
    max-width: none;
  }

  /* 窄屏折叠：分组标题可点，链接默认收起，避免页脚拉得过长 */
  .qf-footer-col {
    border-bottom: 1px solid #1E293B;
    margin: 0;
  }

  .qf-footer-col h4 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 14px 2px;
    font-size: 15px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  /* 箭头：默认朝下，展开后朝上 */
  .qf-footer-arrow {
    width: 7px;
    height: 7px;
    margin-right: 4px;
    border-right: 2px solid #94A3B8;
    border-bottom: 2px solid #94A3B8;
    transform: rotate(45deg);
    transition: transform 0.2s;
  }

  .qf-footer-col.open .qf-footer-arrow {
    transform: rotate(-135deg);
  }

  .qf-footer-links {
    display: none;
    padding: 4px 2px 12px;
  }

  .qf-footer-col.open .qf-footer-links {
    display: block;
  }

  .qf-footer-links li {
    margin-bottom: 14px;
  }

  .qf-footer-bottom {
    padding-top: 24px;
    text-align: center;
  }
}

/* ============================================================
   旧版 footer（页面内联、未接入组件时）的移动端兜底，保留以免遗漏页面
   ============================================================ */
/* 平板：统一 2 列（各页面断点从 900 到 1024 不等，且有的一列不降） */
@media (max-width: 1024px) {
  .footer .footer-grid,
  .footer-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 32px;
  }
}

/* 手机：统一 1 列。!important 用于压过各页面自己写的 2 列规则——
   页面内联 <style> 比 common.css 后加载，同特异性下会赢，导致各页列数不一致 */
@media (max-width: 768px) {
  .footer {
    padding: 48px 20px 28px !important;
  }

  .footer .footer-grid,
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 28px;
    margin-bottom: 32px;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}
