/**
 * 海外代购 CRM — 自定义样式
 * 文件路径: public/css/app.css
 * 主色: Bootstrap Blue (#0d6efd)，简约商务风格
 */

/* ===== CSS 变量 ===== */
:root {
  --color-primary: #0d6efd;
  --color-primary-dark: #0a58ca;
  --color-primary-light: #cfe2ff;
  --color-sidebar-bg: #1e293b;
  --color-sidebar-hover: #334155;
  --color-sidebar-active: #0d6efd;
  --color-topbar-bg: #ffffff;
  --color-bg: #f1f5f9;
  --color-card: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 0px;
  --topbar-height: 60px;
  --transition-speed: 0.3s;
}

/* ===== 全局 ===== */
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== 侧边栏 ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-sidebar-bg);
  color: #fff;
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition-speed), width var(--transition-speed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  white-space: nowrap;
}

.sidebar-brand i { font-size: 1.4rem; }

.sidebar-menu {
  list-style: none;
  padding: 10px 0;
  margin: 0;
}

.sidebar-menu li { margin: 2px 8px; }

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.sidebar-menu a:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
}

.sidebar-menu a.active {
  background: var(--color-sidebar-active);
  color: #fff;
}

.sidebar-menu a i { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-section-title {
  padding: 15px 20px 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
  white-space: nowrap;
}

/* ===== 主区域 ===== */
#main-wrapper {
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-speed);
  min-height: 100vh;
}

/* ===== 顶部栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  background: var(--color-topbar-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0 20px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 1.2rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-icon:hover { background: var(--color-bg); }

/* ===== 页面内容区 ===== */
.page-content {
  padding: 24px;
  min-height: calc(100vh - var(--topbar-height));
}

/* ===== 登录页 ===== */
.login-page-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 50%, #1e293b 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo i {
  font-size: 3rem;
  color: var(--color-primary);
}

.login-logo h2 {
  margin-top: 10px;
  font-weight: 700;
  color: var(--color-text);
}

/* ===== 卡片 ===== */
.card-stats {
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s;
}

.card-stats:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.card-stats .stat-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 1.4rem;
}

.card-stats .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.card-stats .stat-label {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* ===== 表格美化 ===== */
.table-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
}

.table-card .table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.table-card .table {
  margin-bottom: 0;
}

.table th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  background: #f8fafc;
  border-bottom-width: 1px;
}

.table td {
  vertical-align: middle;
  font-size: 0.9rem;
}

/* ===== 标签徽章 ===== */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s;
}

.tag-badge:hover { opacity: 0.85; }

.tag-badge .tag-remove {
  margin-left: 2px;
  cursor: pointer;
  opacity: 0.7;
}

.tag-badge .tag-remove:hover { opacity: 1; }

/* 优先级 */
.priority-high { background: #dc3545; color: #fff; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; }
.priority-medium { background: #ffc107; color: #000; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; }
.priority-low { background: #0dcaf0; color: #000; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; }
.priority-none { background: #e9ecef; color: #6c757d; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; }

/* 状态 */
.status-active { color: #198754; font-weight: 600; }
.status-inactive { color: #dc3545; }
.status-bounced { color: #fd7e14; }

/* ===== 筛选栏 ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-bar .form-select,
.filter-bar .form-control {
  width: auto;
  min-width: 140px;
}

/* ===== 分页 ===== */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
  gap: 12px;
}

/* ===== 营销模板卡片 ===== */
.template-card {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s;
  background: #fff;
}

.template-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--color-primary);
}

/* ===== 响应式 ===== */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  #main-wrapper {
    margin-left: 0 !important;
  }

  .page-content {
    padding: 16px;
  }

  /* 移动端表格滚动 */
  .table-responsive-stack {
    overflow-x: auto;
  }

  /* 移动端统计卡片 */
  .card-stats .stat-value {
    font-size: 1.4rem;
  }

  /* 移动端筛选栏 */
  .filter-bar .form-select,
  .filter-bar .form-control {
    width: 100%;
  }

  .login-card {
    padding: 24px;
  }
}

@media (max-width: 575.98px) {
  .topbar {
    padding: 0 12px;
  }

  .page-content {
    padding: 12px;
  }

  .table-card .table-header {
    padding: 12px;
  }

  .btn-group-sm-full .btn {
    width: 100%;
    margin-bottom: 4px;
  }
}

/* ===== 遮罩层（手机端侧边栏） ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1035;
}

@media (max-width: 991.98px) {
  .sidebar-overlay.show {
    display: block;
  }
}

/* ===== 上传区域 ===== */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #f8fafc;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

/* ===== 步骤向导 ===== */
.wizard-steps {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.wizard-step.active {
  color: var(--color-primary);
  font-weight: 600;
}

.wizard-step.done {
  color: #198754;
}

.wizard-step .step-number {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-border);
  font-weight: 700;
  font-size: 0.85rem;
}

.wizard-step.active .step-number {
  background: var(--color-primary);
  color: #fff;
}

.wizard-step.done .step-number {
  background: #198754;
  color: #fff;
}

/* ===== 日历 ===== */
.holiday-calendar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.holiday-card {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  background: #fff;
}

.holiday-card .holiday-date {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* ===== 编辑器 ===== */
.template-editor .editor-toolbar {
  border: 1px solid var(--color-border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 8px;
  background: #f8fafc;
}

.template-editor textarea,
.template-editor .editor-preview {
  border: 1px solid var(--color-border);
  border-radius: 0 0 8px 8px;
  min-height: 300px;
  padding: 16px;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
}

/* ===== 加载 spinner ===== */
.spinner-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
