/**
 * 后台管理样式
 */

:root {
  --admin-sidebar-width: 260px;
  --admin-header-height: 64px;
  
  /* Space scale (fallbacks) */
  --article-space-1: 4px;
  --article-space-2: 8px;
  --article-space-3: 12px;
  --article-space-4: 16px;
  --article-space-5: 20px;
  --article-space-6: 24px;
  --article-space-8: 32px;
  --article-space-10: 40px;
  
  /* Text scale (fallbacks) */
  --article-text-xs: 12px;
  --article-text-sm: 14px;
  --article-text-base: 16px;
  --article-text-lg: 18px;
  --article-text-xl: 24px;
  
  /* Transitions (fallbacks) */
  --article-transition-fast: 0.15s ease;
  --article-transition-normal: 0.25s ease;
  
  /* Colors (fallbacks) */
  --article-success: #10b981;
  --article-warning: #f59e0b;
  --article-error: #ef4444;
  --article-info: #3b82f6;
}

/* 布局 */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* 侧边?*/
.admin-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--admin-sidebar-width);
  height: 100vh;
  background: var(--paper-solid);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.admin-brand {
  padding: var(--article-space-4) var(--article-space-5);
  /* removed border-bottom */
}

.admin-brand a {
  display: flex;
  align-items: center;
  gap: var(--article-space-3);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
}

.admin-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}

.admin-nav {
  flex: 1;
  padding: var(--article-space-4);
}

.admin-nav__link {
  display: flex;
  align-items: center;
  gap: var(--article-space-3);
  padding: 10px var(--article-space-4);
  margin-bottom: var(--article-space-1);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.admin-nav__link:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.admin-nav__link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* 主内容区 */
.admin-main {
  flex: 1;
  margin-left: var(--admin-sidebar-width);
  display: flex;
  flex-direction: column;
}

.admin-header {
  position: sticky;
  top: 0;
  height: var(--admin-header-height);
  padding: 0 var(--article-space-5);
  background: var(--paper-solid);
  /* removed border-bottom */
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
}

.admin-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: var(--article-space-3);
}

.admin-select {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  height: 36px;
}

.admin-select:hover {
  border-color: var(--line-strong);
}

.admin-content {
  flex: 1;
  padding: var(--article-space-6);
}

/* 文章卡片网格 */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--article-space-5);
}

.article-card {
  background: var(--paper-solid);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.article-card:hover {
  box-shadow: var(--article-shadow-lg);
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

.article-card__cover {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--bg-soft);
}

.article-card__body {
  padding: var(--article-space-4);
}

.article-card__title {
  margin: 0 0 var(--article-space-2);
  font-size: var(--article-text-base);
  font-weight: 600;
  line-height: 1.4;
}

.article-card__title a {
  color: var(--ink);
}

.article-card__excerpt {
  margin: 0 0 var(--article-space-3);
  font-size: var(--article-text-sm);
  color: var(--article-ink-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--article-space-3);
  font-size: var(--article-text-xs);
  color: var(--article-ink-muted);
}

.article-card__status {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 12px;
}

.article-card__status--published {
  background: rgba(16, 185, 129, 0.1);
  color: var(--article-success);
}

.article-card__status--draft {
  background: rgba(245, 158, 11, 0.1);
  color: var(--article-warning);
}

.article-card__actions {
  display: flex;
  gap: var(--article-space-2);
  padding-top: var(--article-space-3);
  border-top: 1px solid var(--line);
}

.article-card__actions .btn {
  flex: 1;
  font-size: var(--article-text-xs);
}

/* 按钮 - Claude 风格 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  height: 36px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #e55a2b;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-soft);
}

.btn-danger {
  background: var(--article-error);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn--loading {
  position: relative;
  color: transparent !important;
}

.btn--loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 模态框 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal.is-open {
  display: flex;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal__content {
  position: relative;
  width: 90%;
  max-width: 440px;
  background: var(--paper-solid);
  border-radius: 12px;
  box-shadow: var(--article-shadow-lg);
  animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--article-space-5);
  /* removed border-bottom */
}

.modal__header h3 {
  margin: 0;
  font-size: var(--article-text-lg);
}

.modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.modal__close:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.modal__body {
  padding: var(--article-space-5);
}

.modal__warning {
  color: var(--article-error);
  font-size: var(--article-text-sm);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--article-space-3);
  padding: var(--article-space-4) var(--article-space-5);
  border-top: 1px solid var(--line);
}

/* Toast */
.toast-container {
  position: fixed;
  top: var(--article-space-4);
  right: var(--article-space-4);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--article-space-2);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--article-space-3);
  padding: 12px 16px;
  background: var(--paper-solid);
  border-radius: 10px;
  box-shadow: var(--article-shadow-lg);
  transform: translateX(120%);
  transition: transform 0.25s ease;
  min-width: 280px;
}

.toast--visible {
  transform: translateX(0);
}

.toast__icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
}

.toast--success .toast__icon { background: rgba(16, 185, 129, 0.1); color: var(--article-success); }
.toast--error .toast__icon { background: rgba(239, 68, 68, 0.1); color: var(--article-error); }
.toast--warning .toast__icon { background: rgba(245, 158, 11, 0.1); color: var(--article-warning); }
.toast--info .toast__icon { background: rgba(59, 130, 246, 0.1); color: var(--article-info); }

.toast__message {
  flex: 1;
  font-size: var(--article-text-sm);
}

.toast__close {
  border: none;
  background: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

/* 分页 */
.admin-pagination {
  display: flex;
  justify-content: center;
  gap: var(--article-space-2);
  margin-top: var(--article-space-6);
}

.admin-pagination button {
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-solid);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.admin-pagination button:hover:not(:disabled) {
  background: var(--bg-soft);
}

.admin-pagination button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.admin-pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 空状?*/
.empty-state {
  text-align: center;
  padding: var(--article-space-10);
  color: var(--muted);
}

.empty-state__icon {
  font-size: 64px;
  margin-bottom: var(--article-space-4);
  opacity: 0.5;
}

.empty-state p {
  margin: 0;
}

/* 响应?*/
@media (max-width: 768px) {
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  
  .admin-layout {
    flex-direction: column;
  }
  
  .admin-main {
    margin-left: 0;
  }
  
  .article-grid {
    grid-template-columns: 1fr;
  }
}

/* 侧边栏底?- 主题切换 */
.admin-sidebar__footer {
  padding: var(--article-space-4);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--ink-soft);
}

.theme-toggle:hover {
  background: var(--bg-soft);
  border-color: var(--line-strong);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.sun-icon { display: block; }
.moon-icon { display: none; }

/* ===== 暗色模式 ===== */
[data-theme="dark"] .admin-layout {
  background: #1a1816;
}

[data-theme="dark"] .admin-sidebar {
  background: #1e1c1a;
  border-color: rgba(246,239,227,0.08);
}

[data-theme="dark"] .admin-brand {
  border-color: rgba(246,239,227,0.08);
}

[data-theme="dark"] .admin-brand a,
[data-theme="dark"] .admin-nav__link {
  color: #a8a6a0;
}

[data-theme="dark"] .admin-nav__link:hover {
  background: rgba(246,239,227,0.06);
  color: #f6efe3;
}

[data-theme="dark"] .admin-nav__link.is-active {
  background: rgba(255,107,53,0.15);
  color: #ff854a;
}

[data-theme="dark"] .admin-header {
  background: #1a1816;
  border-color: rgba(246,239,227,0.08);
}

[data-theme="dark"] .admin-header h1 {
  color: #f6efe3;
}

[data-theme="dark"] .admin-select {
  background: #1e1c1a;
  border-color: rgba(246,239,227,0.12);
  color: #d6d0c4;
}

[data-theme="dark"] .article-card {
  background: #1e1c1a;
  border-color: rgba(246,239,227,0.08);
}

[data-theme="dark"] .article-card:hover {
  background: #242220;
}

[data-theme="dark"] .article-card__title a {
  color: #f6efe3;
}

[data-theme="dark"] .article-card__excerpt {
  color: #a8a6a0;
}

[data-theme="dark"] .article-card__meta {
  color: #8a8880;
}

[data-theme="dark"] .article-card__actions {
  border-color: rgba(246,239,227,0.08);
}

[data-theme="dark"] .btn-ghost {
  color: #d6d0c4;
  border-color: rgba(246,239,227,0.15);
}

[data-theme="dark"] .btn-ghost:hover:not(:disabled) {
  background: rgba(246,239,227,0.08);
  color: #f6efe3;
}

[data-theme="dark"] .modal__content {
  background: #1e1c1a;
  border: 1px solid rgba(246,239,227,0.08);
}

[data-theme="dark"] .modal__header {
  border-color: rgba(246,239,227,0.08);
}

[data-theme="dark"] .modal__header h3 {
  color: #f6efe3;
}

[data-theme="dark"] .modal__close {
  color: #8a8880;
}

[data-theme="dark"] .modal__close:hover {
  background: rgba(246,239,227,0.08);
  color: #f6efe3;
}

[data-theme="dark"] .modal__body {
  color: #d6d0c4;
}

[data-theme="dark"] .modal__footer {
  border-color: rgba(246,239,227,0.08);
}

[data-theme="dark"] .admin-pagination button {
  background: #1e1c1a;
  border-color: rgba(246,239,227,0.1);
  color: #d6d0c4;
}

[data-theme="dark"] .admin-pagination button:hover:not(:disabled) {
  background: rgba(246,239,227,0.08);
  color: #f6efe3;
}

[data-theme="dark"] .admin-pagination button.is-active {
  background: #ff6b35;
  color: white;
}

[data-theme="dark"] .admin-sidebar__footer {
  border-color: rgba(246,239,227,0.08);
}

[data-theme="dark"] .theme-toggle {
  border-color: rgba(246,239,227,0.15);
  color: #a8a6a0;
}

[data-theme="dark"] .theme-toggle:hover {
  background: rgba(246,239,227,0.08);
  border-color: rgba(246,239,227,0.25);
  color: #f6efe3;
}

[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }

[data-theme="dark"] .toast {
  background: #242220;
}

[data-theme="dark"] .empty-state {
  color: #8a8880;
}
