/* ========== 全局样式 ========== */
:root {
  --primary: #1a237e;
  --primary-dark: #0d1642;
  --primary-light: #3949ab;
  --accent: #f9a825; /* 安平橙 */
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-500: #adb5bd;
  --gray-700: #495057;
  --gray-900: #212529;
  --radius: 10px;
  --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", "Microsoft YaHei", sans-serif;
  background: var(--gray-100); color: var(--gray-900);
  line-height: 1.6; font-size: 14px;
}

/* ========== 顶部导航栏（Banner） ========== */
.topbar {
  height: 60px;
  /* 安平物流货车背景图 */
  background-image: url('/header_bg.jpg');
  background-size: cover;
  background-position: center;
  border-bottom: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; position: fixed; top: 0; left: 0; right: 0; z-index: 100;
}
/* 顶部栏文字暗化层 */
.topbar::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(13, 22, 66, 0.20) 0%, rgba(26, 35, 126, 0.15) 50%, rgba(57, 73, 171, 0.08) 100%);
  z-index: -1;
}
.topbar-left .logo { font-size: 24px; font-weight: 700; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.4); letter-spacing: 1px; }
.topbar-right { display: flex; align-items: center; gap: 16px; flex-direction: column; align-items: flex-end; }
.user-info { color: rgba(255,255,255,0.9); font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,0.3); margin-bottom: 4px; }

.btn-logout {
  padding: 6px 16px; background: rgba(255,255,255,0.15); color: #fff;
  border: 1px solid rgba(255,255,255,0.35); border-radius: 20px; cursor: pointer;
  font-size: 13px; transition: all 0.2s;
  backdrop-filter: blur(4px);
}
.btn-logout:hover { background: rgba(231,76,60,0.8); border-color: transparent; }

/* ========== 布局 ========== */
.main-layout { display: flex; margin-top: 60px; min-height: calc(100vh - 60px); }

.sidebar {
  width: 200px; background: #fff; border-right: 1px solid var(--gray-200);
  padding: 16px 0; position: fixed; top: 60px; left: 0; bottom: 0;
  overflow-y: auto; z-index: 50;
}
.nav-item {
  padding: 11px 24px; display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 14px; color: var(--gray-700);
  transition: all 0.15s; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--gray-100); color: var(--primary); }
.nav-item.active { background: #eef0ff; color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 16px; }

.content {
  margin-left: 200px; flex: 1; padding: 28px 32px; max-width: 1200px;
}

/* ========== 页面切换 ========== */
.page { display: none; animation: fadeIn 0.25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; margin-bottom: 4px; }
.page-desc { color: var(--gray-500); font-size: 13px; }

/* ========== 按钮 ========== */
.btn-primary {
  padding: 9px 18px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius); cursor: pointer;
  font-size: 13px; font-weight: 500; transition: background 0.2s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--gray-300); cursor: not-allowed; }
.btn-secondary {
  padding: 9px 18px; background: #7c3aed; color: #fff;
  border: none; border-radius: var(--radius);
  cursor: pointer; font-size: 13px; transition: all 0.2s; white-space: nowrap;
}
.btn-secondary:hover { background: #6d28d9; }
.btn-success { background: #16a34a; color: #fff; border: none; padding: 6px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: #d97706; color: #fff; border: none; padding: 6px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.btn-warning:hover { background: #b45309; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { background: var(--danger); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; padding: 5px 12px; font-size: 12px; }
.btn-danger:hover { background: #c0392b; }
.btn-info { background: #2563eb; color: #fff; border: none; border-radius: var(--radius); cursor: pointer; padding: 5px 12px; font-size: 12px; }
.btn-info:hover { background: #1d4ed8; }

/* ========== 导入预览表格 ========== */
.import-preview { margin-top: 16px; }
.import-preview h4 { font-size: 14px; color: var(--gray-700); margin-bottom: 8px; }
#importPreviewTable { width: 100%; border-collapse: collapse; font-size: 13px; }
#importPreviewTable th { background: var(--gray-100); padding: 8px 12px; text-align: left; border-bottom: 2px solid var(--gray-300); color: var(--gray-700); font-weight: 600; }
#importPreviewTable td { padding: 6px 12px; border-bottom: 1px solid var(--gray-200); }
#importPreviewTable tr:hover { background: var(--gray-100); }
.btn-danger:hover { opacity: 0.85; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type="text"] {
  flex: 1; min-width: 200px; padding: 8px 14px; border: none;
  border-radius: var(--radius); outline: none; font-size: 13px;
}
.toolbar input:focus { border-color: var(--primary); }

/* ========== 表格 ========== */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table th { background: var(--gray-100); padding: 12px 16px; text-align: left; font-size: 13px; color: var(--gray-700); font-weight: 600; border-bottom: 2px solid var(--gray-200); }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--gray-200); font-size: 13px; vertical-align: middle; }
.data-table tr:hover td { background: #fafbfe; }
.empty-row { text-align: center; color: var(--gray-500); padding: 40px !important; }
.webhook-cell { font-family: monospace; font-size: 12px; color: var(--gray-500); max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.status-active { background: #d4edda; color: #155724; }
.status-inactive { background: #f8d7da; color: #721c24; }
.tag-badge { display: inline-block; padding: 2px 10px; background: #eef0ff; color: var(--primary); border-radius: 12px; font-size: 12px; }

.action-btns { display: flex; gap: 6px; }

/* ========== 推送页面 ========== */
.push-container { display: grid; gap: 20px; }

.editor-section { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.form-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; color: var(--gray-900); }
.required { color: var(--danger); }

.editor-section textarea {
  width: 100%; padding: 14px; border: none;
  border-radius: var(--radius); font-size: 14px; resize: vertical;
  outline: none; font-family: inherit; line-height: 1.7;
}
.editor-section textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(102,126,234,0.12); }

.signature-row { margin-top: 14px; }
.signature-row input {
  width: 100%; max-width: 400px; padding: 10px 14px; border: none;
  border-radius: var(--radius); font-size: 13px; outline: none;
}
.signature-row input:focus { border-color: var(--primary); }

.supplier-section { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.supplier-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; flex-wrap: wrap; gap: 10px;
}
.filter-group { display: flex; gap: 8px; align-items: center; }
.filter-group select, .filter-group input[type="text"] {
  padding: 7px 12px; border: none;
  border-radius: 8px; font-size: 13px; outline: none;
}
.filter-group select { width: 130px; }
.filter-group input { width: 180px; }

.supplier-list {
  max-height: 360px; overflow-y: auto; border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 4px 0;
}
.supplier-list.compact { max-height: 240px; }
.supplier-item {
  display: flex; align-items: center; padding: 9px 16px;
  border-bottom: 1px solid var(--gray-100); transition: background 0.1s;
}
.supplier-item:last-child { border-bottom: none; }
.supplier-item:hover { background: var(--gray-100); }
.supplier-item input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer;
  flex-shrink: 0;
}
.supplier-item-info { margin-left: 12px; flex: 1; min-width: 0; }
.supplier-item-name { font-size: 14px; font-weight: 500; }
.supplier-item-tag { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

.supplier-count { text-align: center; color: var(--gray-500); font-size: 13px; margin-top: 10px; }

.loading-hint { text-align: center; color: var(--gray-500); padding: 30px; }

/* ========== 操作按钮区 ========== */
.action-bar {
  display: flex; justify-content: flex-end; gap: 12px; padding: 16px 0;
}
.btn-preview {
  padding: 12px 28px; background: #7c3aed; color: #fff;
  border: none; border-radius: var(--radius);
  cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.2s;
}
.btn-preview:hover { background: var(--gray-100); border-color: var(--gray-500); }

.btn-send {
  padding: 12px 36px; background: var(--success); color: #fff;
  border: none; border-radius: var(--radius); cursor: pointer;
  font-size: 15px; font-weight: 600; transition: all 0.2s;
  letter-spacing: 1px;
}
.btn-send:hover:not(:disabled) { background: #219a52; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(39,174,96,0.35); }
.btn-send:disabled { background: var(--gray-300); cursor: not-allowed; transform: none; box-shadow: none; }
.btn-send.sending { background: var(--warning); color: #fff; }

/* ========== 卡片列表 ========== */
.card-list { display: grid; gap: 16px; }

.log-card {
  background: #fff; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.log-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.card-title { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.card-time { font-size: 12px; color: var(--gray-500); }
.card-body { font-size: 13px; color: var(--gray-700); line-height: 1.6; max-height: 60px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gray-200); }
.card-stats { display: flex; gap: 16px; font-size: 13px; }
.stat-success { color: var(--success); font-weight: 600; }
.stat-fail { color: var(--danger); font-weight: 600; }
.card-actions { display: flex; gap: 8px; }

.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 24px; }
.page-btn {
  padding: 7px 14px; border: none; border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 13px; transition: all 0.15s;
}
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:hover:not(.active) { background: var(--gray-100); }
.page-btn:disabled { color: var(--gray-300); cursor: not-allowed; }

/* ========== 设置页面 ========== */
.settings-card { background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.settings-card h3 { font-size: 16px; margin-bottom: 18px; color: var(--gray-900); }
.setting-row { margin-bottom: 16px; }
.setting-row label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--gray-700); }
.setting-row input[type="text"] {
  width: 100%; max-width: 450px; padding: 10px 14px; border: none;
  border-radius: var(--radius); font-size: 13px; outline: none;
}
.setting-note { display: block; font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.setting-actions { margin-top: 8px; }
.sys-info { display: grid; gap: 8px; }
.info-row { font-size: 13px; color: var(--gray-700); }
.info-row span { color: var(--gray-500); display: inline-block; width: 80px; }

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45); z-index: 999; display: flex;
  align-items: center; justify-content: center;
}
.modal-content {
  background: #fff; border-radius: 14px; max-width: 520px;
  width: 90%; max-height: 85vh; overflow-y: auto; animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 720px; }
.modal-md { max-width: 480px; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  background: none; border: none; font-size: 24px; cursor: pointer;
  color: var(--gray-500); line-height: 1;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--gray-200);
  display: flex; justify-content: flex-end; gap: 10px;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--gray-700); }
.form-group input, .form-group textarea {
  width: 100%; padding: 10px 14px; border: none;
  border-radius: 8px; font-size: 13px; outline: none;
  font-family: inherit; resize: vertical;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }
.preview-box {
  background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 16px; font-size: 14px;
  white-space: pre-wrap; line-height: 1.7; max-height: 350px; overflow-y: auto;
}

/* ========== Toast 提示 ========== */
.toast {
  position: fixed; top: 74px; right: 24px; padding: 12px 24px;
  border-radius: var(--radius); font-size: 14px; font-weight: 500;
  z-index: 9999; transform: translateX(120%); transition: transform 0.3s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.toast.show { transform: translateX(0); }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.info { background: var(--primary); color: #fff; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  /* 顶栏压缩 */
  .topbar { height: 48px; padding: 0 12px; }
  .topbar::before { display: none; }
  .topbar-left .logo { font-size: 15px; letter-spacing: 0; text-shadow: 0 1px 3px rgba(0,0,0,0.4); }
  .topbar-right { flex-direction: row; gap: 8px; }
  .user-info { display: none; }
  .btn-logout { padding: 4px 12px; font-size: 12px; }
  /* 主布局让位 */
  .main-layout { margin-top: 48px; min-height: calc(100vh - 48px); }
  /* 侧边栏 → 顶部水平滚动 tab 条 */
  .sidebar {
    position: fixed; top: 48px; left: 0; right: 0; bottom: auto;
    width: 100%; height: 42px; padding: 0 4px;
    display: flex !important; flex-direction: row;
    overflow-x: auto; overflow-y: hidden;
    background: #fff;
    border-right: none; border-bottom: 1px solid var(--gray-200);
    z-index: 50;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar::-webkit-scrollbar { height: 2px; }
  .nav-item {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 13px;
    border-left: none !important;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }
  .nav-item.active {
    border-left: none !important;
    border-bottom-color: var(--primary);
    background: #eef0ff;
  }
  /* 主内容全宽 */
  .content { margin-left: 0; padding: 14px 12px; max-width: 100%; }
  .page-header h2 { font-size: 18px; }
  .page-desc { font-size: 12px; }
  /* 表单/工具栏/卡片头：纵向堆叠 */
  .supplier-toolbar, .push-toolbar { flex-direction: column; align-items: stretch; }
  .filter-group { flex-wrap: wrap; }
  .card-header { flex-direction: column; gap: 4px; }
  /* 表格/列表：横向滚动 */
  .table-wrap, .supplier-list, .logs-table, .supplier-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 12px; }
  th, td { padding: 6px 8px; white-space: nowrap; }
  /* 按钮略小 */
  .btn-primary, .btn-secondary { font-size: 12px; padding: 6px 12px; }
  /* 模态弹窗全屏化 */
  .modal, .modal-content, .modal-box {
    width: 96vw !important; max-width: 96vw !important;
    max-height: 90vh;
    left: 2vw !important; right: 2vw !important;
    margin: 4vh auto !important;
  }
}


/* 供应商列表项（div模式） */
.supplier-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}
.supplier-item:hover { background: #f8f9fa; }
.supplier-item-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.supplier-item-left input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
.supplier-item-left .supplier-name { font-size: 14px; font-weight: 500; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.supplier-item-left .supplier-tag { font-size: 11px; background: #e8f4fd; color: #1976d2; padding: 2px 8px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; }
.supplier-item-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.supplier-item-right .webhook-info { font-size: 12px; white-space: nowrap; }
.empty-hint { text-align: center; color: #999; padding: 40px 20px; font-size: 14px; }

/* 星期/日期选择 chip 标签 */
.chip-label { display: inline-flex; align-items: center; gap:4px; padding:4px 10px; border:1px solid var(--gray-300); border-radius:15px; cursor:pointer; font-size:12px; color:var(--gray-700); background:#fff; transition:all 0.2s; user-select:none; }
.chip-label:has(:checked) { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.chip-label input { accent-color: #7c3aed; }

/* 操作列统一居中 */
.col-actions { text-align: center; white-space: nowrap; width: 140px; }
.col-actions .btn-sm { margin: 0 3px; vertical-align: middle; }
