/* ============================================================
   机油查询系统 — 微信适配样式
   基于 WeUI 风格设计
   ============================================================ */

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

:root {
  --weui-BG-0: #ededed;
  --weui-BG-1: #f7f7f7;
  --weui-BG-2: #ffffff;
  --weui-FG-0: rgba(0,0,0,.9);
  --weui-FG-1: rgba(0,0,0,.5);
  --weui-FG-2: rgba(0,0,0,.3);
  --weui-RED: #fa5151;
  --weui-BRAND: #07c160;
  --weui-BLUE: #1482ee;
  --weui-LINK: #576b95;
  --weui-TAG-BG: rgba(0,0,0,.05);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --max-width: 480px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%; /* 禁止微信调整字体大小 */
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--weui-BG-0);
  color: var(--weui-FG-0);
  line-height: 1.6;
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: var(--safe-bottom);
}

a { color: var(--weui-LINK); text-decoration: none; }

/* ============================================================
   Navigation Bar
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--weui-BG-2);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0,0,0,.08);
}

.navbar__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--weui-FG-0);
}

.navbar__back {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--weui-FG-0);
  font-size: 15px;
  padding: 4px 8px;
  border: none;
  background: none;
  cursor: pointer;
}

.navbar__back::before {
  content: '‹';
  font-size: 24px;
  line-height: 1;
  font-weight: 300;
}

.navbar__action {
  display: flex;
  align-items: center;
  color: var(--weui-FG-0);
  font-size: 15px;
  padding: 4px 8px;
  border: none;
  background: none;
  cursor: pointer;
}

/* ============================================================
   WeUI Cells (列表项)
   ============================================================ */
.weui-cells {
  background: var(--weui-BG-2);
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
}

.weui-cells__title {
  padding: 12px 16px 6px;
  font-size: 13px;
  color: var(--weui-FG-1);
}

.weui-cell {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  background: var(--weui-BG-2);
  border-bottom: 1px solid rgba(0,0,0,.05);
  cursor: pointer;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}

.weui-cell:last-child { border-bottom: none; }
.weui-cell:active { background: rgba(0,0,0,.05); }

.weui-cell__bd {
  flex: 1;
  font-size: 15px;
}

.weui-cell__ft {
  color: var(--weui-FG-2);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.weui-cell__ft::after {
  content: '›';
  font-size: 20px;
  color: rgba(0,0,0,.3);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .2s;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary:active { background: #06ad56; }

.btn-default {
  background: var(--weui-BG-1);
  color: var(--weui-FG-0);
  border: 1px solid rgba(0,0,0,.1);
}

.btn-block {
  display: flex;
  width: 100%;
  margin: 8px 0;
}

.btn-lg { padding: 14px 24px; font-size: 16px; }

/* ============================================================
   Search Bar
   ============================================================ */
.search-bar {
  padding: 12px 16px;
  background: var(--weui-BG-2);
}

.search-bar__input {
  display: flex;
  align-items: center;
  background: var(--weui-BG-0);
  border-radius: 8px;
  padding: 10px 14px;
  gap: 8px;
}

.search-bar__input input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  outline: none;
  color: var(--weui-FG-0);
}

.search-bar__input input::placeholder { color: var(--weui-FG-2); }
.search-bar__icon { font-size: 18px; }

/* ============================================================
   Brand Grid (品牌快捷选择)
   ============================================================ */
.brand-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px;
}

.brand-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--weui-BG-2);
  border-radius: 10px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.brand-item:active { transform: scale(.95); }

.brand-item__icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--weui-TAG-BG);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--weui-FG-0);
}

.brand-item__name {
  font-size: 12px;
  color: var(--weui-FG-0);
  text-align: center;
  line-height: 1.3;
}

/* ============================================================
   Feature Cards
   ============================================================ */
.feature-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px 16px;
}

.feature-card {
  background: var(--weui-BG-2);
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: transform .15s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.feature-card:active { transform: scale(.97); }

.feature-card__icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.feature-card__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.feature-card__desc {
  font-size: 12px;
  color: var(--weui-FG-1);
}

.feature-card--primary {
  background: linear-gradient(135deg, #07c160, #06ad56);
  color: #fff;
}

.feature-card--primary .feature-card__desc {
  color: rgba(255,255,255,.8);
}

/* ============================================================
   Page Content
   ============================================================ */
.page {
  padding: 12px 16px;
}

.page__title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.page__subtitle {
  font-size: 13px;
  color: var(--weui-FG-1);
  margin-bottom: 16px;
}

/* ============================================================
   Results Card
   ============================================================ */
.result-card {
  background: var(--weui-BG-2);
  border-radius: 10px;
  padding: 20px 16px;
  margin: 12px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.result-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0,0,0,.06);
}

.result-card__vehicle {
  font-size: 16px;
  font-weight: 600;
}

.result-card__confidence {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--weui-TAG-BG);
  color: var(--weui-FG-1);
}

.confidence--high { background: rgba(7,193,96,.1); color: #07c160; }
.confidence--mid { background: rgba(20,130,238,.1); color: #1482ee; }
.confidence--low { background: rgba(250,81,81,.1); color: #fa5151; }

.oil-spec {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.oil-spec__item {
  background: var(--weui-BG-1);
  border-radius: 8px;
  padding: 12px;
}

.oil-spec__label {
  font-size: 11px;
  color: var(--weui-FG-1);
  margin-bottom: 4px;
}

.oil-spec__value {
  font-size: 22px;
  font-weight: 700;
  color: var(--weui-FG-0);
}

.oil-spec__value--highlight {
  color: #07c160;
}

.oil-spec__unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--weui-FG-1);
}

.oil-spec__full {
  grid-column: 1 / -1;
}

/* ============================================================
   Source Badges
   ============================================================ */
.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.source-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 10px;
  background: var(--weui-TAG-BG);
  color: var(--weui-FG-1);
}

/* ============================================================
   VIN Input
   ============================================================ */
.vin-input-section {
  text-align: center;
  padding: 24px 16px;
}

.vin-input {
  width: 100%;
  max-width: 320px;
  padding: 14px 16px;
  font-size: 18px;
  text-align: center;
  letter-spacing: 3px;
  border: 2px solid rgba(0,0,0,.1);
  border-radius: 10px;
  text-transform: uppercase;
  font-family: 'Courier New', monospace;
  outline: none;
  transition: border-color .2s;
}

.vin-input:focus { border-color: var(--weui-BRAND); }

.vin-hint {
  font-size: 12px;
  color: var(--weui-FG-2);
  margin-top: 8px;
}

/* ============================================================
   Camera
   ============================================================ */
.camera-area {
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  margin: 12px 0;
}

.camera-area video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-area__overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 60px;
  border: 2px dashed rgba(255,255,255,.6);
  border-radius: 8px;
}

.camera-area__hint {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255,255,255,.8);
  font-size: 13px;
}

.preview-image {
  width: 100%;
  border-radius: 10px;
  margin: 12px 0;
}

/* ============================================================
   Loading & Status
   ============================================================ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0,0,0,.1);
  border-top-color: var(--weui-BRAND);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.status-msg {
  text-align: center;
  padding: 20px;
  color: var(--weui-FG-1);
  font-size: 14px;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--weui-FG-1);
}

.empty-state__icon { font-size: 48px; margin-bottom: 12px; }
.empty-state__text { font-size: 15px; }

/* ============================================================
   History List
   ============================================================ */
.history-list {
  margin: 12px 16px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: var(--weui-BG-2);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}

.history-item__info {
  display: flex;
  flex-direction: column;
}

.history-item__vehicle {
  font-size: 15px;
  font-weight: 500;
}

.history-item__time {
  font-size: 12px;
  color: var(--weui-FG-2);
}

/* ============================================================
   Toast / Message
   ============================================================ */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,.8);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}

.toast--show { opacity: 1; }

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
  display: flex;
  background: var(--weui-BG-2);
  border-bottom: 1px solid rgba(0,0,0,.08);
}

.tab {
  flex: 1;
  text-align: center;
  padding: 12px;
  font-size: 14px;
  color: var(--weui-FG-1);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all .2s;
}

.tab--active {
  color: var(--weui-BRAND);
  border-bottom-color: var(--weui-BRAND);
  font-weight: 600;
}

/* ============================================================
   Step Selector (品牌→车系→年份→排量)
   ============================================================ */
.step-indicator {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 4px;
  font-size: 13px;
  color: var(--weui-FG-1);
  flex-wrap: wrap;
  background: var(--weui-BG-2);
  border-bottom: 1px solid rgba(0,0,0,.05);
}

.step-indicator__item {
  color: var(--weui-BLUE);
}

.step-indicator__arrow {
  color: var(--weui-FG-2);
}

.step-indicator__item--active {
  color: var(--weui-BRAND);
  font-weight: 600;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  text-align: center;
  padding: 20px 16px;
  font-size: 12px;
  color: var(--weui-FG-2);
}

/* ============================================================
   Utility Classes
   ============================================================ */
.text-muted { font-size: 13px; color: var(--weui-FG-1); }
.text-xs { font-size: 12px; color: var(--weui-FG-2); }
.text-sm { font-size: 13px; }
.text-center { text-align: center; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.navbar__spacer { width: 50px; }
.page--center { text-align: center; padding: 20px; }

/* ============================================================
   Responsive / Mobile Fixes
   ============================================================ */
@media (max-width: 375px) {
  .brand-grid { grid-template-columns: repeat(3, 1fr); }
  .oil-spec { grid-template-columns: 1fr; }
}

@media (min-width: 481px) {
  body { border-left: 1px solid rgba(0,0,0,.08); border-right: 1px solid rgba(0,0,0,.08); }
}
