/* ============================================================
   优惠券计算器 - 现代美观的样式表
   ============================================================ */

/* ==================== CSS 变量 ==================== */
:root {
  --sidebar-width: 240px;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #fff;
  --sidebar-hover: #1e293b;

  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #4338ca;
  --primary-bg: #eef2ff;

  --rose: #f43f5e;
  --rose-bg: #fff1f2;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --emerald: #10b981;
  --emerald-bg: #ecfdf5;

  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --transition: 200ms ease;
}

/* ==================== 基础重置 ==================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ==================== 侧边栏 ==================== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
}

.logo svg { color: var(--primary-light); flex-shrink: 0; }

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-active);
}

.nav-item.active {
  background: rgba(79,70,229,0.15);
  color: var(--sidebar-active);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary-light);
  border-radius: 0 3px 3px 0;
}

.nav-item svg { flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; color: var(--primary-light); }


/* ==================== 主内容区域 ==================== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
  width: calc(100% - var(--sidebar-width));
}

/* ==================== 标签面板 ==================== */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.page-header { margin-bottom: 28px; }

.page-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-desc {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 4px;
}

/* ==================== 统计卡片 ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-blue { background: var(--primary-bg); color: var(--primary); }
.stat-icon-rose { background: var(--rose-bg); color: var(--rose); }
.stat-icon-amber { background: var(--amber-bg); color: var(--amber); }
.stat-icon-emerald { background: var(--emerald-bg); color: var(--emerald); }

.stat-info { display: flex; flex-direction: column; gap: 2px; }

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ==================== 快速开始 ==================== */
.quick-start-card {
  margin-bottom: 28px;
}

.quick-steps {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
}

.step {
  flex: 1;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-content h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.step-content p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.step-arrow {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding-top: 8px;
  color: var(--text-muted);
}

/* ==================== 卡片 ==================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  overflow: hidden;
}

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

.card-header h2 {
  font-size: 17px;
  font-weight: 700;
}

.card-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

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

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

.card-body {
  padding: 24px;
}

.card-body.p-0 { padding: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--primary-bg);
  color: var(--primary);
}

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(79,70,229,0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(79,70,229,0.4);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--text-muted);
}

/* 清空按钮（带危险色） */
.btn-clear {
  color: var(--rose) !important;
  border-color: #fecaca !important;
}

.btn-clear:hover {
  background: var(--rose-bg) !important;
  border-color: var(--rose) !important;
  color: var(--rose) !important;
}

.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-xl { padding: 16px 40px; font-size: 17px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ==================== 表格 ==================== */
.table-container { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:not(.empty-row):hover {
  background: #f8fafc;
}

.table .actions {
  display: flex;
  gap: 6px;
}

.table .btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition);
}

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

.table .btn-icon.edit:hover { color: var(--primary); background: var(--primary-bg); }
.table .btn-icon.delete:hover { color: var(--rose); background: var(--rose-bg); }
.table .btn-icon.view:hover { color: var(--emerald); background: var(--emerald-bg); }

/* ==================== 空状态 ==================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg { margin-bottom: 12px; opacity: 0.5; }

.empty-state p {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state span {
  font-size: 13px;
  margin-top: 4px;
}

/* ==================== 表单 ==================== */
.form { display: flex; flex-direction: column; gap: 20px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.form-input, .form-textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 12px;
  padding-top: 4px;
}

/* ==================== 单选按钮 ==================== */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.radio {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}

.radio input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

/* ==================== 计算摘要 ==================== */
.calc-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 20px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.calc-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.calc-stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.calc-stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.calc-divider {
  width: 1px;
  height: 48px;
  background: var(--border);
}

/* ==================== 计算结果 ==================== */
.result-group {
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.result-group:last-child { margin-bottom: 0; }

.result-group-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
}

.result-group-header.need-extra {
  background: var(--amber-bg);
  color: #92400e;
}

.result-group-header.no-extra {
  background: var(--emerald-bg);
  color: #065f46;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.result-item:hover { background: #f8fafc; }
.result-item:last-child { border-bottom: none; }

.result-item-price {
  font-weight: 700;
  font-size: 18px;
  color: var(--rose);
}

.result-item-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 8px;
}

/* ==================== 结果文本区域 ==================== */
.result-textarea {
  width: 100%;
  min-height: 300px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  background: #f8fafc;
  resize: vertical;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ==================== 模态框 ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  animation: fadeIn 150ms ease;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 200ms ease;
}

.modal-lg { max-width: 720px; }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  padding: 24px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* ==================== Toast 通知 ==================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  pointer-events: auto;
  animation: slideInRight 250ms ease;
  max-width: 380px;
}

.toast-success { border-left: 4px solid var(--emerald); }
.toast-error { border-left: 4px solid var(--rose); }
.toast-info { border-left: 4px solid var(--primary); }

/* ==================== 加载动画 ==================== */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  margin: 24px auto;
}

/* ==================== 隐藏 ==================== */
.hidden { display: none !important; }

/* ==================== 动画 ==================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================== 响应式设计 ==================== */

/* 汉堡菜单按钮 */
.hamburger {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.hamburger:hover {
  background: var(--bg);
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.hamburger svg {
  display: block;
}

/* 侧边栏遮罩层 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
  z-index: 99;
}

/* 批量改显示模式按钮 */
.batch-display-mode {
  display: flex;
  align-items: center;
  gap: 6px;
}

.batch-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.btn-mode {
  padding: 5px 12px !important;
  font-size: 12px !important;
  background: var(--bg) !important;
  color: var(--text-secondary) !important;
  border: 1.5px solid var(--border) !important;
}

.btn-mode:hover {
  background: var(--primary-bg) !important;
  color: var(--primary) !important;
  border-color: var(--primary-light) !important;
}

@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 260px;
    max-width: 75vw;
    z-index: 100;
  }

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

  .sidebar-overlay.show {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 20px;
    padding-top: 64px;
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .quick-steps {
    flex-direction: column;
    gap: 16px;
  }

  .step-arrow {
    display: none;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .card-header-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .batch-display-mode {
    width: auto;
    flex-wrap: wrap;
  }

  .calc-summary {
    flex-direction: column;
    gap: 16px;
  }

  .calc-divider {
    width: 48px;
    height: 1px;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .modal {
    max-width: 100%;
    border-radius: var(--radius);
  }
}
