/* ========================================
   智汇寄件系统 - 统一样式
   简洁商务风 · 移动端优先 · 适配钉钉工作台
   ======================================== */

:root {
  /* 主题色 */
  --primary: #1677FF;
  --primary-light: #E6F0FF;
  --primary-dark: #0958D9;
  --success: #00B578;
  --success-light: #E8F8F0;
  --warning: #FF8F1F;
  --warning-light: #FFF3E0;
  --danger: #FF3141;
  --danger-light: #FFE8EA;
  --info: #1677FF;
  --info-light: #E6F0FF;

  /* 中性色 */
  --text-primary: #1A1A1A;
  --text-secondary: #666666;
  --text-placeholder: #999999;
  --text-disabled: #CCCCCC;
  --border: #E5E5E5;
  --border-light: #F0F0F0;
  --bg-page: #F5F6FA;
  --bg-white: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-hover: #F7F8FA;

  /* 间距 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --spacing-xxl: 24px;

  /* 圆角 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-round: 999px;

  /* 字号 */
  --font-xs: 11px;
  --font-sm: 13px;
  --font-md: 15px;
  --font-lg: 17px;
  --font-xl: 20px;
  --font-xxl: 24px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);

  /* 布局 */
  --header-height: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: var(--font-md);
  color: var(--text-primary);
  background-color: var(--bg-page);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

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

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

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

/* ====== 页面布局 ====== */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 顶部导航栏 */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-lg);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

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

.header-back {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 20px;
  border-radius: var(--radius-sm);
}

.header-back:active {
  background: var(--bg-hover);
}

.header-action {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--font-md);
  border-radius: var(--radius-sm);
}

/* 内容区域 */
.content {
  flex: 1;
  padding: var(--spacing-lg);
  padding-bottom: calc(var(--spacing-lg) + var(--safe-bottom));
}

/* ====== 卡片 ====== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
}

/* ====== 表单 ====== */
.form-group {
  margin-bottom: var(--spacing-lg);
}

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

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 44px;
  padding: 0 var(--spacing-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  font-size: var(--font-md);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

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

.form-input:disabled,
.form-select:disabled {
  background: var(--bg-hover);
  color: var(--text-disabled);
}

.form-textarea {
  height: auto;
  min-height: 80px;
  padding: var(--spacing-md);
  resize: vertical;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-hint {
  font-size: var(--font-xs);
  color: var(--text-placeholder);
  margin-top: var(--spacing-xs);
}

.form-error {
  font-size: var(--font-xs);
  color: var(--danger);
  margin-top: var(--spacing-xs);
}

/* 单选按钮组 */
.radio-group {
  display: flex;
  gap: var(--spacing-md);
}

.radio-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-md);
  transition: all 0.2s;
  background: var(--bg-white);
}

.radio-item.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

.radio-item input {
  display: none;
}

/* ====== 按钮 ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 var(--spacing-xl);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  opacity: 0.8;
  transform: scale(0.98);
}

.btn-block {
  width: 100%;
}

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

.btn-primary:active {
  background: var(--primary-dark);
}

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

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

.btn-danger {
  background: var(--danger);
  color: #FFF;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-ghost:active {
  background: var(--primary-light);
}

.btn-sm {
  height: 32px;
  padding: 0 var(--spacing-md);
  font-size: var(--font-sm);
  border-radius: var(--radius-sm);
}

.btn-xs {
  height: 28px;
  padding: 0 var(--spacing-sm);
  font-size: var(--font-xs);
  border-radius: var(--radius-sm);
}

.btn-disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ====== 标签 ====== */
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-round);
  font-size: var(--font-xs);
  font-weight: 500;
  white-space: nowrap;
}

.tag-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.tag-success {
  background: var(--success-light);
  color: var(--success);
}

.tag-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.tag-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.tag-info {
  background: var(--info-light);
  color: var(--info);
}

.tag-default {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* ====== 首页菜单网格 ====== */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl) var(--spacing-md);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text-primary);
}

.menu-item:active {
  transform: scale(0.96);
  box-shadow: var(--shadow-md);
}

.menu-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-sm);
  font-size: 24px;
}

.menu-icon.blue { background: var(--primary-light); color: var(--primary); }
.menu-icon.green { background: var(--success-light); color: var(--success); }
.menu-icon.orange { background: var(--warning-light); color: var(--warning); }
.menu-icon.red { background: var(--danger-light); color: var(--danger); }

.menu-text {
  font-size: var(--font-sm);
  font-weight: 500;
}

.menu-desc {
  font-size: var(--font-xs);
  color: var(--text-placeholder);
  margin-top: 2px;
}

/* ====== 列表 ====== */
.list-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s;
}

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

.list-item:last-child {
  border-bottom: none;
}

.list-body {
  flex: 1;
  min-width: 0;
}

.list-title {
  font-size: var(--font-md);
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-subtitle {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

.list-extra {
  flex-shrink: 0;
  margin-left: var(--spacing-md);
  text-align: right;
}

.list-arrow {
  flex-shrink: 0;
  margin-left: var(--spacing-sm);
  color: var(--text-disabled);
  font-size: 14px;
}

/* ====== 筛选栏 ====== */
.filter-bar {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  height: 32px;
  padding: 0 var(--spacing-md);
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-round);
  font-size: var(--font-sm);
  color: var(--text-secondary);
  background: var(--bg-white);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-chip.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* ====== 空状态 ====== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xxl) 0;
  color: var(--text-placeholder);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: var(--spacing-md);
}

.empty-text {
  font-size: var(--font-md);
}

/* ====== 用户信息卡 ====== */
.user-card {
  display: flex;
  align-items: center;
  padding: var(--spacing-lg);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-lg);
  color: #FFF;
  margin-bottom: var(--spacing-lg);
}

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-xl);
  font-weight: 600;
  margin-right: var(--spacing-md);
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: var(--font-lg);
  font-weight: 600;
}

.user-dept {
  font-size: var(--font-sm);
  opacity: 0.85;
  margin-top: 2px;
}

.user-role {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-round);
  font-size: var(--font-xs);
  margin-top: var(--spacing-xs);
}

/* ====== 订单卡片 ====== */
.order-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  box-shadow: var(--shadow-sm);
}

.order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-md);
}

.order-no {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  font-family: "SF Mono", "Menlo", monospace;
}

.order-body {
  margin-bottom: var(--spacing-md);
}

.order-row {
  display: flex;
  font-size: var(--font-sm);
  margin-bottom: var(--spacing-xs);
}

.order-label {
  color: var(--text-placeholder);
  width: 72px;
  flex-shrink: 0;
}

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

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

.order-time {
  font-size: var(--font-xs);
  color: var(--text-placeholder);
}

.order-actions {
  display: flex;
  gap: var(--spacing-sm);
}

/* ====== 弹窗/模态框 ====== */
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-mask.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  background: var(--bg-white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--spacing-lg);
  padding-bottom: calc(var(--spacing-lg) + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
}

.modal-mask.visible .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-lg);
}

.modal-title {
  font-size: var(--font-lg);
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-hover);
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-secondary);
}

/* ====== Toast 提示 ====== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #FFF;
  padding: var(--spacing-md) var(--spacing-xl);
  border-radius: var(--radius-md);
  font-size: var(--font-md);
  z-index: 999;
  text-align: center;
  max-width: 80%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.toast.visible {
  opacity: 1;
}

/* ====== 加载 ====== */
.loading-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xxl);
}

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

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

/* ====== 底部安全区 ====== */
.safe-bottom {
  height: var(--safe-bottom);
}

/* ====== 搜索框 ====== */
.search-bar {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 var(--spacing-md);
  background: var(--bg-hover);
  border-radius: var(--radius-round);
  margin-bottom: var(--spacing-md);
}

.search-icon {
  color: var(--text-placeholder);
  margin-right: var(--spacing-sm);
  font-size: 16px;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: var(--font-md);
  height: 100%;
}

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

/* ====== 统计栏 ====== */
.stat-row {
  display: flex;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.stat-item {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: var(--font-xxl);
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: var(--font-xs);
  color: var(--text-secondary);
  margin-top: var(--spacing-xs);
}

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

/* ====== 文本工具 ====== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-secondary { color: var(--text-secondary); }
.text-placeholder { color: var(--text-placeholder); }
.text-sm { font-size: var(--font-sm); }
.text-xs { font-size: var(--font-xs); }
.font-bold { font-weight: 600; }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

/* ====== 响应式 ====== */
@media (min-width: 480px) {
  .content {
    max-width: 500px;
    margin: 0 auto;
  }
}

/* ====== 页面切换动画 ====== */
.page-enter {
  animation: pageIn 0.25s ease-out;
}

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

/* ====== 钉钉适配 ====== */
body.dd-embedded {
  --header-height: 44px;
}

/* 下拉刷新占位 */
.pull-refresh {
  text-align: center;
  padding: var(--spacing-md);
  color: var(--text-placeholder);
  font-size: var(--font-sm);
}
