/* ============================================================
   陕汽二期小程序 - 全局样式
   蓝白简洁风格，适配移动端 (375px)
   ============================================================ */

:root {
  --primary: #1890FF;
  --primary-light: #E6F7FF;
  --primary-dark: #096DD9;
  --success: #52C41A;
  --warning: #FAAD14;
  --danger: #FF4D4F;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --text-disabled: #CCCCCC;
  --bg-page: #F5F7FA;
  --bg-white: #FFFFFF;
  --bg-input: #F0F2F5;
  --border: #E8E8E8;
  --border-light: #F0F0F0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-md: 15px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 20px;
  --font-size-3xl: 24px;
  --header-height: 50px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 0; height: 0; }

/* ============================================================
   Header
   ============================================================ */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  padding: 0 16px;
}

.header.back {
  justify-content: space-between;
}

.header-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  min-width: 48px;
  height: 100%;
}

.header-right { justify-content: flex-end; }

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.back-btn svg { width: 22px; height: 22px; color: var(--text-primary); }

.header-action {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  cursor: pointer;
  gap: 4px;
}

.header-action.primary { background: var(--primary); color: white; }
.header-action.ghost { background: var(--bg-page); color: var(--text-secondary); }

/* ============================================================
   Page wrapper (each HTML page wraps content in .page-content)
   ============================================================ */

.page-content {
  min-height: calc(100vh - var(--header-height));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.section { padding: 12px 16px; }

.section-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title .more {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  font-weight: 400;
}

/* ============================================================
   Components - Card
   ============================================================ */

.card {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.card.no-shadow { box-shadow: none; }

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

/* ============================================================
   Components - Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { opacity: 0.7; }

.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-text { background: transparent; color: var(--primary); height: auto; padding: 8px 12px; }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 14px; font-size: var(--font-size-sm); }
.btn-lg { height: 48px; font-size: var(--font-size-lg); }

/* ============================================================
   Components - Tags
   ============================================================ */

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  line-height: 18px;
}

.tag-primary { background: var(--primary-light); color: var(--primary); }
.tag-success { background: #F6FFED; color: var(--success); }
.tag-warning { background: #FFFBE6; color: #D48806; }
.tag-danger { background: #FFF2F0; color: var(--danger); }
.tag-default { background: #F5F5F5; color: var(--text-secondary); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  color: white;
  background: var(--danger);
  line-height: 18px;
  text-align: center;
}

/* ============================================================
   Components - Lists
   ============================================================ */

.list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-white);
  cursor: pointer;
  transition: background 0.15s;
}

.list-item:active { background: var(--bg-input); }
.list-item + .list-item { border-top: 1px solid var(--border-light); }

.list-item .icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
  font-size: 18px;
}

.list-item .content { flex: 1; min-width: 0; }
.list-item .title { font-size: var(--font-size-base); color: var(--text-primary); font-weight: 500; }
.list-item .subtitle { font-size: var(--font-size-xs); color: var(--text-tertiary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .extra { flex-shrink: 0; font-size: var(--font-size-sm); color: var(--text-tertiary); margin-left: 8px; }
.list-item .extra.right { margin-left: auto; }

.chevron {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  margin-left: 8px;
}

/* ============================================================
   Components - Form
   ============================================================ */

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.form-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-base);
  background: var(--bg-white);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus { border-color: var(--primary); }
.form-input.area { height: 80px; padding: 10px 12px; resize: none; }
.form-input.transparent { background: var(--bg-input); border: none; border-radius: var(--radius-full); }

.search-bar {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  gap: 8px;
}

.search-bar svg { width: 16px; height: 16px; color: var(--text-tertiary); flex-shrink: 0; }
.search-bar input { flex: 1; border: none; background: transparent; font-size: var(--font-size-base); color: var(--text-primary); outline: none; }
.search-bar input::placeholder { color: var(--text-tertiary); }

/* ============================================================
   Components - Switch
   ============================================================ */

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.15);
  border-radius: 28px;
  cursor: pointer;
  transition: 0.3s;
}

.switch .slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ============================================================
   Components - Progress
   ============================================================ */

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar .fill { height: 100%; border-radius: var(--radius-full); transition: width 0.3s; }
.progress-bar .fill.primary { background: var(--primary); }
.progress-bar .fill.success { background: var(--success); }

/* ============================================================
   Components - Loading
   ============================================================ */

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: var(--text-tertiary);
  font-size: var(--font-size-sm);
}

/* ============================================================
   Utilities
   ============================================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-tertiary); }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.px-16 { padding-left: 16px; padding-right: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty-state svg { width: 64px; height: 64px; color: var(--border); margin-bottom: 16px; }
.empty-state p { font-size: var(--font-size-sm); }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.quick-action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  cursor: pointer;
}
.quick-action-item:active { background: var(--bg-input); }
.quick-action-item .qa-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  font-size: 22px;
}
.quick-action-item .qa-label { font-size: var(--font-size-xs); color: var(--text-secondary); }

.stats-row { display: flex; justify-content: space-around; text-align: center; padding: 12px 0; }
.stats-row .stat-item .stat-value { font-size: var(--font-size-2xl); font-weight: 600; color: var(--text-primary); }
.stats-row .stat-item .stat-label { font-size: var(--font-size-xs); color: var(--text-tertiary); margin-top: 4px; }

/* Watermark overlay */
.watermark-text-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.watermark-text-overlay span {
  position: absolute;
  font-size: 12px;
  color: rgba(0,0,0,0.08);
  white-space: nowrap;
  transform: rotate(-30deg);
}

/* Streaming cursor */
.streaming-cursor::after {
  content: '▊';
  animation: blink 0.8s infinite;
  color: var(--primary);
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Tab pills */
.tab-pills {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  flex-shrink: 0;
}

.tab-pill {
  flex-shrink: 0;
  height: 34px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  background: var(--bg-white);
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.tab-pill.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   Modal (shared)
   ============================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal-content {
  width: 80%;
  max-width: 320px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.modal-body { padding: 24px 20px; text-align: center; }
.modal-body h3 { font-size: var(--font-size-lg); font-weight: 600; margin-bottom: 12px; }
.modal-body p { font-size: var(--font-size-sm); color: var(--text-secondary); line-height: 1.5; margin-bottom: 8px; }

.modal-actions { display: flex; border-top: 1px solid var(--border-light); }
.modal-actions button { flex: 1; height: 48px; border: none; background: transparent; font-size: var(--font-size-base); cursor: pointer; transition: background 0.15s; }
.modal-actions button:active { background: var(--bg-input); }
.modal-actions .cancel { color: var(--text-secondary); border-right: 1px solid var(--border-light); }
.modal-actions .confirm { color: var(--primary); font-weight: 500; }
