/* ========================================
   车辆管理系统 - 移动优先样式
   宁波轿运友通汽车服务有限公司
   ======================================== */

/* ============ 变量 ============ */
:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-bg: #eff6ff;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --expired: #991b1b;
  --expired-light: #fecaca;

  --bg: #f0f2f5;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-2: #6b7280;
  --text-3: #9ca3af;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);

  --nav-height: 60px;
  --bottom-nav-height: 64px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
  min-height: 100vh;
}

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

/* ============ 顶部导航 ============ */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  color: var(--text);
  border-radius: var(--radius-sm);
}

.menu-toggle:active { background: var(--bg); }

.top-nav-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.top-nav-sub {
  font-size: 11px;
  color: var(--text-3);
  display: block;
  margin-top: -1px;
}

.top-nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--primary-bg);
  color: var(--primary);
  font-family: inherit;
  white-space: nowrap;
}

.nav-btn:active { opacity: 0.7; }

/* ============ 侧边栏菜单 ============ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
}

.sidebar-overlay.open { display: block; }

.sidebar {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100vh;
  background: var(--card);
  z-index: 201;
  transition: left 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.sidebar.open { left: 0; }

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.sidebar-brand span {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-3);
  display: block;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  color: var(--text-2);
  font-size: 15px;
  text-decoration: none;
  transition: all 0.1s;
  border-radius: 0;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
}

.sidebar-link:active { background: var(--primary-bg); }
.sidebar-link.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 500;
}

.sidebar-icon {
  width: 24px;
  text-align: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
}

/* ============ 底部导航 ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 100;
  padding: 0 4px;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  color: var(--text-3);
  font-size: 11px;
  text-decoration: none;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.bottom-nav-item:active { opacity: 0.6; }
.bottom-nav-item.active { color: var(--primary); }

.bottom-nav-icon {
  font-size: 22px;
  line-height: 1;
}

/* ============ 主内容区 ============ */
.main-content {
  padding: 16px;
  max-width: 800px;
  margin: 0 auto;
}

/* ============ 页面头部 ============ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ============ 卡片 ============ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}

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

/* ============ 统计卡片网格 ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.stat-card.total::before { background: var(--primary); }
.stat-card.expired::before { background: var(--expired); }
.stat-card.alert::before { background: var(--danger); }
.stat-card.warning-card::before { background: var(--warning); }
.stat-card.normal-card::before { background: var(--success); }
.stat-card.rented::before { background: var(--primary-light); }
.stat-card.idle-card::before { background: var(--text-3); }

.stat-label {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 4px;
  font-weight: 500;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-card.total .stat-value { color: var(--primary); }
.stat-card.expired .stat-value { color: var(--expired); }
.stat-card.alert .stat-value { color: var(--danger); }
.stat-card.warning-card .stat-value { color: var(--warning); }
.stat-card.normal-card .stat-value { color: var(--success); }
.stat-card.rented .stat-value { color: var(--primary-light); }
.stat-card.idle-card .stat-value { color: var(--text-2); }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.12s;
  font-family: inherit;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { opacity: 0.7; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:active { background: var(--bg); }

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  min-height: 36px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

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

/* ============ 表单 ============ */
.form-group { margin-bottom: 18px; }

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

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

.form-error {
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--danger-light);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--danger);
}

/* ============ 列表/卡片列表 ============ */
.item-list { display: flex; flex-direction: column; gap: 10px; }

.item-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.1s;
}

.item-card:active { background: var(--bg); }

.item-left { flex: 1; min-width: 0; }

.item-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.item-sub {
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-right {
  flex-shrink: 0;
  margin-left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============ 表格 ============ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  border-bottom: 2px solid var(--border);
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.table tr:active td { background: #f9fafb; }

/* ============ 标签/徽章 ============ */
.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--primary-bg); color: var(--primary); }
.badge-gray { background: #f3f4f6; color: var(--text-2); }
.badge-expired { background: var(--expired-light); color: var(--expired); }

/* ============ 租赁状态切换 ============ */
.rental-toggle {
  display: inline-flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.rental-btn {
  padding: 6px 16px;
  font-size: 13px;
  border: none;
  background: #f3f4f6;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
  min-height: 34px;
}

.rental-btn:active { opacity: 0.7; }
.rental-btn.active.idle { background: var(--success); color: #fff; }
.rental-btn.active.rented { background: var(--primary); color: #fff; }

/* ============ 保险到期日期 ============ */
.ins-date {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.4;
  font-weight: 600;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--border);
}

.ins-date small { font-weight: 400; font-size: 11px; margin-top: 2px; }

.ins-normal { background: var(--success-light); border-left-color: var(--success); color: var(--success); }
.ins-warning { background: var(--warning-light); border-left-color: var(--warning); color: #b45309; }
.ins-urgent { background: #ffedd5; border-left-color: #f97316; color: #c2410c; }
.ins-critical { background: var(--danger-light); border-left-color: var(--danger); color: var(--danger); }
.ins-expired { background: var(--expired-light); border-left-color: var(--expired); color: var(--expired); font-weight: 700; }

/* 移动端概览小标签 */
.ins-badge-expired { background: var(--expired-light); color: var(--expired); }
.ins-badge-critical { background: var(--danger-light); color: var(--danger); }
.ins-badge-urgent { background: #ffedd5; color: #c2410c; }
.ins-badge-warning { background: var(--warning-light); color: #b45309; }
.ins-badge-normal { background: var(--success-light); color: var(--success); }

/* ============ 上传区域 ============ */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbfc;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-zone:active { border-color: var(--primary); background: var(--primary-bg); }
.upload-zone.dragging { border-color: var(--primary); background: var(--primary-bg); }

.upload-icon { font-size: 36px; color: var(--text-3); margin-bottom: 10px; }
.upload-text { font-size: 15px; color: var(--text-2); margin-bottom: 4px; }
.upload-hint { font-size: 12px; color: var(--text-3); }

.upload-preview { margin-top: 12px; }
.upload-preview img { max-width: 100%; max-height: 200px; border-radius: var(--radius-sm); }

.upload-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  color: var(--primary);
  font-size: 14px;
}

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

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

/* ============ 预警列表 ============ */
.alert-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  border-left: 4px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alert-card.expired { background: var(--expired-light); border-left-color: var(--expired); }
.alert-card.critical { background: var(--danger-light); border-left-color: var(--danger); }
.alert-card.urgent { background: var(--warning-light); border-left-color: var(--warning); }
.alert-card.warning { background: var(--warning-light); border-left-color: var(--warning); }
.alert-card.normal { background: var(--success-light); border-left-color: var(--success); }

.alert-plate { font-weight: 600; font-size: 15px; }
.alert-info { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.alert-days { font-weight: 700; font-size: 18px; }

/* ============ 空状态 ============ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-size: 15px; margin-bottom: 4px; }
.empty-hint { font-size: 13px; color: var(--text-3); }

/* ============ 信息横幅 ============ */
.info-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.info-bar.success { background: var(--success-light); border-color: var(--success); }
.info-bar.warning { background: var(--warning-light); border-color: var(--warning); }
.info-bar strong { font-weight: 600; }

/* ============ 车辆详情页 ============ */
.detail-section { margin-bottom: 20px; }

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

.detail-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.detail-label {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 2px;
}

.detail-value {
  font-size: 15px;
  font-weight: 500;
}

.file-link {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--primary-bg);
  border-radius: 6px;
  font-weight: 500;
  transition: background 0.15s;
  word-break: break-all;
}
.file-link:hover, .file-link:active {
  background: #dbeafe;
}

/* ============ 分割线 ============ */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ============ 登录页 ============ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #1d4ed8 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.05) 0%, transparent 50%),
              radial-gradient(circle at 70% 50%, rgba(255,255,255,0.03) 0%, transparent 50%);
}

.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 40px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.login-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

.login-form .form-group { margin-bottom: 20px; }

.login-form .form-label {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.login-form .form-input {
  padding: 14px 16px;
  font-size: 15px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px solid var(--border);
}

.login-form .form-input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 8px;
  transition: opacity 0.15s;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.login-btn:active { opacity: 0.85; }

.login-error {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  padding: 12px;
  background: var(--danger-light);
  border-radius: 10px;
  margin-bottom: 16px;
}

/* ============ 桌面端覆盖 ============ */
@media (min-width: 768px) {
  body { padding-bottom: 0; }

  .top-nav { display: none; }

  .sidebar {
    left: 0 !important;
    width: 240px;
  }

  .sidebar-overlay { display: none !important; }

  .main-content {
    margin-left: 240px;
    padding: 28px 32px;
    max-width: none;
  }

  .bottom-nav { display: none; }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-grid.grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }

  .login-page {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #1d4ed8 100%);
  }

  .stat-card {
    padding: 24px 20px;
  }

  .stat-value { font-size: 30px; }
}

@media (min-width: 1024px) {
  .stats-grid.grid-6 {
    grid-template-columns: repeat(6, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
