/* ============================================================
   site-stability.css —— 全站稳定性增强样式
   页面过渡 · 开发者面板 · 自检结果
   ============================================================ */

/* ---------- 页面加载淡入 / 离开淡出（消除白闪） ---------- */
body {
  opacity: 0;
  transition: opacity 0.24s ease-out;
}

body.page-loaded {
  opacity: 1;
}

body.page-leaving {
  opacity: 0;
  transition: opacity 0.18s ease-out;
}

/* 防止页面加载时内容闪烁：先显示背景色 */
html {
  background-color: var(--color-bg, #0a0e1a);
}

/* ---------- 开发者隐藏面板 ---------- */
.dev-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s ease-out, visibility 0.24s ease-out;
}

.dev-panel-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.dev-panel {
  width: 90%;
  max-width: 780px;
  max-height: 85vh;
  background: var(--color-surface, #141a2e);
  border: 1px solid var(--color-border, #2a3142);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dev-panel-overlay.visible .dev-panel {
  transform: scale(1) translateY(0);
}

.dev-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border, #2a3142);
  background: linear-gradient(135deg, rgba(196, 30, 58, 0.12), rgba(139, 0, 0, 0.08));
}

.dev-panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text, #f1f5f9);
}

.dev-panel-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #94a3b8);
  font-size: 22px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.24s ease-out;
}

.dev-panel-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.dev-panel-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border, #2a3142);
  overflow-x: auto;
}

.dev-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #94a3b8);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  white-space: nowrap;
  transition: all 0.24s ease-out;
}

.dev-tab:hover {
  background: var(--color-surface-hover, #1b2237);
  color: var(--color-text, #f1f5f9);
}

.dev-tab.active {
  background: linear-gradient(135deg, #C41E3A, #8B0000);
  color: white;
}

.dev-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.dev-tab-content {
  display: none;
}

.dev-tab-content.active {
  display: block;
  animation: devFadeIn 0.2s ease;
}

@keyframes devFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 开发者工具栏 ---------- */
.dev-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dev-btn {
  padding: 8px 16px;
  border: 1px solid var(--color-border, #2a3142);
  background: var(--color-surface-hover, #1b2237);
  color: var(--color-text, #f1f5f9);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.24s ease-out;
}

.dev-btn:hover {
  border-color: #C41E3A;
  background: rgba(196, 30, 58, 0.15);
}

.dev-btn-primary {
  background: linear-gradient(135deg, #C41E3A, #8B0000);
  border-color: transparent;
  color: white;
}

.dev-btn-primary:hover {
  background: linear-gradient(135deg, #8B0000, #A01830);
  border-color: transparent;
}

.dev-btn-danger {
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

.dev-btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}

.dev-btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

.dev-count {
  font-size: 12px;
  color: var(--color-text-muted, #64748b);
  margin-left: auto;
}

/* ---------- 成就列表 ---------- */
.dev-ach-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--color-border, #2a3142);
  border-radius: 10px;
}

.dev-ach-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border, #2a3142);
  font-size: 13px;
}

.dev-ach-item:last-child {
  border-bottom: none;
}

.dev-ach-id {
  flex: 1;
  font-family: monospace;
  color: var(--color-text, #f1f5f9);
}

.dev-ach-time {
  font-size: 11px;
  color: var(--color-text-muted, #64748b);
}


/* ---------- 调试工具网格 ---------- */
.dev-tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

/* ---------- 自检结果 ---------- */
.dev-selfcheck-summary {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--color-surface-hover, #1b2237);
  border-radius: 10px;
}

.dev-pass { color: #10b981; font-weight: 600; }
.dev-warn { color: #f59e0b; font-weight: 600; }
.dev-fail { color: #ef4444; font-weight: 600; }

.dev-selfcheck-list {
  border: 1px solid var(--color-border, #2a3142);
  border-radius: 10px;
  overflow: hidden;
}

.dev-selfcheck-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border, #2a3142);
  font-size: 13px;
}

.dev-selfcheck-item:last-child {
  border-bottom: none;
}

.dev-status-icon {
  width: 20px;
  text-align: center;
  font-weight: bold;
}

.dev-status-pass .dev-status-icon { color: #10b981; }
.dev-status-warn .dev-status-icon { color: #f59e0b; }
.dev-status-fail .dev-status-icon { color: #ef4444; }

/* ---------- 日志列表 ---------- */
.dev-log-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--color-border, #2a3142);
  border-radius: 10px;
}

.dev-log-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border, #2a3142);
  font-size: 12px;
}

.dev-log-item:last-child {
  border-bottom: none;
}

.dev-log-time {
  color: var(--color-text-muted, #64748b);
  font-family: monospace;
  flex-shrink: 0;
}

.dev-log-type {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  font-weight: 600;
  flex-shrink: 0;
}

.dev-log-msg {
  color: var(--color-text-secondary, #94a3b8);
  word-break: break-all;
}

/* ---------- 空状态 ---------- */
.dev-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--color-text-muted, #64748b);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 640px) {
  .dev-panel {
    width: 95%;
    max-height: 90vh;
  }

  .dev-panel-header {
    padding: 12px 16px;
  }

  .dev-panel-body {
    padding: 12px 14px;
  }

  .dev-tool-grid {
    grid-template-columns: 1fr;
  }

  .dev-tab {
    padding: 6px 12px;
    font-size: 12px;
  }
}


/* ---------- 图片加载失败优雅占位 ---------- */
img.img-fallback {
  background: var(--color-surface-2, #1e293b);
  min-width: 40px;
  min-height: 40px;
  object-fit: cover;
}

[data-theme="dark"] img.img-fallback {
  background: #1a1f2e;
}

[data-theme="light"] img.img-fallback {
  background: #e8ecf1;
}

/* ---------- 减少动画偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  body,
  body.page-leaving,
  .dev-panel-overlay,
  .dev-panel,
  .dev-tab-content {
    transition: none !important;
    animation: none !important;
  }
}
