/* ==========================================================================
   base.css   全局 reset + 通用排版 + 跨页面公共组件
   依赖 THEME.css 中定义的变量，必须在 THEME.css 之后引入
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

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

button {
  font-family: inherit;
  cursor: pointer;
}

input, textarea {
  font-family: inherit;
}

img {
  display: block;
  max-width: 100%;
}

/* ---------- 通用页面容器：模拟手机端单列布局，桌面端居中显示 ---------- */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- 顶部导航栏：返回键 + 标题 ---------- */
.top-nav {
  display: flex;
  align-items: center;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-gold);
  position: sticky;
  top: 0;
  background: var(--bg-page);
  z-index: 10;
}

.top-nav .nav-back {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 22px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
}
.top-nav .nav-back:active {
  background: var(--bg-surface-raised);
}

.top-nav .nav-title {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: 1px;
  margin-right: 36px; /* 抵消左侧返回按钮宽度，使标题真正居中 */
}

/* ---------- 页面主体内容区 ---------- */
.page-content {
  flex: 1;
  padding: var(--space-md);
  padding-top: var(--space-lg);
  padding-bottom: 140px; /* 预留底部固定栏空间 */
}

/* ---------- 通用卡片 ---------- */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.panel-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  padding-left: 10px;
  border-left: 3px solid var(--gold-main);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* ---------- 装饰性分隔线：金色细线 + 中间菱形，呼应高级菜单质感 ---------- */
.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: var(--space-lg) 0 var(--space-md);
  color: var(--gold-light);
}
.section-divider::before,
.section-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-gold) 50%, transparent);
}
.section-divider .divider-mark {
  font-size: 10px;
  color: var(--gold-main);
  transform: rotate(45deg);
  display: inline-block;
}

/* ---------- 底部固定操作栏 ---------- */
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-gold);
  padding: var(--space-md);
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
  z-index: 20;
}

/* ---------- 主按钮（大宽度，去付款 / 返回首页等） ---------- */
.btn-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.btn-block .btn-sub {
  font-size: var(--font-size-xs);
  font-weight: 400;
  color: var(--text-on-accent);
  opacity: 0.75;
}
.btn-block.btn-disabled {
  background: var(--status-disabled-bg);
  color: var(--status-disabled-text);
  box-shadow: none;
  pointer-events: none;
}
.btn-block.btn-disabled .btn-sub {
  color: var(--status-disabled-text);
}

/* ---------- 全局 Toast 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 30, 35, 0.95);
  color: var(--text-primary);
  border: 1px solid var(--border-accent);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base), transform var(--transition-base);
  z-index: 999;
  max-width: 80%;
  text-align: center;
}
.toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 通用表单元素 ---------- */
.form-group {
  margin-bottom: var(--space-md);
}
.form-label {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}
.form-label .required-star {
  color: var(--status-danger);
  margin-left: 2px;
}
.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px var(--space-md);
  font-size: var(--font-size-md);
}
.form-control::placeholder {
  color: var(--text-tertiary);
}
.form-control:focus {
  outline: none;
  border-color: var(--border-input-focus);
}
.form-control.has-error {
  border-color: var(--status-danger);
}
.form-error-text {
  color: var(--status-danger);
  font-size: var(--font-size-xs);
  margin-top: 4px;
  display: none;
}
.form-control.has-error + .form-error-text {
  display: block;
}
textarea.form-control {
  resize: none;
  min-height: 80px;
}
.char-counter {
  text-align: right;
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  margin-top: 4px;
}
