/* ==================== 通用增强样式 ==================== */

/* ===== 深色模式变量 ===== */
body.dark-mode {
  --primary: #BE3B31;
  --primary-light: #6B241D;
  --primary-dark: #D26254;
  --accent: #BE3B31;
  --green: #10b981;
  --green-light: #064e3b;
  --orange: #f59e0b;
  --orange-light: #451a03;
  --red: #ef4444;
  --red-light: #450a0a;
  --gray-50: #1f2937;
  --gray-100: #374151;
  --gray-200: #4b5563;
  --gray-300: #6b7280;
  --gray-500: #9ca3af;
  --gray-600: #d1d5db;
  --gray-700: #e5e7eb;
  --gray-900: #f3f4f6;
  --slate-50: #0f172a;
  --slate-100: #1e293b;
  --slate-200: #334155;
  --slate-300: #475569;
  --slate-400: #64748b;
  --slate-500: #94a3b8;
  --slate-600: #cbd5e1;
  --slate-700: #e2e8f0;
  --slate-800: #f1f5f9;
  --slate-900: #f8fafc;
  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --bg-card: rgba(31, 41, 55, 0.8);
  --text-primary: #f3f4f6;
  --text-secondary: #d1d5db;
  --border-color: #374151;
}

body.dark-mode {
  background: var(--bg-primary);
  color: var(--text-primary);
}

body.dark-mode .card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
}

body.dark-mode .input-wrap input,
body.dark-mode .input-wrap select {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

body.dark-mode .input-wrap input:focus,
body.dark-mode .input-wrap select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

body.dark-mode .top-nav .tabs {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

body.dark-mode .top-nav .tab-btn {
  color: var(--gray-500);
}

body.dark-mode .top-nav .tab-btn:hover {
  background: var(--gray-50);
  color: var(--primary);
}

body.dark-mode .top-nav .tab-btn.active {
  background: var(--primary);
  color: #fff;
}

body.dark-mode .items-row:nth-child(odd) {
  background: var(--gray-50);
}

body.dark-mode .items-row.total-row {
  background: var(--primary-light);
  border-color: var(--primary);
}

body.dark-mode .result-card {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

body.dark-mode .formula-box {
  background: var(--gray-50);
  color: var(--text-secondary);
}

body.dark-mode .preset-btn {
  background: var(--gray-50);
  color: var(--primary-dark);
  border-color: var(--border-color);
}

body.dark-mode .preset-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* ===== 加载动画 ===== */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: var(--border-radius);
  z-index: 100;
}

body.dark-mode .loading-overlay {
  background: rgba(17, 24, 39, 0.9);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 13px;
  color: var(--gray-500);
}

/* ===== 主题切换按钮 ===== */
.theme-toggle {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--gray-100);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.theme-toggle:hover {
  background: var(--gray-200);
  transform: scale(1.05);
}

body.dark-mode .theme-toggle {
  background: var(--gray-50);
}

/* ===== 操作按钮组 ===== */
.action-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.action-btn {
  padding: 8px 14px;
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-700);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.action-btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.action-btn.primary:hover {
  background: var(--primary-dark);
}

.action-btn.danger {
  color: var(--red);
  border-color: #fecaca;
}

.action-btn.danger:hover {
  background: #fef2f2;
}

body.dark-mode .action-btn {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

body.dark-mode .action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ===== 历史记录面板 ===== */
.history-panel {
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--gray-50);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item:hover {
  background: var(--primary-light);
}

.history-item .hi-time {
  font-size: 11px;
  color: var(--gray-500);
}

.history-item .hi-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.history-item .hi-del {
  opacity: 0;
  color: var(--red);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  transition: opacity 0.2s;
}

.history-item:hover .hi-del {
  opacity: 1;
}

body.dark-mode .history-item {
  background: var(--gray-50);
}

body.dark-mode .history-item:hover {
  background: var(--primary-light);
}

/* ===== 方案对比模态框 ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 900px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

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

body.dark-mode .modal-content {
  background: var(--bg-secondary);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-100);
  border-radius: 6px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
}

.modal-close:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

/* ===== 对比表格 ===== */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.compare-table th,
.compare-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--gray-100);
}

.compare-table th:first-child,
.compare-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
}

.compare-table th {
  background: var(--gray-50);
  font-weight: 700;
  color: var(--gray-700);
}

.compare-table tr:hover td {
  background: var(--primary-light);
}

.compare-table .diff-pos {
  color: var(--green);
}

.compare-table .diff-neg {
  color: var(--red);
}

body.dark-mode .compare-table th,
body.dark-mode .compare-table td {
  border-bottom-color: var(--border-color);
}

body.dark-mode .compare-table th {
  background: var(--gray-50);
}

/* ===== 术语提示 ===== */
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-600);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  margin-left: 4px;
  position: relative;
}

.tooltip-icon:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

.tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  z-index: 1000;
  transition: opacity 0.2s;
  margin-bottom: 6px;
  min-width: 120px;
  text-align: center;
}

.tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--gray-900);
}

/* ===== 标签页切换增强 ===== */
.tab-btns {
  display: flex;
  gap: 2px;
  background: var(--gray-100);
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.tab-btn-sm {
  flex: 1;
  padding: 6px 0;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn-sm.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

body.dark-mode .tab-btns {
  background: var(--gray-50);
}

body.dark-mode .tab-btn-sm.active {
  background: var(--bg-secondary);
}

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

.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 10px;
  opacity: 0.5;
}

.empty-state .empty-text {
  font-size: 13px;
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}

body.dark-mode ::-webkit-scrollbar-track {
  background: var(--gray-50);
}

body.dark-mode ::-webkit-scrollbar-thumb {
  background: var(--gray-200);
}

/* ===== 响应式增强 ===== */
@media (max-width: 768px) {
  .action-btn {
    padding: 10px 12px;
    font-size: 13px;
  }
  
  .modal-content {
    width: 95%;
    padding: 16px;
    max-height: 90vh;
  }
}
