/* =====================================================
   全局样式 / style.css
   打工心情日记 - 管理后台
   ===================================================== */

/* ——— CSS Reset & 基础 ——— */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif; color: #1f2328; background: #f6f8fa; line-height: 1.5; }
a { color: #0969da; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
pre { font-family: 'Consolas', 'Courier New', monospace; }

/* ——— 颜色变量 ——— */
:root {
  --primary:        #0969da;
  --primary-hover:  #0753c1;
  --success:        #1a7f37;
  --warning:        #9a6700;
  --danger:         #cf222e;
  --info:           #0550ae;
  --border:         #d0d7de;
  --bg:             #f6f8fa;
  --bg-white:       #ffffff;
  --bg-sidebar:     #f6f8fa;
  --text-muted:     #656d76;
  --text-secondary: #57606a;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:      0 4px 16px rgba(0,0,0,.12);
  --radius-sm:      6px;
  --radius-md:      8px;
  --radius-lg:      12px;
  --topbar-h:       52px;
}

/* =====================================================
   登录页
   ===================================================== */
.login-body {
  background: linear-gradient(135deg, #fff8e1 0%, #ffe0b2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrap {
  width: 400px;
  padding: 20px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.logo-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: #1f2328; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.login-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.login-tip {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 16px;
}

/* =====================================================
   后台布局
   ===================================================== */
.admin-body { background: var(--bg); overflow: hidden; height: 100vh; }

/* 顶部导航 */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-logo { font-size: 22px; }
.topbar-title { font-size: 15px; font-weight: 600; color: #1f2328; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-admin { font-size: 13px; color: var(--text-secondary); }

/* 主布局 */
.admin-layout {
  display: flex;
  height: calc(100vh - var(--topbar-h));
  margin-top: var(--topbar-h);
  overflow: hidden;
}

/* 左侧边栏 */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  padding: 14px 16px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.btn-icon {
  background: none; border: none; color: var(--text-muted); font-size: 16px;
  padding: 2px 4px; border-radius: 4px; line-height: 1;
}
.btn-icon:hover { background: var(--bg); color: #1f2328; }

.collection-list { list-style: none; overflow-y: auto; flex: 1; padding: 6px 0; }
.collection-item {
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s;
  border-left: 3px solid transparent;
}
.collection-item:hover { background: #f3f4f6; }
.collection-item.active {
  background: #dbeafe;
  border-left-color: var(--primary);
}
.col-label { display: block; font-size: 13px; font-weight: 500; color: #1f2328; }
.col-name { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; font-family: monospace; }
.collection-loading, .collection-empty {
  padding: 20px 16px; color: var(--text-muted); font-size: 13px; text-align: center;
}

/* 主内容区 */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--bg);
}

/* 欢迎面板 */
.welcome-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 60vh;
  color: var(--text-muted);
  text-align: center;
}
.welcome-icon { font-size: 56px; margin-bottom: 16px; }
.welcome-panel h2 { font-size: 18px; color: #57606a; margin-bottom: 8px; }
.welcome-panel p { font-size: 13px; }

/* 表格面板 */
.table-panel { display: flex; flex-direction: column; gap: 12px; }

/* 工具栏 */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.collection-title { font-size: 16px; font-weight: 600; }
.badge {
  display: inline-block; padding: 2px 10px;
  background: #e8f0fe; color: var(--primary);
  border-radius: 12px; font-size: 12px; font-weight: 500;
}
.search-box { display: flex; gap: 6px; align-items: center; }

/* 表格容器 */
.table-container {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  overflow-x: auto;
}

/* 数据表格 */
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  white-space: nowrap;
}
.data-table th {
  background: #f6f8fa;
  font-weight: 600; color: #57606a; font-size: 12px; text-transform: none;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f1f3;
  vertical-align: middle;
  max-width: 260px;
  overflow: hidden; text-overflow: ellipsis;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f6fbff; }

.th-id, .td-id { width: 200px; font-family: monospace; font-size: 11px; }
.th-action, .td-action { width: 130px; text-align: center; white-space: nowrap; }
.table-empty { text-align: center; color: var(--text-muted); padding: 40px; font-size: 14px; }
.td-more { color: var(--text-muted); text-align: center; }

/* 字段值样式 */
.null-value  { color: #adb5bd; font-style: italic; }
.bool-value  { color: #0969da; font-weight: 600; }
.num-value   { color: #0550ae; font-family: monospace; }
.str-value   { color: #1f2328; }
.date-value  { color: #6e40c9; }
.arr-value   { color: #9a6700; font-style: italic; }
.obj-value   { color: #57606a; font-family: monospace; font-size: 11px; }

/* 分页 */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; flex-wrap: wrap; gap: 8px;
}
.pagination-info { font-size: 12px; color: var(--text-muted); }
.pagination-btns { display: flex; align-items: center; gap: 6px; }
.page-numbers { display: flex; gap: 4px; }
.page-num-btn { min-width: 28px; }

/* =====================================================
   表单元素
   ===================================================== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 500; color: #1f2328;
}
.form-input {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; color: #1f2328; background: var(--bg-white);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-input:focus {
  border-color: #0969da;
  box-shadow: 0 0 0 3px rgba(9,105,218,.15);
}
.form-input-sm { width: 220px; font-size: 13px; padding: 6px 10px; }

/* =====================================================
   按钮
   ===================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: all .15s; outline: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; padding: 10px; font-size: 15px; }

.btn-primary    { background: #0969da; color: #fff; border-color: #0969da; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-default    { background: var(--bg-white); color: #1f2328; border-color: var(--border); }
.btn-default:hover:not(:disabled) { background: #f3f4f6; }

.btn-outline    { background: transparent; color: #1f2328; border-color: var(--border); }
.btn-outline:hover:not(:disabled) { background: #f3f4f6; }

.btn-danger     { background: #cf222e; color: #fff; border-color: #cf222e; }
.btn-danger:hover:not(:disabled) { background: #a40e26; }

.btn-warning    { background: #bf8700; color: #fff; border-color: #bf8700; }
.btn-warning:hover:not(:disabled) { background: #9a6700; }

.btn-info       { background: #0550ae; color: #fff; border-color: #0550ae; }
.btn-info:hover:not(:disabled) { background: #033d8b; }

.btn-sm   { padding: 5px 12px; font-size: 12px; }
.btn-xs   { padding: 3px 8px; font-size: 11px; border-radius: 4px; }

/* =====================================================
   Alert
   ===================================================== */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.5;
  margin-bottom: 12px;
}
.alert-error   { background: #fff0f0; color: #cf222e; border: 1px solid #ffcdd2; }
.alert-warning { background: #fff8e1; color: #9a6700; border: 1px solid #ffe082; }
.alert-success { background: #e6ffed; color: #1a7f37; border: 1px solid #b7e4c7; }

/* =====================================================
   弹窗
   ===================================================== */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
}
.modal-box {
  position: relative; z-index: 1;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  max-height: 85vh;
  animation: modalIn .18s ease;
}
.modal-box-sm { width: 420px; }
.modal-box-lg { width: 720px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 18px; color: var(--text-muted);
  padding: 2px 6px; border-radius: 4px; line-height: 1;
}
.modal-close:hover { background: #f0f1f3; color: #1f2328; }

.modal-body {
  padding: 20px; overflow-y: auto; flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0;
}

/* 详情表格 */
.detail-table { display: flex; flex-direction: column; gap: 0; }
.detail-row {
  display: grid; grid-template-columns: 160px 1fr;
  border-bottom: 1px solid #f0f1f3;
  padding: 8px 0;
}
.detail-row:last-child { border-bottom: none; }
.detail-key {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  font-family: monospace; padding-right: 12px;
  word-break: break-all;
}
.detail-val { font-size: 13px; word-break: break-word; }

.json-preview {
  background: #f6f8fa; border: 1px solid var(--border);
  border-radius: 4px; padding: 8px 10px;
  font-size: 12px; white-space: pre-wrap; word-break: break-all;
  max-height: 200px; overflow-y: auto;
}

/* JSON 编辑器 */
.json-editor {
  width: 100%; height: 380px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px; line-height: 1.6;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; resize: vertical; outline: none;
  background: #f6f8fa; color: #1f2328;
}
.json-editor:focus { border-color: #0969da; box-shadow: 0 0 0 3px rgba(9,105,218,.15); }

/* 删除确认 */
.delete-id-tip { color: var(--text-muted); font-size: 12px; margin: 6px 0; }
.delete-id-tip code {
  background: #f6f8fa; border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 3px; font-family: monospace; font-size: 11px;
  word-break: break-all;
}
.text-danger { color: var(--danger); font-size: 13px; }

/* =====================================================
   Toast
   ===================================================== */
.toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 999;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn .2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast-success { background: #e6ffed; color: #1a7f37; border: 1px solid #b7e4c7; }
.toast-error   { background: #fff0f0; color: #cf222e; border: 1px solid #ffcdd2; }
.toast-info    { background: #e8f0fe; color: #0550ae; border: 1px solid #c8d8f8; }

/* =====================================================
   加载遮罩
   ===================================================== */
.loading-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(2px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; font-size: 14px; color: var(--text-secondary);
}
.loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid #d0d7de;
  border-top-color: #0969da;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================
   滚动条美化（Webkit）
   ===================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d7de; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #afb8c1; }

/* =====================================================
   图片查看 - 表格内图片标记
   ===================================================== */
.cell-img-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: #e8f4fd; color: #0550ae;
  border: 1px solid #c8d8f8;
  border-radius: 12px; font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, box-shadow .15s;
}
.cell-img-badge:hover {
  background: #d0e8fb;
  box-shadow: 0 1px 4px rgba(5,80,174,.15);
}

/* =====================================================
   图片查看 - 详情弹窗内图片区
   ===================================================== */
.detail-img-loading {
  padding: 12px 0;
  color: var(--text-muted); font-size: 13px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

.detail-img-grid {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin: 6px 0;
}
.detail-img-wrap {
  position: relative;
  width: 110px; height: 110px;
  border-radius: 8px; overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  background: #f6f8fa;
}
.detail-img-wrap:hover {
  border-color: #0969da;
  transform: scale(1.04);
}
.detail-img-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.detail-img-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.38);
  color: #fff; font-size: 12px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
}
.detail-img-wrap:hover .detail-img-overlay { opacity: 1; }

.detail-img-wrap.img-error {
  border-color: #ffcdd2; background: #fff0f0;
  display: flex; align-items: center; justify-content: center;
}
.img-err-tip { font-size: 11px; color: #cf222e; text-align: center; padding: 4px; }

.detail-img-count {
  font-size: 12px; color: var(--text-muted);
  margin-top: 4px;
}

/* =====================================================
   图片灯箱弹窗
   ===================================================== */
.lightbox-modal {
  z-index: 500;   /* 高于普通弹窗 */
}

.lightbox-box {
  position: relative; z-index: 1;
  width: min(90vw, 900px);
  max-height: 92vh;
  display: flex; flex-direction: column;
  background: #0d1117;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.7);
  animation: modalIn .2s ease;
}

.lightbox-close {
  position: absolute; top: 12px; right: 14px; z-index: 10;
  background: rgba(255,255,255,.12); border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 16px; color: #e6edf3;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }

.lightbox-counter {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.5); color: #e6edf3; border-radius: 12px;
  padding: 3px 12px; font-size: 12px; font-weight: 500; z-index: 10;
  white-space: nowrap;
}

.lightbox-main {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  padding: 48px 60px 12px;
}

.lightbox-img-wrap {
  max-width: 100%; max-height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-img-wrap img {
  max-width: 100%; max-height: calc(92vh - 140px);
  object-fit: contain;
  border-radius: 4px;
  display: block;
}

.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px;
  background: rgba(255,255,255,.12); border: none; border-radius: 50%;
  color: #e6edf3; font-size: 28px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s; z-index: 5;
}
.lightbox-nav:disabled { opacity: .25; cursor: not-allowed; }
.lightbox-nav:not(:disabled):hover { background: rgba(255,255,255,.25); }
.lightbox-nav-prev { left: 12px; }
.lightbox-nav-next { right: 12px; }

.lightbox-strip {
  display: flex; gap: 6px;
  padding: 10px 16px;
  overflow-x: auto;
  background: rgba(0,0,0,.3);
  flex-shrink: 0;
}
.lightbox-strip:empty { display: none; }

.lightbox-thumb {
  width: 56px; height: 56px; flex-shrink: 0;
  border-radius: 6px; overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer; transition: border-color .15s, transform .15s;
}
.lightbox-thumb:hover { transform: scale(1.06); }
.lightbox-thumb.active { border-color: #58a6ff; }
.lightbox-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

