/* ========================================
   运智宝 TMS - 司机端公共样式
   移动端适配: vw 方案
   ======================================== */

/* Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #333;
  background: #f5f7fa;
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

input, button, textarea, select {
  font-family: inherit;
  font-size: inherit;
  outline: none;
  border: none;
  -webkit-appearance: none;
  appearance: none;
}

a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ========== CSS Variables ========== */
:root {
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --primary-light: #e6f4ff;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --orange: #ff7a00;

  --text-primary: #333;
  --text-secondary: #666;
  --text-placeholder: #999;
  --text-disabled: #bbb;

  --bg-page: #f5f7fa;
  --bg-card: #fff;
  --bg-input: #f5f7fa;

  --border: #e8e8e8;
  --border-light: #f0f0f0;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ========== Layout ========== */
.page-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

.page-header .back-btn {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(calc(-50% + env(safe-area-inset-top) / 2));
  font-size: 24px;
  color: #fff;
  padding: 4px 8px;
  cursor: pointer;
}

.page-header .title {
  font-size: 17px;
  font-weight: 600;
}

.page-header .right-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(calc(-50% + env(safe-area-inset-top) / 2));
  font-size: 14px;
  color: #fff;
  cursor: pointer;
}

.page-body {
  flex: 1;
  padding: 12px 16px;
  padding-bottom: calc(60px + var(--safe-bottom));
}

/* ========== Brand Footer ========== */
.brand-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 12px 0;
  padding-bottom: calc(12px + var(--safe-bottom));
  font-size: 12px;
  color: var(--text-placeholder);
  background: var(--bg-page);
}

.brand-footer .brand-name {
  font-weight: 600;
  color: var(--primary);
}

/* ========== Card ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

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

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.2s;
  user-select: none;
}

.btn:active { opacity: 0.8; }

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

.btn-primary:disabled {
  background: #91caff;
  cursor: not-allowed;
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger);
}

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

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

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

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  height: 56px;
  font-size: 18px;
  border-radius: var(--radius-lg);
}

.btn-sm {
  height: 36px;
  padding: 0 16px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.btn-group {
  display: flex;
  gap: 12px;
}

.btn-group .btn { flex: 1; }

/* ========== Form ========== */
.form-group {
  margin-bottom: 20px;
}

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

.form-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  background: #fff;
}

.form-input::placeholder {
  color: var(--text-placeholder);
}

.input-with-btn {
  display: flex;
  gap: 12px;
}

.input-with-btn .form-input { flex: 1; }

.input-with-btn .btn {
  white-space: nowrap;
  min-width: 120px;
  height: 48px;
}

/* ========== Tabs ========== */
.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 48px;
  z-index: 90;
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  font-size: 14px;
  color: var(--text-secondary);
  position: relative;
  cursor: pointer;
  transition: color 0.2s;
}

.tab-item.active {
  color: var(--primary);
  font-weight: 600;
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

/* ========== Status Tags ========== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 4px;
  font-weight: 500;
}

.tag-pending { background: #fff7e6; color: var(--orange); }
.tag-active { background: var(--primary-light); color: var(--primary); }
.tag-success { background: #f6ffed; color: var(--success); }
.tag-danger { background: #fff2f0; color: var(--danger); }
.tag-default { background: #f5f5f5; color: var(--text-secondary); }

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  pointer-events: none;
}

.toast {
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  text-align: center;
  max-width: 260px;
  animation: toastIn 0.3s ease;
  pointer-events: auto;
}

.toast.success::before { content: '✓ '; }
.toast.error::before { content: '✗ '; }
.toast.warning::before { content: '⚠ '; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== Loading ========== */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.7);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

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

/* ========== Modal / Confirm ========== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  animation: slideUp 0.3s ease;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-content {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions .btn { flex: 1; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== Progress Bar ========== */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

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

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state .empty-text {
  font-size: 14px;
}

/* ========== Info List ========== */
.info-list {
  display: flex;
  flex-direction: column;
}

.info-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}

.info-row:last-child { border-bottom: none; }

.info-label {
  width: 100px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.info-value {
  flex: 1;
  color: var(--text-primary);
  word-break: break-all;
}

/* ========== Pull to Refresh ========== */
.pull-indicator {
  text-align: center;
  padding: 12px;
  font-size: 13px;
  color: var(--text-placeholder);
  display: none;
}

.pull-indicator.visible { display: block; }

/* ========== Waybill Card ========== */
.waybill-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.waybill-card:active {
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.waybill-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.waybill-no {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.waybill-card-body {
  margin-bottom: 10px;
}

.waybill-route {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 6px;
}

.waybill-route .arrow { color: var(--primary); font-weight: bold; }

.waybill-cargo {
  font-size: 13px;
  color: var(--text-secondary);
}

.waybill-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.waybill-amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--orange);
}

.waybill-amount .unit {
  font-size: 12px;
  font-weight: 400;
}

/* ========== Photo Section ========== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.photo-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: var(--bg-input);
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-item .photo-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 11px;
  text-align: center;
}

/* ========== Camera Specific ========== */
.camera-viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

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

.camera-guide-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.camera-guide-frame {
  width: 80%;
  height: 60%;
  border: 2px dashed rgba(255,255,255,0.6);
  border-radius: 8px;
}

.camera-preview canvas {
  width: 100%;
  border-radius: var(--radius);
}

/* ========== Doc Card ========== */
.doc-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.doc-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.doc-icon.uploaded { background: #f6ffed; }
.doc-icon.pending { background: var(--primary-light); }
.doc-icon.empty { background: #f5f5f5; }

.doc-info { flex: 1; }

.doc-name {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}

.doc-status {
  font-size: 12px;
  color: var(--text-placeholder);
}

.doc-action .btn { height: 36px; padding: 0 16px; font-size: 13px; }

/* ========== Section Header ========== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 8px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
}

.section-badge {
  font-size: 12px;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
}

/* ========== Invoice Specific ========== */
.invoice-status-card {
  text-align: center;
  padding: 24px;
}

.invoice-status-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.invoice-amount-highlight {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  margin: 12px 0;
}

.invoice-amount-highlight .unit {
  font-size: 16px;
  font-weight: 400;
}

/* ========== Utilities ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-placeholder); }

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

.hidden { display: none !important; }
