/* common.css — 高视高清代理商门户共享样式（品牌化 v2） */

/* ─── Design Tokens ──────────────────────────────────── */
:root {
  --brand: #0066CC;
  --brand-dark: #1B3A5C;
  --brand-light: #E8F2FF;
  --gold: #E6B422;
  --gold-light: #FFF8E1;
  --success: #00B894;
  --success-light: #E8F8F5;
  --error: #E74C3C;
  --error-light: #FDEDEC;
  --text: #2C3E50;
  --text-muted: #7F8C8D;
  --border: #E0E6ED;
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --shadow: 0 4px 24px rgba(0,102,204,0.08);
  --shadow-sm: 0 2px 8px rgba(0,102,204,0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --font: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-num: "Montserrat", "SF Pro Display", var(--font);
  --font-mono: "SF Mono", "Menlo", "Consolas", monospace;
}

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

/* ─── Base ────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ──────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(27,58,92,0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header h1 { font-size: 17px; font-weight: 600; }
.header .agent-name { font-size: 13px; opacity: 0.85; margin-left: auto; }
.header .brand-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-num);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
}
.header .brand-logo .gaush { font-weight: 700; }
.header .brand-logo .sep { opacity: 0.5; margin: 0 2px; }
.header .brand-logo .clear { font-weight: 400; opacity: 0.9; }

/* ─── Navigation ──────────────────────────────────── */
.nav {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.nav a {
  padding: 7px 16px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--bg);
  transition: all 0.2s;
}
.nav a.active {
  background: var(--brand);
  color: #fff;
}
.nav a:hover:not(.active) { background: #E8EEF4; }

/* ─── Container ───────────────────────────────────── */
.container { max-width: 800px; margin: 0 auto; padding: 16px; }

/* ─── Card ────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,102,204,0.04);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--brand-dark);
  border-left: 3px solid var(--brand);
  padding-left: 10px;
}
.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ─── Form Fields ─────────────────────────────────── */
.field { margin-bottom: 14px; }
label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
label .req { color: var(--error); }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}
input.error, select.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(231,76,60,0.1);
}
.error-tip {
  font-size: 12px;
  color: var(--error);
  margin-top: 4px;
  display: none;
}
input.error + .error-tip,
select.error + .error-tip { display: block; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 500px) {
  .field-row { grid-template-columns: 1fr; }
}

/* ─── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  min-height: 44px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #0052A3; }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) { background: #009D7F; }

.btn-gold {
  background: linear-gradient(135deg, var(--gold), #F0C040);
  color: var(--brand-dark);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(230,180,34,0.3);
}
.btn-gold:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(230,180,34,0.4); transform: translateY(-1px); }

.btn-outline {
  background: #fff;
  color: var(--brand);
  border: 1px solid #B3D4FF;
}
.btn-outline:hover:not(:disabled) { background: var(--brand-light); }

.btn-text {
  background: none;
  color: var(--brand);
  padding: 4px 8px;
  min-height: auto;
}
.btn-text:hover { background: var(--brand-light); }

.btn-danger {
  background: none;
  color: var(--error);
  padding: 4px 8px;
  min-height: auto;
  font-size: 13px;
}
.btn-danger:hover { background: var(--error-light); }

.btn-block { width: 100%; }

.btn-lg {
  padding: 13px 24px;
  font-size: 16px;
  border-radius: var(--radius-sm);
}

/* ─── Badges ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* 库存状态 */
.badge-instock { background: var(--success-light); color: var(--success); }
.badge-low { background: var(--gold-light); color: #B8860B; }
.badge-out { background: var(--error-light); color: var(--error); }
.badge-custom { background: #F0ECFF; color: #5B3CC4; }

/* 订单状态 */
.badge-pending { background: var(--gold-light); color: #B8860B; }
.badge-review { background: var(--error-light); color: var(--error); }
.badge-producing { background: var(--brand-light); color: var(--brand); }
.badge-shipped { background: var(--success-light); color: var(--success); }
.badge-received { background: #E0F7EA; color: #00875A; }
.badge-done { background: #F0F0F0; color: #8C8C8C; }

/* 交期类型 */
.badge-instock-delivery { background: var(--success-light); color: var(--success); }
.badge-custom-delivery { background: #F0ECFF; color: #5B3CC4; }

/* ─── Toast ───────────────────────────────────────── */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  z-index: 9999;
  display: none;
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
}
.toast.success { background: var(--success-light); border: 1px solid #A3E4D7; color: #006D5B; }
.toast.error { background: var(--error-light); border: 1px solid #F5B7B1; color: #922B21; }
.toast.info { background: var(--brand-light); border: 1px solid #B3D4FF; color: #004085; }

/* ─── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(27,58,92,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 20px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; font-weight: 600; color: var(--brand-dark); }
.modal-close {
  width: 32px; height: 32px;
  border: none; background: var(--bg);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.modal-close:hover { background: #E8EEF4; color: var(--text); }

/* ─── Loading ─────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty State ─────────────────────────────────── */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: #C0C8D4;
  font-size: 14px;
}

/* ─── Stats Bar ───────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.stat-item {
  flex-shrink: 0;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  min-width: 80px;
}
.stat-value {
  font-family: var(--font-num);
  font-size: 20px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.2;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Filter Bar ──────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar select,
.filter-bar input[type="date"] {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: var(--radius-xs);
  width: auto;
  min-width: 100px;
}

/* ─── Pagination ──────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}
.pagination button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  min-height: 36px;
  transition: all 0.2s;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pagination .page-info { font-size: 13px; color: var(--text-muted); }

/* ─── Success Page ────────────────────────────────── */
.success-page {
  display: none;
  text-align: center;
  padding: 40px 20px;
}
.success-icon { font-size: 56px; margin-bottom: 16px; }
.success-page h2 { font-size: 20px; color: var(--success); margin-bottom: 8px; }
.success-page p { color: var(--text-muted); font-size: 14px; line-height: 1.6; }
.success-detail {
  background: var(--success-light);
  border-radius: var(--radius-xs);
  padding: 16px;
  margin: 16px 0;
  text-align: left;
}
.success-detail .item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid rgba(0,184,148,0.15);
}
.success-detail .item:last-child { border-bottom: none; }
.success-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}
.success-actions .btn { min-width: 140px; }

/* ─── Delivery Estimate ───────────────────────────── */
.delivery-estimate {
  display: none;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  margin-top: 6px;
}
.delivery-estimate.show { display: flex; align-items: center; gap: 6px; }
.delivery-estimate.instock { background: var(--success-light); color: var(--success); }
.delivery-estimate.custom { background: #F0ECFF; color: #5B3CC4; }

/* ─── Table (for order detail) ────────────────────── */
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.detail-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.detail-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #F0F4F8;
}
.detail-table tr:last-child td { border-bottom: none; }

/* ─── Order Group Card ────────────────────────────── */
.order-group {
  background: #fff;
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
  border: 1px solid rgba(0,102,204,0.04);
}
.order-group:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.order-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #F0F4F8;
}
.order-group-header .order-no {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
}
.order-group-header .meta {
  font-size: 12px;
  color: var(--text-muted);
}

.order-group-body { padding: 0; }
.order-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #FAFBFC;
  font-size: 13px;
}
.order-item:last-child { border-bottom: none; }
.order-item .left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.order-item .customer { font-weight: 500; color: var(--text); }
.order-item .sku-info { color: var(--text-muted); font-size: 12px; }
.order-item .right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ─── Confirm Modal Summary ──────────────────────── */
.confirm-summary { margin-bottom: 20px; }
.confirm-summary .row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid #F0F4F8;
}
.confirm-summary .row:last-child { border-bottom: none; }
.confirm-summary .row .label { color: var(--text-muted); }
.confirm-summary .row .value { font-weight: 500; }

/* ─── Utility ─────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ─── Print ─────────────────────────────────────────── */
@media print {
  body { background: #fff; }
  .header, .nav, .filter-bar, .pagination, .admin-filter,
  .admin-actions, .no-print { display: none !important; }
  .stats-bar, .admin-stats { page-break-after: avoid; }
  .order-group, .admin-table { break-inside: avoid; }
  .modal-overlay { display: none !important; }
}

/* ─── Delivery Estimate Inline ──────────────────────── */
.delivery-estimate-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}
.delivery-estimate-inline.instock { background: var(--success-light); color: var(--success); }
.delivery-estimate-inline.custom { background: #F0ECFF; color: #5B3CC4; }

/* ─── Logistics Info Card ───────────────────────────── */
.logistics-info {
  background: var(--brand-light);
  border: 1px solid #CCE0FF;
  border-radius: var(--radius-xs);
  padding: 14px;
  margin-top: 16px;
  font-size: 14px;
}
.logistics-info .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,102,204,0.1);
}
.logistics-info .row:last-child { border-bottom: none; }
.logistics-info .label { color: var(--text-muted); }
.logistics-info .value { font-weight: 500; }
.logistics-info .copy-btn {
  background: #fff;
  border: 1px solid #B3D4FF;
  color: var(--brand);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.2s;
}
.logistics-info .copy-btn:hover { background: var(--brand-light); }

/* ─── Search Input ──────────────────────────────────── */
.search-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  min-width: 160px;
}
.search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(0,102,204,0.1);
  outline: none;
}

/* ─── Draft Recovery Bar ────────────────────────────── */
.draft-bar {
  background: var(--gold-light);
  border: 1px solid #FFE082;
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: #8B6914;
}
.draft-bar .actions { display: flex; gap: 8px; flex-shrink: 0; }
.draft-bar .actions button {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid;
}
.draft-bar .restore-btn { background: var(--brand); color: #fff; border-color: var(--brand); }
.draft-bar .discard-btn { background: #fff; color: var(--text-muted); border-color: var(--border); }

/* ─── Overdue Highlight ─────────────────────────────── */
.overdue { color: var(--error) !important; }
.overdue .order-no { color: var(--error) !important; }

/* ─── Promise Date Badge ────────────────────────────── */
.promise-date {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}
.promise-date.on-time { background: var(--success-light); color: var(--success); }
.promise-date.overdue { background: var(--error-light); color: var(--error); }
