/* ========================================
   盒饭接龙系统 - 移动端优先样式
   ======================================== */

:root {
  --primary: #e74c3c;
  --primary-dark: #c0392b;
  --success: #27ae60;
  --warning: #f39c12;
  --bg: #f5f5f5;
  --card: #ffffff;
  --text: #2c3e50;
  --text-secondary: #7f8c8d;
  --border: #ecf0f1;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

/* Header */
.app-header {
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.app-header h1 {
  font-size: 17px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* Tabs */
.tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 48px;
  z-index: 99;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex: 1;
  min-width: fit-content;
  padding: 12px 8px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

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

/* Main content */
.main-content {
  padding: 16px;
  max-width: 800px;
  margin: 0 auto;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Textarea */
.textarea-wrapper {
  position: relative;
}

textarea {
  width: 100%;
  min-height: 160px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.8;
  resize: vertical;
  background: #fafafa;
  transition: border-color 0.2s;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

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

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

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

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

/* Order items */
.order-list {
  list-style: none;
}

.order-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border-left: 3px solid var(--primary);
}

.order-item.unpaid {
  border-left-color: var(--warning);
}

.order-item.paid {
  border-left-color: var(--success);
}

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.order-name {
  font-weight: 600;
  font-size: 15px;
}

.order-time {
  font-size: 11px;
  color: var(--text-secondary);
}

.order-dishes {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.meta-tag {
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}

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

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Summary table */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.summary-table th,
.summary-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.summary-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-table .amount {
  text-align: right;
}

.summary-table .highlight {
  font-weight: 600;
  color: var(--primary);
}

/* Delivery sheet */
.delivery-group {
  margin-bottom: 20px;
}

.delivery-group-title {
  font-size: 15px;
  font-weight: 700;
  color: white;
  background: var(--primary);
  padding: 8px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  justify-content: space-between;
}

.delivery-group .order-item {
  border-radius: 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.delivery-group .order-item:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Payment status badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-paid {
  background: #d5f5e3;
  color: #1e8449;
}

.badge-unpaid {
  background: #fdebd0;
  color: #b9770e;
}

.badge-weekly {
  background: #d6eaf8;
  color: #2471a3;
}

/* ============ 置信度标签 ============ */
.badge-confidence {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
  vertical-align: middle;
}

.badge-high {
  background: #d5f5e3;
  color: #1e8449;
}

.badge-medium {
  background: #fdebd0;
  color: #b9770e;
}

.badge-low {
  background: #fadbd8;
  color: #c0392b;
}

/* ============ 桌面快捷方式引导 ============ */
.desktop-guide {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.6;
}

.desktop-guide strong {
  color: #856404;
}

.desktop-guide .btn-close-guide {
  float: right;
  background: none;
  border: none;
  color: #856404;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
}

/* ============ 别名映射表 ============ */
.alias-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.alias-table th,
.alias-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.alias-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
}

.alias-table input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}

.alias-table input:focus {
  outline: none;
  border-color: var(--primary);
}

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

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

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  background: white;
  -webkit-appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237f8c8d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Print styles */
@media print {
  .app-header,
  .tabs,
  .btn,
  .no-print {
    display: none !important;
  }

  body {
    background: white;
    font-size: 12px;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }

  .order-item {
    break-inside: avoid;
  }

  .delivery-group-title {
    background: #333 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .main-content {
    padding: 0;
    max-width: 100%;
  }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #2c3e50;
  color: white;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

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

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: white;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

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

/* Section divider */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* Login page */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.login-card {
  background: white;
  border-radius: 12px;
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--primary);
}

.login-subtitle {
  font-size: 14px;
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Responsive */
@media (min-width: 768px) {
  .main-content {
    padding: 24px;
  }

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