/* ==========================================================================
   万州长江珍稀水生生物科普馆 · 内容管理系统
   设计令牌 + 基础样式 + 组件样式
   ========================================================================== */

:root {
  color-scheme: light;

  /* 品牌色 */
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft: #eff6ff;
  --brand-border: #bfdbfe;
  --brand-ring: rgba(37, 99, 235, 0.14);

  /* 中性色 */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e8ebf0;
  --border-strong: #d6dbe4;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #98a2b3;

  /* 语义色 */
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --success-text: #14532d;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-text: #b42318;
  --danger-border: #fecaca;

  /* 侧边栏 */
  --sidebar-bg: #101828;
  --sidebar-text: #98a2b3;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: #1d2939;
  --sidebar-line: rgba(255, 255, 255, 0.08);

  /* 圆角 */
  --radius-sm: 6px;
  --radius: 9px;
  --radius-lg: 13px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 18px 44px rgba(16, 24, 40, 0.16);

  --sidebar-width: 248px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden {
  display: none !important;
}

/* ---------- 按钮 ---------- */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  padding: 9px 16px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  background: var(--brand-strong);
}

button:active {
  transform: translateY(0.5px);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-ring);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

button.secondary:hover {
  background: var(--surface-muted);
  border-color: #c2cad6;
}

button.danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

button.danger:hover {
  background: #fee4e2;
  border-color: #fda29b;
}

button svg.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

/* ---------- 表单控件 ---------- */

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 8px 11px;
  font: inherit;
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-subtle);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

textarea {
  resize: vertical;
  line-height: 1.7;
}

input[type="checkbox"] {
  width: auto;
  accent-color: var(--brand);
}

/* ==========================================================================
   登录页
   ========================================================================== */

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(circle at 15% 0%, #e4ecfb 0%, transparent 55%),
    radial-gradient(circle at 100% 100%, #e2f4f8 0%, transparent 50%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 32px 30px 30px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.login-brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.login-brand p {
  margin: 1px 0 0;
  color: var(--text-muted);
  font-size: 12.5px;
}

.login-card form {
  display: grid;
  gap: 14px;
}

.login-card form label {
  display: grid;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
}

.login-card form button {
  margin-top: 6px;
  padding: 11px 16px;
  font-size: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.brand-mark svg {
  width: 19px;
  height: 19px;
}

/* ==========================================================================
   主布局
   ========================================================================== */

.admin-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- 侧边栏 ---------- */

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100vh;
  padding: 18px 14px 16px;
  overflow-y: auto;
  background: var(--sidebar-bg);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 16px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--sidebar-line);
}

.sidebar-brand .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.brand-text strong {
  color: #fff;
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.brand-text small {
  color: #8b98ad;
  font-size: 11px;
}

.sidebar-title {
  padding: 0 8px;
  margin-bottom: 6px;
  color: #667085;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
}

.tabs button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tabs button svg.icon {
  width: 17px;
  height: 17px;
  opacity: 0.85;
}

.tabs button:hover {
  background: var(--sidebar-hover-bg);
  color: #e4e7ec;
}

.tabs button.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  font-weight: 600;
}

.tabs button.active svg.icon {
  opacity: 1;
  color: #60a5fa;
}

.tabs button.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: #3b82f6;
  transform: translateY(-50%);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-line);
}

.sidebar-footer button {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-weight: 500;
}

.sidebar-footer button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* ---------- 内容区 ---------- */

.content-area {
  min-width: 0;
  max-width: 1360px;
  padding: 26px 30px 72px;
}

.panel {
  display: none;
  padding: 24px 26px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel.active {
  display: block;
}

.panel > h2,
.panel-header h2 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.panel-header > div {
  min-width: 0;
}

.panel-header h2 {
  margin-bottom: 6px;
}

.panel-header .panel-desc {
  margin-bottom: 0;
}

.panel-desc {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.75;
}

.subsection-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 26px 0 14px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}

.subsection-title::before {
  content: "";
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: var(--brand);
}

.panel > .subsection-title:first-of-type {
  margin-top: 20px;
}

/* ---------- 表单卡片 ---------- */

.form-card {
  padding: 18px 18px 16px;
  margin-bottom: 22px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
  margin: 0;
}

.grid-form label {
  display: grid;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
}

.grid-form .full {
  grid-column: 1 / -1;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-strong);
}

.inline-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.inline-input input[type="file"] {
  max-width: 220px;
  padding: 7px 9px;
  border-style: dashed;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12.5px;
}

.inline-input input[type="file"]::file-selector-button {
  margin-right: 8px;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.grid-form label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: end;
  padding-bottom: 9px;
  cursor: pointer;
}

.checkbox input {
  width: auto;
  margin: 0;
}

/* ---------- 富文本 ---------- */

.editor {
  min-height: 240px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.editor:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.ql-toolbar.ql-snow {
  border: 0 !important;
  border-bottom: 1px solid var(--border) !important;
  background: var(--surface-muted);
  padding: 7px 10px !important;
}

.ql-container.ql-snow {
  border: 0 !important;
  font-family: inherit;
  font-size: 14px;
}

.ql-editor {
  min-height: 260px;
  line-height: 1.85;
}

.ql-editor.ql-blank::before {
  color: var(--text-subtle);
  font-style: normal;
}

/* ---------- 表格 ---------- */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 10px 14px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fafbfd;
}

tbody td[colspan] {
  padding: 34px 14px;
  color: var(--text-subtle);
  font-size: 13px;
  text-align: center;
}

.intro-cell,
td.text-cell {
  max-width: 260px;
}

.table-text-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}

.table-empty {
  color: var(--text-subtle);
  font-size: 12.5px;
}

td img {
  display: block;
  width: 96px;
  height: 60px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-muted);
}

.no-image {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 60px;
  border: 1px dashed var(--border-strong);
  border-radius: 7px;
  background: var(--surface-muted);
  color: var(--text-subtle);
  font-size: 12px;
}

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

.actions button {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
}

.homepage-sort {
  width: 76px;
}

/* ---------- 图片预览 ---------- */

.cover-preview {
  min-height: 0;
}

.cover-preview img {
  display: block;
  width: 132px;
  height: 82px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.cover-preview .no-image {
  width: 132px;
  height: 82px;
}

/* ---------- 每周推荐 ---------- */

.weekly-recommend-form {
  margin: 0;
}

.weekly-recommend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.weekly-recommend-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
}

.weekly-recommend-grid select {
  width: 100%;
}

/* ---------- 分页 ---------- */

.pagination {
  margin-top: 16px;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.pagination-bar .pages {
  display: flex;
  gap: 4px;
}

.pagination-bar button {
  min-width: 32px;
  padding: 6px 10px;
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
}

.pagination-bar button:hover {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-strong);
}

.pagination-bar button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.pagination-bar .ellipsis {
  padding: 6px 2px;
  color: var(--text-subtle);
  font-size: 12.5px;
}

.pagination-info {
  padding: 10px;
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
}

.pagination-bar .pagination-info {
  margin-left: 6px;
  padding: 0;
  text-align: left;
}

/* ---------- 提示条 ---------- */

.message {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 4000;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 13.5px;
  animation: toast-in 0.22s ease both;
}

.message-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  border-left-color: var(--success);
  color: var(--success-text);
}

.message-error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  border-left-color: var(--danger);
  color: var(--danger-text);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- 弹窗 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(16, 24, 40, 0.5);
}

.modal-card {
  width: min(880px, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-strong);
}

.picker-section {
  margin-bottom: 16px;
}

.picker-section h4 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.picker-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.picker-item {
  display: grid;
  grid-template-columns: auto 76px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.picker-item:hover {
  background: var(--brand-soft);
  border-color: var(--brand-border);
}

.picker-item.selected {
  opacity: 0.5;
  cursor: default;
}

.picker-item.selected:hover {
  background: var(--surface);
  border-color: var(--border);
}

.picker-item input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.picker-item img,
.picker-item .no-image {
  width: 76px;
  height: 48px;
  border-radius: 6px;
}

.picker-item .meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.picker-item .meta strong {
  font-size: 13.5px;
  font-weight: 600;
}

.picker-item .meta span {
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- 滚动条 ---------- */

.sidebar::-webkit-scrollbar,
.picker-list::-webkit-scrollbar,
.modal-card::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.16);
}

.picker-list::-webkit-scrollbar-thumb,
.modal-card::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: #d3d9e2;
}

.sidebar::-webkit-scrollbar-track,
.picker-list::-webkit-scrollbar-track,
.modal-card::-webkit-scrollbar-track {
  background: transparent;
}

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 960px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .tabs {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .tabs button {
    width: auto;
    padding: 8px 12px;
  }

  .tabs button.active::before {
    display: none;
  }

  .sidebar-footer {
    margin-top: 14px;
  }

  .sidebar-footer button {
    width: auto;
  }

  .content-area {
    padding: 20px 16px 56px;
  }
}

@media (max-width: 720px) {
  .grid-form {
    grid-template-columns: 1fr;
  }

  .inline-input {
    grid-template-columns: 1fr;
  }

  .inline-input input[type="file"] {
    max-width: none;
  }

  .panel {
    padding: 18px 16px 20px;
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .message {
    top: 12px;
    right: 12px;
    left: 12px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
