/* ====== 暗夜剧场 — 管理后台 ====== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;700;900&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg-base: #0f1620;
  --bg-card: rgba(19, 30, 46, 0.82);
  --bg-elevated: rgba(22, 34, 52, 0.92);
  --bg-input: rgba(16, 26, 40, 0.7);
  --text: #e2ddd5;
  --text-secondary: #8e99a8;
  --text-muted: #5a6577;
  --primary: #c9a96e;
  --primary-dark: #b8944f;
  --primary-light: #e2c891;
  --accent: #5db8a3;
  --accent-dark: #459e8a;
  --danger: #d66878;
  --danger-dark: #b84a5c;
  --warning: #e8a838;
  --border: rgba(100, 130, 170, 0.15);
  --border-focus: rgba(201, 169, 110, 0.35);
  --shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.2);
  --focus: 0 0 0 3px rgba(201, 169, 110, 0.2);
  --radius: 16px;
  --radius-sm: 12px;
  --font-display: 'Noto Serif SC', 'Georgia', serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
  --transition: all 0.2s ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 900px 500px at 10% 20%, rgba(201, 169, 110, 0.06) 0%, transparent 70%),
    radial-gradient(ellipse 700px 400px at 90% 10%, rgba(93, 184, 163, 0.05) 0%, transparent 60%),
    linear-gradient(170deg, #0c1219, var(--bg-base) 40%, #111d2c);
  min-height: 100vh;
  background-attachment: fixed;
}

.admin-wrap {
  max-width: 1120px;
  margin: 36px auto;
  padding: 0 18px 26px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

#loginCard {
  max-width: 460px;
  margin: 60px auto 0;
  text-align: center;
}

#loginCard h1 {
  font-family: var(--font-display);
  background: linear-gradient(135deg, var(--primary-light), var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 26px;
  margin-bottom: 6px;
}

#loginCard .form-row {
  text-align: left;
}

.hidden {
  display: none;
}

h1,
h2 {
  margin-top: 0;
  color: var(--text);
}

h1 {
  letter-spacing: 0.4px;
  font-family: var(--font-display);
}

h2 {
  font-size: 18px;
  letter-spacing: 0.2px;
  color: var(--primary-light);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.panel-block {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
}

.section-tip {
  color: var(--text-muted);
  font-size: 12px;
}
.health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.health-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: rgba(16, 26, 40, 0.6);
  transition: var(--transition);
}

.health-item:hover {
  border-color: var(--border-focus);
}

.health-label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.health-value {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--primary-light);
  font-variant-numeric: tabular-nums;
}

.form-row {
  margin-bottom: 14px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus);
  background: rgba(20, 32, 50, 0.9);
}

textarea {
  font-family: var(--font-mono);
  resize: vertical;
}

select {
  cursor: pointer;
}

select option {
  background: #1a2840;
  color: var(--text);
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.mode-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.mode-switch .active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #1a1410;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(201, 169, 110, 0.25);
  font-weight: 600;
}

.edit-status {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 13px;
  background: rgba(93, 184, 163, 0.08);
  border: 1px solid rgba(93, 184, 163, 0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .2s ease, color .2s ease, border-color .2s ease;
  position: relative;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #1a1410;
  box-shadow: 0 8px 20px rgba(201, 169, 110, 0.25);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 10px 28px rgba(201, 169, 110, 0.35);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), var(--danger-dark));
  color: #fff;
  box-shadow: 0 8px 18px rgba(214, 104, 120, 0.2);
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 0 10px 24px rgba(214, 104, 120, 0.3);
}

.btn-ghost {
  background: rgba(22, 33, 48, 0.6);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(30, 44, 62, 0.8);
  border-color: var(--border-focus);
  color: var(--text);
}

.tip {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 0;
}

.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.search-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.search-row select {
  flex: 0 0 170px;
  width: 170px;
  min-width: 170px;
}

.search-row .btn {
  flex: 0 0 auto;
}

.script-list {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--text);
  max-height: 400px;
  overflow: auto;
}

.script-list li {
  margin-bottom: 10px;
}

.script-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(16, 26, 40, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: var(--transition);
}

.script-item:hover {
  border-color: var(--border-focus);
  background: rgba(20, 32, 50, 0.7);
}

.script-meta {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.script-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.visual-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.v-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(16, 26, 40, 0.5);
}

.v-card h3,
.v-card h4 {
  margin: 0 0 8px;
  color: var(--primary-light);
  font-family: var(--font-display);
}

.v-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.v-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.v-row.wrap {
  flex-wrap: wrap;
}

.v-muted {
  color: var(--text-muted);
  font-size: 12px;
}

.v-inline-label {
  min-width: 60px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.v-block {
  border: 1px dashed rgba(100, 130, 170, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 8px;
  background: rgba(12, 20, 32, 0.4);
  position: relative;
}

/* 层级色条指示: 幕=金 地点=青 线索=白 */
.v-block {
  border-left: 3px solid rgba(201, 169, 110, 0.3);
}

.v-block .v-block {
  border-left-color: rgba(93, 184, 163, 0.3);
}

.v-block .v-block .v-block {
  border-left-color: rgba(200, 210, 225, 0.2);
}

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: rgba(19, 30, 46, 0.96);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  opacity: 0;
  pointer-events: none;
  transition: all .28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  z-index: 60;
  font-size: 14px;
  max-width: 500px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: rgba(214, 104, 120, 0.4);
  color: var(--danger);
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 18, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 16px;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  width: min(760px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  animation: modalEnter 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
}
.modal-body {
  padding: 4px 14px 14px;
}
.modal-close {
  background: transparent;
  border: 0;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: var(--transition);
}

.modal-close:hover {
  background: rgba(214, 104, 120, 0.12);
  color: var(--danger);
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-filter {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.history-filter-action {
  flex: 0 0 170px;
  width: 170px;
  min-width: 170px;
}
.history-filter input {
  flex: 1 1 auto;
  min-width: 0;
}
.history-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: rgba(16, 26, 40, 0.5);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  transition: var(--transition);
}

.history-item:hover {
  border-color: var(--border-focus);
}

.history-meta {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.script-list::-webkit-scrollbar {
  width: 6px;
}

.script-list::-webkit-scrollbar-thumb {
  background: rgba(100, 130, 160, 0.2);
  border-radius: 3px;
}

.script-list::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 130, 160, 0.35);
}

.script-list::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 768px) {
  .admin-wrap {
    margin-top: 16px;
    padding: 0 12px 20px;
  }

  .card {
    border-radius: var(--radius-sm);
    padding: 16px;
  }

  .panel-header,
  .toolbar,
  .mode-switch,
  .v-grid,
  .section-head,
  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .v-grid {
    display: flex;
  }

  .script-item,
  .history-item {
    flex-direction: column;
    align-items: stretch;
  }

  .history-filter {
    flex-direction: column;
    align-items: stretch;
  }

  .history-filter-action {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
  }

  .health-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .script-actions {
    justify-content: flex-end;
  }

  .search-row select {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
  }
}

/* ====== 按钮加载态 ====== */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(200, 200, 200, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: adminSpin 0.6s linear infinite;
  left: 50%;
  top: 50%;
  margin: -8px 0 0 -8px;
}

.btn-primary.is-loading::after { border-top-color: #1a1410; }
.btn-danger.is-loading::after { border-top-color: #fff; }

@keyframes adminSpin {
  to { transform: rotate(360deg); }
}

/* ====== 编辑区展开动画 ====== */
#editorSection {
  animation: editorSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes editorSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== 工具栏优化 ====== */
.toolbar {
  justify-content: flex-end;
}

.toolbar .btn-ghost {
  margin-right: auto;
}

/* ====== 面板入场动画 ====== */
.panel-block {
  animation: panelFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.panel-block:nth-child(1) { animation-delay: 0.05s; }
.panel-block:nth-child(2) { animation-delay: 0.12s; }
.panel-block:nth-child(3) { animation-delay: 0.19s; }

@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== 登录卡品牌Logo ====== */
.login-brand {
  font-size: 48px;
  margin-bottom: 10px;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(201, 169, 110, 0.2));
}

.back-to-site {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 8px 20px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(15, 22, 32, 0.5);
  backdrop-filter: blur(6px);
  transition: var(--transition);
  letter-spacing: 1px;
}

.back-to-site:hover {
  color: var(--primary-light);
  border-color: var(--primary);
  background: rgba(201, 169, 110, 0.08);
}

.back-to-site-icon {
  font-size: 15px;
  transition: transform 0.3s ease;
}

.back-to-site:hover .back-to-site-icon {
  transform: translateX(-3px);
}

/* ====== 全局滚动条 ====== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 130, 160, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 130, 160, 0.3);
}

/* ====== Placeholder ====== */
::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}
