/* ==========================================
   admin.css — 后台面板完整样式
   复用 base.css 的 CSS 变量和 glass.css 的模态框模式
   ========================================== */

/* ====== 认证区 ====== */
.auth-section {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--color-bg);
}
.auth-card {
  text-align: center; padding: 40px; max-width: 360px; width: 100%;
}
.auth-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 24px; color: var(--color-text); }
.auth-input {
  width: 100%; padding: 12px 16px; border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px; font-size: 1rem; outline: none; text-align: center;
  transition: border-color 0.2s; box-sizing: border-box;
}
.auth-input:focus { border-color: var(--color-accent); }
.auth-btn {
  margin-top: 16px; padding: 10px 40px; border: none; border-radius: 10px;
  background: var(--color-accent); color: #fff; font-size: 0.95rem; cursor: pointer;
  transition: all 0.2s;
}
.auth-btn:hover { opacity: 0.9; transform: scale(1.03); }
.auth-error { color: var(--color-error); font-size: 0.85rem; margin-top: 10px; }

/* ====== 后台主界面 ====== */
.admin-shell {
  display: flex; flex-direction: column; height: 100vh; background: var(--color-bg);
}

/* ====== 顶部栏 ====== */
.admin-header {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px; background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
  z-index: 100; flex-shrink: 0;
}
.admin-brand { font-weight: 700; font-size: 1rem; color: var(--color-text); white-space: nowrap; }
.admin-tabs { display: flex; gap: 4px; flex: 1; }
.admin-tab-btn {
  padding: 8px 16px; border: none; background: transparent; border-radius: 10px;
  font-size: 0.9rem; cursor: pointer; color: var(--color-text-secondary);
  transition: all 0.2s; font-family: var(--font-sans);
}
.admin-tab-btn:hover { background: rgba(0,0,0,0.04); color: var(--color-text); }
.admin-tab-btn.active { background: rgba(37,99,235,0.12); color: var(--color-accent); font-weight: 600; }
.admin-header-actions { display: flex; gap: 8px; }

/* ====== 按钮系统 ====== */
.admin-btn {
  padding: 8px 18px; border: none; border-radius: 10px; font-size: 0.88rem;
  cursor: pointer; font-family: var(--font-sans); transition: all 0.2s;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 4px;
}
.admin-btn:active { transform: scale(0.97); }
.admin-btn-primary { background: var(--color-accent); color: #fff; }
.admin-btn-primary:hover { opacity: 0.9; }
.admin-btn-secondary { background: rgba(0,0,0,0.06); color: var(--color-text); }
.admin-btn-secondary:hover { background: rgba(0,0,0,0.1); }
.admin-btn-danger { background: var(--color-error); color: #fff; }
.admin-btn-danger:hover { opacity: 0.9; }
.admin-btn-deploy { background: #2DA44E; color: #fff; }
.admin-btn-deploy:hover { opacity: 0.9; }
.admin-btn-sm { padding: 4px 12px; font-size: 0.8rem; border-radius: 6px; }
.admin-btn-lg { padding: 14px 40px; font-size: 1rem; border-radius: 12px; }

/* ====== 表单控件 ====== */
.admin-input, .admin-select, .admin-textarea {
  padding: 8px 12px; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px;
  font-size: 0.9rem; font-family: var(--font-sans); outline: none;
  transition: border-color 0.2s; box-sizing: border-box; background: #fff;
}
.admin-input:focus, .admin-select:focus, .admin-textarea:focus { border-color: var(--color-accent); }
.admin-input-search { padding-left: 32px; }
.admin-select { cursor: pointer; }
.admin-select-sm { padding: 4px 8px; font-size: 0.8rem; }
.admin-textarea { resize: vertical; width: 100%; }

/* ====== 面板 ====== */
.admin-panel { flex: 1; overflow-y: auto; padding: 16px 20px; }

/* ====== 工具栏 ====== */
.panel-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.panel-toolbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-toolbar-right { display: flex; align-items: center; gap: 8px; }
.panel-toolbar-hint { font-size: 0.8rem; color: var(--color-text-secondary); }

/* 筛选胶囊 */
.articles-filter { display: flex; gap: 6px; }
.filter-chip {
  padding: 5px 14px; border: 1px solid rgba(0,0,0,0.06); border-radius: 16px;
  background: rgba(0,0,0,0.03); font-size: 0.82rem; cursor: pointer;
  color: var(--color-text-secondary); transition: all 0.2s ease; font-family: var(--font-sans);
}
.filter-chip:hover { background: rgba(37,99,235,0.08); color: var(--color-text); border-color: rgba(37,99,235,0.15); }
.filter-chip.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

/* 批量操作 */
.batch-actions { display: flex; align-items: center; gap: 8px; }

/* ====== 表格 ====== */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%; border-collapse: collapse; font-size: 0.88rem;
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.admin-table th, .admin-table td {
  padding: 12px 14px; text-align: left; border-bottom: 1px solid rgba(0,0,0,0.05);
}
.admin-table th { font-weight: 600; color: var(--color-text-secondary); font-size: 0.8rem; text-transform: uppercase; background: #f5f5f0; }
.admin-table tbody tr:hover { background: #faf8f2; }
.admin-table tbody tr.pinned-row { background: rgba(37,99,235,0.06); }

/* 状态标签 */
.status-tag {
  display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 0.78rem; font-weight: 500;
}
.status-published { background: rgba(74,140,74,0.08); color: #6B9B6B; }
.status-draft { background: rgba(138,138,138,0.1); color: #8A8A8A; }
.status-private { background: rgba(200,100,100,0.1); color: #C86464; }
.status-pinned { background: rgba(37,99,235,0.12); color: var(--color-accent); }

/* 字数、日期列灰色 */
.admin-table td:nth-child(4),
.admin-table td:nth-child(6) { color: #999; font-size: 0.84rem; }

/* 表格操作按钮 */
.table-actions { display: flex; gap: 4px; }
.table-btn {
  padding: 3px 8px; border: none; background: rgba(0,0,0,0.04); border-radius: 5px;
  font-size: 0.78rem; cursor: pointer; color: var(--color-text-secondary); transition: all 0.15s;
  font-family: var(--font-sans);
}
.table-btn:hover { background: rgba(0,0,0,0.08); color: var(--color-text); }
.table-btn.danger:hover { background: rgba(200,64,64,0.1); color: var(--color-error); }

/* ====== 编辑器 ====== */
.editor-layout { display: flex; flex-direction: column; gap: 16px; height: calc(100vh - 110px); }
.editor-meta { flex-shrink: 0; }
.editor-field { margin-bottom: 10px; }
.editor-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--color-text-secondary); margin-bottom: 4px; }
.editor-field-row { display: flex; gap: 12px; }
.editor-field-row .editor-field { flex: 1; }
.editor-field-row .admin-input, .editor-field-row .admin-select { width: 100%; }

.editor-md { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor-toolbar {
  display: flex; align-items: center; gap: 2px; padding: 6px 8px;
  background: rgba(0,0,0,0.03); border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px 10px 0 0; flex-wrap: wrap;
}
.md-btn {
  width: 30px; height: 28px; border: none; background: transparent; border-radius: 4px;
  font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--color-text-secondary); transition: all 0.15s;
}
.md-btn:hover { background: rgba(0,0,0,0.06); color: var(--color-text); }
.md-sep { width: 1px; height: 18px; background: rgba(0,0,0,0.1); margin: 0 4px; }
.editor-view-toggle { margin-left: auto; display: flex; gap: 2px; }
.md-view-btn {
  padding: 4px 12px; border: 1px solid rgba(0,0,0,0.1); background: transparent;
  border-radius: 6px; font-size: 0.8rem; cursor: pointer; color: var(--color-text-secondary);
  font-family: var(--font-sans);
}
.md-view-btn.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

.editor-panes { flex: 1; min-height: 0; }
.editor-textarea {
  width: 100%; height: 100%; padding: 16px; border: 1px solid rgba(0,0,0,0.08);
  border-top: none; border-radius: 0 0 10px 10px; font-size: 0.92rem;
  font-family: var(--font-mono);
  line-height: 1.7; resize: none; outline: none; box-sizing: border-box;
}
.editor-textarea:focus { border-color: var(--color-accent); }
.editor-preview {
  height: 100%; padding: 16px 20px; border: 1px solid rgba(0,0,0,0.08);
  border-top: none; border-radius: 0 0 10px 10px; overflow-y: auto;
  font-size: 0.95rem; line-height: 1.8; background: #fff;
}
.editor-preview h1,.editor-preview h2,.editor-preview h3 { margin: 20px 0 10px; color: var(--color-text); }
.editor-preview p { margin: 0 0 12px; }
.editor-preview blockquote { margin: 12px 0; padding: 8px 16px; border-left: 3px solid rgba(37,99,235,0.4); color: var(--color-text-secondary); background: rgba(0,0,0,0.02); }
.editor-preview code { background: rgba(0,0,0,0.05); padding: 2px 5px; border-radius: 3px; font-size: 0.88em; font-family: var(--font-mono); }
.editor-preview pre { background: rgba(0,0,0,0.04); padding: 14px; border-radius: 8px; overflow-x: auto; }
.editor-preview pre code { background: none; padding: 0; }
.editor-preview table { border-collapse: collapse; margin: 12px 0; width: 100%; }
.editor-preview th, .editor-preview td { padding: 8px 12px; border: 1px solid rgba(0,0,0,0.1); }
.editor-preview img { max-width: 100%; border-radius: 6px; }
.editor-preview a { color: var(--color-accent); }

/* ====== 媒体库 ====== */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-item {
  position: relative; background: #fff; border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04); transition: box-shadow 0.2s; cursor: pointer;
}
.media-item:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.media-thumb {
  width: 100%; height: 120px; object-fit: cover; display: block;
  background: rgba(0,0,0,0.03);
}
.media-item-icon {
  width: 100%; height: 120px; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: var(--color-text-secondary); background: rgba(0,0,0,0.02);
}
.media-item-name {
  padding: 6px 10px; font-size: 0.75rem; color: var(--color-text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-item-actions {
  display: none; position: absolute; top: 4px; right: 4px; gap: 4px;
}
.media-item:hover .media-item-actions { display: flex; }
.media-action-btn {
  width: 26px; height: 26px; border: none; border-radius: 50%;
  background: rgba(255,255,255,0.9); font-size: 0.75rem; cursor: pointer;
  color: var(--color-text-secondary); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.media-action-btn:hover { background: #fff; color: var(--color-text); }

/* ====== 设置 ====== */
.settings-section {
  background: #fff; border-radius: 12px; padding: 20px 24px; margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
.settings-heading { font-size: 1rem; font-weight: 700; margin: 0 0 16px; color: var(--color-text); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.settings-grid .editor-field { margin-bottom: 0; }
.settings-grid .admin-input,.settings-grid .admin-select,.settings-grid .admin-textarea { width: 100%; }

/* ====== 模态框 ====== */
.admin-modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.35); backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0.25s;
}
.admin-modal-overlay.active { opacity: 1; visibility: visible; }
.admin-modal {
  background: #fff; border-radius: 16px; padding: 24px; max-width: 420px; width: calc(100vw - 40px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.admin-modal-title { font-size: 1.1rem; font-weight: 700; margin: 0 0 12px; }
.admin-modal-body { font-size: 0.92rem; color: var(--color-text-secondary); margin-bottom: 20px; line-height: 1.6; }
.admin-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ====== 空状态 ====== */
.admin-empty { text-align: center; padding: 40px; color: var(--color-text-secondary); font-size: 0.9rem; }

/* ====== 部署状态 ====== */
.deploy-status {
  font-size: 0.88rem; padding: 12px 20px; border-radius: 10px; text-align: left;
}
.deploy-status.success { background: rgba(74,140,74,0.08); color: #4A8C4A; }
.deploy-status.error { background: rgba(200,64,64,0.08); color: #C84040; }
.deploy-status.loading { background: rgba(37,99,235,0.08); color: var(--color-accent); }

/* ====== 移动端 ====== */
@media (max-width: 768px) {
  .admin-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
  }
  .admin-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .admin-tabs::-webkit-scrollbar { display: none; }
  .admin-tab-btn {
    font-size: 0.8rem;
    padding: 8px 14px;
    min-height: 40px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .admin-panel {
    padding: 12px 14px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .panel-toolbar { flex-direction: column; align-items: stretch; }
  .panel-toolbar-left { flex-wrap: wrap; }
  .editor-field-row { flex-direction: column; }
  .editor-layout { height: auto; min-height: calc(100dvh - 140px); }
  .editor-textarea { min-height: 42vh; font-size: 16px; /* 防 iOS 聚焦缩放 */ }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .admin-table { font-size: 0.8rem; }
  .admin-table th, .admin-table td { padding: 8px; }
  /* 手机端隐藏 Slug、字数列，减少横向挤压（第 3、6 列） */
  .admin-table th:nth-child(3),
  .admin-table td:nth-child(3),
  .admin-table th:nth-child(6),
  .admin-table td:nth-child(6) {
    display: none;
  }
  .table-actions { flex-wrap: wrap; }
  .table-btn { min-height: 32px; padding: 6px 10px; }
  .auth-card { padding: 28px 20px; }
  .auth-input { font-size: 16px; min-height: 44px; }
}

@media (prefers-color-scheme: dark) {
  .auth-section, .admin-shell { background: #111; }
  .auth-card .auth-title { color: #eee; }
  .auth-input, .admin-input, .admin-select, .admin-textarea { background: #222; color: #ddd; border-color: rgba(255,255,255,0.1); }
  .admin-header { background: rgba(30,30,30,0.85); border-bottom-color: rgba(255,255,255,0.06); }
  .admin-tab-btn:hover { background: rgba(255,255,255,0.06); }
  .admin-table { background: #1a1a1a; }
  .admin-table th, .admin-table td { border-bottom-color: rgba(255,255,255,0.05); }
  .admin-table tbody tr:hover { background: rgba(255,255,255,0.03); }
  .editor-toolbar { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.06); }
  .editor-preview { background: #1a1a1a; }
  .editor-textarea { background: #1a1a1a; color: #ddd; border-color: rgba(255,255,255,0.08); }
  .settings-section { background: #1a1a1a; }
  .media-item { background: #1a1a1a; }
  .admin-modal { background: #222; }
  .status-published { background: rgba(74,140,74,0.15); }
  .status-draft { background: rgba(138,138,138,0.15); }
  .status-private { background: rgba(200,100,100,0.15); }
  .status-pinned { background: rgba(37,99,235,0.18); }
}
