:root {
  --primary-color: #6e8cfb;
  --primary-hover: #5d7ff9;
  --bg-color: #f0f2f5;
  --card-bg: #ffffff;
  --text-color: #333;
  --text-secondary: #666;
  --border-radius: 12px;
  --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  --transition: all 0.3s ease;
}

/* 注意：这里不能设 min-height:100vh。
   本页在 iframe 里运行，父页面会按内容高度调整 iframe 高度；
   若最小高度依赖视口，会与「内容变高 -> iframe 变高 -> 视口变高」形成反馈循环，
   并导致外层出现多余的滚动条。 */
html, body {
  margin: 0;
  background-color: var(--bg-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-color);
}

.admin-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 卡片样式 */
.card-panel {
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  padding: 24px;
  transition: var(--transition);
}

.card-panel:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08); /* 悬浮更加强烈的阴影 */
}

/* 用户信息卡片 */
.user-profile-card {
  display: flex;
  align-items: center;
}

.user-avatar {
  width: 72px !important;
  height: 72px !important;
  flex-shrink: 0;
  border-radius: 50%;
  border: 3px solid #e0e7ff;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: block;
}

.user-info {
  margin-left: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.user-name {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #2c3e50;
}

.user-role {
  margin: 4px 0 0 0;
  font-size: 14px;
  color: var(--text-secondary);
  background-color: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  width: fit-content;
}

/* 表格卡片 */
.table-panel-header {
  margin: 0 0 20px 0;
  padding-left: 10px;
  border-left: 4px solid var(--primary-color);
  font-size: 18px;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1.2;
}

/* 移动端表格滚动条优化 */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}
.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1; 
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: #ddd; 
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #bbb; 
}


.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #f1f3f5;
  background-color: transparent;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  background-color: #fff;
  min-width: 800px; /* 增加宽度，避免挤成一团 */
  white-space: nowrap; /* 表格内容不换行 */
}

.user-table th,
.user-table td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid #f1f3f5;
}

.user-table th {
  background-color: #f8fafc;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

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

.user-table tr:hover {
  background-color: #f8faff;
}

/* 按钮 */
.action-btn {
  background-color: white;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.action-btn:hover {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 2px 6px rgba(110, 140, 251, 0.4);
}

/* 响应式 */
@media (max-width: 768px) {
  .admin-container {
    padding: 10px;
    gap: 15px;
  }
  
  .card-panel {
    padding: 16px;
  }
  
  .user-avatar {
    width: 60px;
    height: 60px;
  }
  
  .user-name {
    font-size: 18px;
  }
  
  .table-panel-header {
    font-size: 16px;
    margin-bottom: 15px;
  }
  
  .user-table th, 
  .user-table td {
    padding: 12px 10px;
    font-size: 13px;
  }
  
  .action-btn {
    padding: 4px 10px;
    font-size: 12px;
  }
}

/* 模态框美化 */
.modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.modal-header {
  border-bottom: 1px solid #f5f5f5;
  padding: 20px 24px;
  background-color: #fff;
}

.modal-title {
  font-weight: 700;
  color: #333;
  font-size: 1.1rem;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  border-top: none;
  padding: 0 24px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* 表单控件优化 */
.modal .form-label {
  font-size: 14px;
  font-weight: 500;
  color: #555;
  margin-bottom: 6px;
}

.modal .form-control,
.modal .form-select {
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  padding: 10px 12px;
  font-size: 14px;
  transition: all 0.2s;
  box-shadow: none;
}

.modal .form-control:focus,
.modal .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(110, 140, 251, 0.15);
}

.modal .form-check-input {
  cursor: pointer;
}

.modal .form-check-label {
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

/* 模态框按钮 */
.modal .btn-secondary {
  background-color: #f1f5f9;
  border: none;
  color: #64748b;
  font-weight: 500;
  padding: 8px 20px;
  border-radius: 8px;
  transition: all 0.2s;
}

.modal .btn-secondary:hover {
  background-color: #e2e8f0;
  color: #475569;
}

.modal .btn-primary {
  background-color: var(--primary-color);
  border: none;
  padding: 8px 20px;
  border-radius: 8px;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(110, 140, 251, 0.3);
  transition: all 0.2s;
}

.modal .btn-primary:active,
.modal .btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(110, 140, 251, 0.4);
}

/* 移动端适配模态框 */
@media (max-width: 576px) {
  .modal-dialog {
    margin: 10px;
  }
  
  .modal-content {
    border-radius: 12px;
  }
  
  .modal-body {
    padding: 16px;
  }
  
  .modal-footer {
    padding: 0 16px 16px;
  }
}

/* ================= 站点外观 ================= */
.site-appearance {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 12px;
}

.appearance-item {
  flex: 1 1 300px;
  min-width: 260px;
}

.appearance-label {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.appearance-preview {
  position: relative;
  width: 100%;
  height: 150px;
  border-radius: 8px;
  border: 1px dashed #c8c8c8;
  background-color: #f5f6f8;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.appearance-empty {
  color: #9aa0a6;
  font-size: 13px;
}

.appearance-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.appearance-hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: #888;
}

/* ================= 数据统计 ================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: #f7f8fa;
  border: 1px solid #eceef2;
  border-radius: 8px;
}

.stat-label {
  font-size: 12px;
  color: #8b909a;
}

.stat-value {
  font-size: 22px;
  font-weight: 600;
  color: #2b3440;
}

.stats-subtitle {
  margin: 20px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.stats-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding: 8px;
  background: #f7f8fa;
  border-radius: 8px;
  overflow: hidden;
}

.stats-bar {
  flex: 1;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #6aa9ff, #3b7ddd);
}

.stats-bar:hover {
  filter: brightness(1.12);
}

.stats-ranking {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: #444;
}

.stats-ranking li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
}

.stats-ranking .rank-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================= 卡片折叠 ================= */
.card-panel.collapsible > .table-panel-header {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-panel.collapsible > .table-panel-header::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid #9aa0a6;
  border-bottom: 2px solid #9aa0a6;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-right: 4px;
}

.card-panel.collapsible.collapsed > .table-panel-header::after {
  transform: rotate(-45deg);
}

/* 折叠后只保留标题行 */
.card-panel.collapsible.collapsed > *:not(.table-panel-header) {
  display: none;
}

/* ================= 用户搜索 ================= */
.user-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0 12px;
}

.user-search {
  flex: 1 1 240px;
  max-width: 360px;
  padding: 8px 12px;
  font-size: 13px;
  color: #2b3440;
  border: 1px solid #dfe3e8;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.user-search:focus {
  border-color: #4a90e2;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.12);
}

.user-count {
  font-size: 12px;
  color: #8b909a;
}

.user-empty {
  text-align: center !important;
  color: #9aa0a6;
  padding: 18px 0;
}

/* 头图文字编辑 */
.hero-editor {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid #e9edf4;
}
.hero-editor-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}
.hero-editor-heading h4 { margin: 0 0 6px; font-size: 16px; font-weight: 700; color: #2c3e50; }
.hero-editor-heading p { margin: 0; color: #778292; font-size: 13px; }
.hero-preview-tag {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: 20px;
  color: #5474d6;
  background: #eef2ff;
  font-size: 12px;
  font-weight: 600;
}
.hero-text-preview {
  position: relative;
  width: 100%;
  max-width: 720px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 10px;
  background: #424c5b url("../img/bc6.webp") center / cover no-repeat;
}
.hero-text-preview .hero-title { font-size: clamp(20px, calc(var(--hero-title-size, 48px) * .7), 55px); }
.hero-text-preview .hero-subtitle { font-size: clamp(12px, calc(var(--hero-subtitle-size, 21px) * .8), 32px); }
.hero-editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.hero-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; color: #425166; font-size: 13px; font-weight: 600; }
.hero-field-wide, .hero-overlay-field { grid-column: 1 / -1; }
.hero-field small { color: #8a95a6; font-weight: 400; }
.hero-field textarea { resize: vertical; min-height: 82px; }
.hero-field input, .hero-field textarea, .hero-field select { font-size: 14px; }
.hero-color { width: 100%; height: 38px; padding: 3px; border: 1px solid #dee2e6; border-radius: 6px; background: #fff; cursor: pointer; }
.hero-overlay-field { max-width: 460px; }
.hero-overlay-field span { display: flex; justify-content: space-between; }
.hero-editor-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
#hero-settings-status { color: #6f7b8b; font-size: 13px; }
#hero-settings-status[data-state="error"] { color: #bd3f3f; }
#hero-settings-status[data-state="success"] { color: #268363; }
@media (max-width: 600px) {
  .hero-editor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  .hero-editor-grid { grid-template-columns: 1fr; }
}
