/* =========================================
   AI Chat Platform - Global Styles
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;600;700&display=swap');
/* 标题字体：马善政楷书(国风) + Cinzel(英文衬线)，text= 自动子集化，极轻量 */
@import url('https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=Cinzel:wght@400;500&text=%E9%80%8D%E5%8B%BE%20AI%20%E6%9C%BA%E5%99%A8%E4%BA%BAXIAOGOUCUP%20BOT&display=swap');

/* ===== 日间主题（默认） ===== */
:root {
  --bg-primary: #f5f0e6;
  --bg-secondary: #ece5d8;
  --bg-tertiary: #e2dace;
  --bg-hover: #d8d0c2;
  --bg-active: #d0c8b8;
  --bg-card: #f0ebe0;
  --border: #d4c9b4;
  --border-light: #c8bca4;

  --text-primary: #3d3528;
  --text-secondary: #6b6052;
  --text-muted: rgba(107,96,82,0.55);

  --accent: #8a7e5a;
  --accent-hover: #9d9068;
  --accent-glow: rgba(138,126,90,0.12);
  --accent-text: #6b6040;

  --success: #5a8a5a;
  --warning: #b8942a;
  --danger: #b85a4a;
  --info: #4a7a8a;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow-sm: 0 2px 8px rgba(60,50,30,0.08);
  --shadow-md: 0 4px 24px rgba(60,50,30,0.1);
  --shadow-lg: 0 8px 48px rgba(60,50,30,0.15);

  --user-bubble: #8a7e5a;
  --user-bubble-text: #fff;
  --msg-avatar-bg: linear-gradient(135deg, #8a7e5a, #b8a878);
}

/* ===== 夜间主题 ===== */
[data-theme="dark"] {
  --bg-primary: #141210;
  --bg-secondary: #1c1916;
  --bg-tertiary: #24201c;
  --bg-hover: #2e2924;
  --bg-active: #38322c;
  --bg-card: #1a1714;
  --border: #2e2924;
  --border-light: #3d362e;

  --text-primary: #e8e2d8;
  --text-secondary: #a89e8e;
  --text-muted: rgba(168,158,142,0.5);

  --accent: #a08860;
  --accent-hover: #b8a070;
  --accent-glow: rgba(160,136,96,0.12);
  --accent-text: #c8b888;

  --success: #6aaa6a;
  --warning: #d4a840;
  --danger: #c86a5a;
  --info: #5a9aaa;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);

  --user-bubble: #6a5a3e;
  --user-bubble-text: #f0ead8;
  --msg-avatar-bg: linear-gradient(135deg, #7a6a48, #a89060);
}
/* 深色模式下logo图标提亮 */
[data-theme="dark"] img[src*="logo.svg"] {
  filter: brightness(1.6) saturate(0.8);
}
[data-theme="dark"] img[src*="hebao.svg"] {
  filter: brightness(1.4) saturate(0.7);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* =========== 滚动条 =========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* =========== 按钮 =========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.btn-danger {
  background: rgba(255,71,87,0.1);
  color: var(--danger);
  border: 1px solid rgba(255,71,87,0.2);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(255,71,87,0.2);
}
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* =========== 输入框 =========== */
.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input::placeholder {
  color: var(--text-muted);
}

textarea.input {
  resize: vertical;
  min-height: 80px;
}

/* =========== 徽章 =========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: rgba(46,213,115,0.15); color: var(--success); }
.badge-warning { background: rgba(255,165,2,0.15); color: var(--warning); }
.badge-danger  { background: rgba(255,71,87,0.15); color: var(--danger); }
.badge-info    { background: rgba(84,160,255,0.15); color: var(--info); }

/* =========== Toast 通知 =========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }

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

/* =========== 模态框 =========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.25s ease;
}
.modal-overlay.active .modal {
  transform: translateY(0);
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}
.modal-body {
  margin-bottom: 20px;
  max-height: 60vh;
  overflow-y: auto;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* =========== 表格 =========== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tr:hover td {
  background: var(--bg-hover);
}
tr:last-child td {
  border-bottom: none;
}

/* =========== 分页 =========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}
.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
.pagination button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.pagination button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.pagination span {
  color: var(--text-muted);
  font-size: 13px;
}

/* =========== 加载动画 =========== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.typing-dots::after {
  content: '';
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
}

/* =========== 表单组 =========== */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-row {
  display: flex;
  gap: 10px;
}

/* =========== 空状态 =========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}
.empty-state p {
  font-size: 15px;
}

/* =========== 工具类 =========== */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* =========== FA 图标统一尺寸 =========== */
.btn i.fa-solid, .btn i.fa-regular { font-size: 1.15em; }
.btn-sm i.fa-solid, .btn-sm i.fa-regular { font-size: 1.1em; }
.btn-icon i.fa-solid { font-size: 16px; }
.form-group label i.fa-solid { font-size: 14px; }
.nav-item i.fa-solid { font-size: 19px; }

/* =========== Select 下拉框美化 =========== */
select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239898b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.2px;
}
select.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
select.input option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 10px 14px;
  font-weight: 500;
  font-size: 14px;
}

/* =========== 移动端全局 =========== */
@media (max-width: 768px) {
  /* Toast 移到顶部居中 */
  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }
  .toast {
    max-width: 100%;
    font-size: 13px;
    padding: 10px 16px;
  }

  /* 模态框 */
  .modal {
    width: 94%;
    padding: 20px;
    max-height: 85vh;
    overflow-y: auto;
  }
  .modal-title { font-size: 16px; }
  .modal-body { margin-bottom: 16px; }
  .form-group { margin-bottom: 12px; }
  .form-group label { font-size: 12px; }
  .input { padding: 10px 12px; font-size: 14px; }
  textarea.input { min-height: 60px; }

  /* 按钮更大的触控区域 */
  .btn { padding: 10px 16px; font-size: 13px; }
  .btn-sm { padding: 7px 12px; font-size: 12px; }
  .btn-icon { width: 38px; height: 38px; }

  /* 表格 */
  .table-wrap { font-size: 12px; }
  th, td { padding: 8px 8px; font-size: 12px; }
  th { font-size: 11px; }

  /* 分页 */
  .pagination { flex-wrap: wrap; }
  .pagination span { font-size: 12px; }
}
