/* ================================================================
   蓝氏自动发货系统 - 全局样式
   ================================================================ */

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

:root {
  --primary: #3370ff;
  --primary-hover: #2860e1;
  --primary-light: #e8f0ff;
  --success: #34c759;
  --success-light: #e8f8ed;
  --danger: #f54a45;
  --danger-light: #fde8e8;
  --warning: #ff9500;
  --text: #1f2329;
  --text-secondary: #646a73;
  --text-tertiary: #8f959e;
  --border: #dee0e3;
  --border-light: #f0f1f3;
  --bg: #f5f7fa;
  --bg-white: #ffffff;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-left { flex-shrink: 0; }
.logo { font-size: 18px; font-weight: 700; color: var(--text); }

.header-nav {
  display: flex;
  gap: 4px;
  margin: 0 24px;
  flex: 1;
  justify-content: center;
}

.nav-btn {
  padding: 8px 20px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-btn:hover { background: var(--bg); color: var(--text); }
.nav-btn.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

.header-right { flex-shrink: 0; }
.badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
}

/* ---------- Main Layout ---------- */
.main-container {
  padding: 20px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---------- Order Layout (Two Columns) ---------- */
.order-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .order-layout { grid-template-columns: 1fr; }
  .header-nav { display: none; }
}

/* ---------- Panel ---------- */
.panel {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.panel-header h2 { font-size: 15px; font-weight: 600; }

.panel-products {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);
}

/* ---------- Search ---------- */
.search-box {
  width: 220px;
}
.search-box input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  transition: border var(--transition);
}
.search-box input:focus { border-color: var(--primary); }

/* ---------- Category Tabs ---------- */
.category-tabs {
  display: flex;
  gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto;
  flex-shrink: 0;
}
.cat-tab {
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.cat-tab:hover { color: var(--text); }
.cat-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- Product Grid ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.product-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-white);
  user-select: none;
}
.product-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.product-card.selected { border-color: var(--primary); background: var(--primary-light); }

.product-card input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
}
.product-card .product-info { flex: 1; min-width: 0; }
.product-card .product-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  word-break: break-all;
}
.product-card .product-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.batch-actions {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

/* ---------- Cart ---------- */
.cart-section {
  border-bottom: 1px solid var(--border);
}

.cart-list {
  padding: 12px 20px;
  max-height: 240px;
  overflow-y: auto;
}

.empty-hint {
  color: var(--text-tertiary);
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
}

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-name {
  font-size: 13px;
  flex: 1;
  word-break: break-all;
}
.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin: 0 12px;
}
.cart-item-qty button {
  width: 26px; height: 26px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-white);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.cart-item-qty button:hover { border-color: var(--primary); color: var(--primary); }
.cart-item-qty input {
  width: 36px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 0;
  font-size: 13px;
}
.cart-item-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  flex-shrink: 0;
}
.cart-item-remove:hover { color: var(--danger); }

/* ---------- Address Section ---------- */
.address-section {
  padding: 0 20px 16px;
}
.address-section .panel-header {
  padding: 16px 0;
  border-bottom: none;
}

#addressInput {
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border var(--transition);
  margin-bottom: 12px;
}
#addressInput:focus { border-color: var(--primary); border-style: solid; }

/* ---------- Parsed Fields ---------- */
.parsed-fields {
  margin-top: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}
.field-row:last-child { margin-bottom: 0; }
.field-row-3 { grid-template-columns: 1fr 1fr 1fr; }

.field-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
}
.field-group input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition: border var(--transition);
  background: var(--bg-white);
}
.field-group input:focus { border-color: var(--primary); }
.field-group-full { grid-column: 1 / -1; }
.required { color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary {
  background: var(--bg-white);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-block {
  width: calc(100% - 40px);
  margin: 0 20px 16px;
  justify-content: center;
  padding: 12px;
  font-size: 15px;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-text { background: none; border: none; color: var(--text-tertiary); cursor: pointer; font-size: 13px; }
.btn-text:hover { color: var(--danger); }

/* ---------- Submit Status ---------- */
.submit-status {
  padding: 0 20px 16px;
  text-align: center;
  font-size: 13px;
}
.submit-status.success { color: var(--success); }
.submit-status.error { color: var(--danger); }

/* ---------- History ---------- */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.history-header h2 { font-size: 18px; }

.history-filters {
  display: flex;
  gap: 8px;
  align-items: center;
}
.date-input {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}

.history-table-wrap {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 900px;
}
.history-table th {
  background: var(--bg);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}
.history-table tr:hover td { background: var(--bg); }
.loading { color: var(--text-tertiary); text-align: center; padding: 40px; }

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.status-badge.pending { background: #fff3e0; color: #e65100; }
.status-badge.shipped { background: #e3f2fd; color: #1565c0; }
.status-badge.done { background: #e8f5e9; color: #2e7d32; }

.btn-danger-sm {
  padding: 3px 10px;
  font-size: 12px;
  border: 1px solid var(--danger);
  background: var(--bg-white);
  color: var(--danger);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-danger-sm:hover { background: var(--danger-light); }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}
.pagination button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  cursor: pointer;
  font-size: 13px;
}
.pagination button:hover { border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { font-size: 13px; color: var(--text-secondary); }

/* ---------- Report ---------- */
.report-content {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.summary-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}
.summary-card .label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.report-section { margin-bottom: 24px; }
.report-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.report-table th {
  background: var(--bg);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
}
.report-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: 70px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 12px 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---------- Checkbox label ---------- */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox-label input { accent-color: var(--primary); }

/* ---------- Login Page ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 48px 40px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  text-align: center;
}

.login-logo { font-size: 56px; margin-bottom: 12px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; color: var(--text); }
.login-subtitle { color: var(--text-tertiary); font-size: 14px; margin-bottom: 28px; }

.login-form { text-align: left; }
.login-form .input-group { margin-bottom: 18px; }
.login-form .input-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.login-form .input-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border var(--transition);
}
.login-form .input-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(51,112,255,0.1); }
.login-error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 8px; min-height: 20px; }

/* ---------- Bundle Tag ---------- */
.bundle-tag {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
  font-weight: 600;
}

/* ---------- Batch Info ---------- */
.batch-info {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-left: 12px;
}

/* ---------- Main App ---------- */
/* ---------- Portal Selection ---------- */
.portal-options {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 8px;
}

.portal-card {
  flex: 1;
  padding: 24px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
  background: var(--bg-white);
}

.portal-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(51,112,255,0.15);
  transform: translateY(-2px);
}

.portal-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.portal-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.portal-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.portal-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.5;
}

.login-back {
  text-align: left;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 16px;
  display: inline-block;
  transition: color var(--transition);
}
.login-back:hover { color: var(--primary); }

/* ---------- Main App ---------- */
.main-app { display: block; }
