
/* Edit mode indicator */
body.edit-mode .topbar {
  border-bottom: 2px solid var(--color-accent);
}

body.edit-mode .btn-edit-toggle {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-primary-dark);
}

/* Editable content styles */
.editable-content {
  background: #fff;
  min-height: calc(100vh - var(--topbar-height) - 120px);
  padding: 32px 48px;
  outline: none;
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.8;
  color: #1c2333;
}

.editable-content[contenteditable="true"] {
  cursor: text;
  border: 2px dashed rgba(201, 162, 39, 0.4);
  border-radius: 4px;
  position: relative;
}

.editable-content[contenteditable="true"]::before {
  content: '编辑模式已开启 - 直接点击内容进行修改';
  position: sticky;
  top: 0;
  display: block;
  background: rgba(201, 162, 39, 0.12);
  color: #a07d10;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 4px 4px 0 0;
  margin: -32px -48px 16px -48px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.2);
  z-index: 5;
  pointer-events: none;
}

/* Content styles within editable area */
.editable-content h1,
.editable-content h2,
.editable-content h3,
.editable-content h4,
.editable-content h5,
.editable-content h6 {
  font-family: 'Noto Serif SC', serif;
  color: #1a3a5c;
  margin-top: 1.5em;
  margin-bottom: 0.6em;
  line-height: 1.4;
}

.editable-content h1 { font-size: 22px; border-bottom: 2px solid #c9a227; padding-bottom: 8px; }
.editable-content h2 { font-size: 18px; border-left: 4px solid #1a3a5c; padding-left: 12px; }
.editable-content h3 { font-size: 16px; }
.editable-content h4 { font-size: 15px; }

.editable-content p {
  margin-bottom: 0.8em;
}

.editable-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 8px 0;
  cursor: zoom-in;
}

body.rich-image-viewer-open { overflow: hidden; }
.rich-image-viewer { position: fixed; inset: 0; z-index: 10050; display: none; align-items: center; justify-content: center; }
.rich-image-viewer.is-open { display: flex; }
.rich-image-viewer-backdrop { position: absolute; inset: 0; background: rgba(10, 16, 28, .86); }
.rich-image-viewer-panel { position: relative; z-index: 1; width: min(94vw, 1200px); height: min(92vh, 900px); display: flex; align-items: center; justify-content: center; }
.rich-image-viewer-image { max-width: calc(100% - 112px); max-height: calc(100% - 54px); object-fit: contain; border-radius: 3px; box-shadow: 0 14px 42px rgba(0,0,0,.4); }
.rich-image-viewer-close, .rich-image-viewer-prev, .rich-image-viewer-next { position: absolute; z-index: 2; border: 0; color: #fff; background: rgba(255,255,255,.14); cursor: pointer; }
.rich-image-viewer-close { top: 0; right: 0; width: 38px; height: 38px; font-size: 28px; line-height: 1; border-radius: 4px; }
.rich-image-viewer-prev, .rich-image-viewer-next { top: 50%; width: 44px; height: 64px; margin-top: -32px; font-size: 42px; line-height: 54px; border-radius: 4px; }
.rich-image-viewer-prev { left: 4px; } .rich-image-viewer-next { right: 4px; }
.rich-image-viewer-prev:disabled, .rich-image-viewer-next:disabled { opacity: .25; cursor: default; }
.rich-image-viewer-counter { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; color: #fff; font-size: 13px; }
@media (max-width: 600px) { .rich-image-viewer-image { max-width: calc(100% - 72px); } .rich-image-viewer-prev, .rich-image-viewer-next { width: 34px; height: 52px; font-size: 34px; } }

.editable-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}

.editable-content table th,
.editable-content table td {
  border: 1px solid #dde1e7;
  padding: 8px 12px;
  text-align: left;
}

.editable-content table th {
  background: #f0f2f5;
  font-weight: 600;
  color: #1a3a5c;
}

.editable-content table tr:nth-child(even) td {
  background: #f8f9fb;
}

.editable-content ul, .editable-content ol {
  padding-left: 24px;
  margin-bottom: 0.8em;
}

.editable-content li {
  margin-bottom: 4px;
}

.editable-content a {
  color: #1a3a5c;
  text-decoration: underline;
}

.editable-content blockquote {
  border-left: 4px solid #c9a227;
  padding: 8px 16px;
  margin: 16px 0;
  background: rgba(201, 162, 39, 0.06);
  color: #5a6478;
  font-style: italic;
}

.editable-content code {
  background: #f0f2f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.editable-content pre {
  background: #1c2333;
  color: #e8ecf0;
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 16px 0;
}

.editable-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* Iframe content wrapper */
.content-frame-wrapper {
  background: #fff;
  width: 100%;
}

.content-frame-wrapper iframe {
  width: 100%;
  border: none;
  display: block;
  background: #fff;
}

/* Edit mode badge on node */
.tree-node-row.edited .tree-node-name::after {
  content: ' *';
  color: #7c3aed;
  font-weight: 700;
}

/* Save indicator */
.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #16a34a;
  padding: 2px 8px;
  background: rgba(22, 163, 74, 0.1);
  border-radius: 10px;
}

/* Unsaved changes indicator */
.unsaved-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #d97706;
  padding: 2px 8px;
  background: rgba(217, 119, 6, 0.1);
  border-radius: 10px;
}

/* Page meta info bar */
.page-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  background: #f8f9fb;
  border-bottom: 1px solid #eaecf0;
  font-size: 12px;
  color: #8a95a8;
  flex-shrink: 0;
}

.page-meta-bar .page-title {
  font-weight: 600;
  color: #1c2333;
  font-size: 13px;
}

.page-meta-bar .page-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Admin panel styles */
.admin-layout {
  display: flex;
  height: 100vh;
  padding-top: var(--topbar-height);
}

.admin-sidebar {
  width: 220px;
  background: #1a3a5c;
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.admin-nav {
  padding: 16px 0;
  flex: 1;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  cursor: pointer;
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  transition: var(--transition);
  text-decoration: none;
}

.admin-nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.admin-nav-item.active {
  background: rgba(201, 162, 39, 0.2);
  color: #c9a227;
  border-right: 3px solid #c9a227;
}

.admin-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #f5f6f8;
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card-icon svg {
  width: 22px;
  height: 22px;
}

.stat-card-info {
  flex: 1;
}

.stat-card-num {
  font-size: 28px;
  font-weight: 700;
  color: #1a3a5c;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card-label {
  font-size: 13px;
  color: #8a95a8;
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.data-table th {
  background: #f0f2f5;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #5a6478;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #dde1e7;
}

.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  color: #1c2333;
  border-bottom: 1px solid #f0f2f5;
}

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

.data-table tr:hover td {
  background: #f8f9fb;
}

:root[data-color-mode="dark"] .editable-content,
:root[data-color-mode="dark"] .content-frame-wrapper,
:root[data-color-mode="dark"] .admin-content,
:root[data-color-mode="dark"] .stat-card,
:root[data-color-mode="dark"] .data-table {
  background: #1b2027 !important;
  color: #d8e0ea !important;
  border-color: #3b4552 !important;
}
:root[data-color-mode="dark"] .editable-content :is(p, li, td, div, span, blockquote),
:root[data-color-mode="dark"] .data-table td,
:root[data-color-mode="dark"] .stat-card-label {
  color: #d8e0ea !important;
}
:root[data-color-mode="dark"] .editable-content :is(h1, h2, h3, h4, h5, h6),
:root[data-color-mode="dark"] .data-table th,
:root[data-color-mode="dark"] .stat-card-num,
:root[data-color-mode="dark"] .page-meta-bar .page-title {
  color: #edf1f5 !important;
}
:root[data-color-mode="dark"] .editable-content :is(table th, code),
:root[data-color-mode="dark"] .data-table th {
  background: #252c35 !important;
  color: #edf1f5 !important;
}
:root[data-color-mode="dark"] .editable-content table :is(td, th),
:root[data-color-mode="dark"] .data-table :is(td, th) {
  border-color: #465361 !important;
}
:root[data-color-mode="dark"] .editable-content table tr:nth-child(even) td,
:root[data-color-mode="dark"] .data-table tr:hover td {
  background: #202832 !important;
}
:root[data-color-mode="dark"] .content-frame-wrapper iframe {
  background: #11161c !important;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.badge-edited {
  background: rgba(124, 58, 237, 0.1);
  color: #7c3aed;
}

.badge-original {
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border-light);
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: #1a3a5c;
}

.section-subtitle {
  font-size: 13px;
  color: #8a95a8;
  margin-top: 2px;
}
