/* ===== 命令面板样式 ===== */
.command-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.command-palette-modal {
  width: 100%;
  max-width: 640px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 20px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  margin: 0 16px;
  border: 1px solid var(--border);
}

.command-palette-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.command-palette-header .command-palette-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.command-palette-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
  outline: none;
  padding: 0;
}

.command-palette-input::placeholder {
  color: var(--text-tertiary);
}

.command-palette-shortcut {
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--bg-hover);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: monospace;
}

.command-palette-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.command-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s;
}

.command-palette-item:hover,
.command-palette-item.selected {
  background: var(--primary-bg);
}

.command-palette-item-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.command-palette-item-info {
  flex: 1;
  min-width: 0;
}

.command-palette-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.command-palette-item-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.command-palette-item mark {
  background: rgba(99, 102, 241, 0.2);
  color: var(--primary);
  padding: 0 2px;
  border-radius: 2px;
}

.command-palette-item-shortcut {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: monospace;
  opacity: 0.6;
}

.command-palette-empty {
  padding: 32px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

.command-palette-footer {
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-tertiary);
}

.command-palette-footer kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bg-hover);
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
  margin-right: 2px;
}

/* ===== Toast 通知 ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-md), 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toastIn 0.3s ease-out;
  pointer-events: auto;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
}

.toast.toast-success::before { background: var(--success); }
.toast.toast-error::before { background: var(--danger); }
.toast.toast-warning::before { background: var(--warning); }

.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-error .toast-icon { color: var(--danger); }
.toast.toast-warning .toast-icon { color: var(--warning); }

.toast-icon {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--primary);
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.toast-message {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.5;
}

.toast-close {
  flex-shrink: 0;
  padding: 4px;
  margin: -4px;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: color 0.15s;
}

.toast-close:hover {
  color: var(--text);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-light);
}

.toast-progress-bar {
  height: 100%;
  background: var(--primary);
  animation: toastProgress 4s linear forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.96); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0; }
}

.toast-exit {
  animation: toastOut 0.2s ease-in forwards;
}

/* ===== 导航抽屉（移动端） ===== */
.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mobile-nav-overlay.active {
  opacity: 1;
}

.mobile-nav-drawer {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--bg-card);
  z-index: 999;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.mobile-nav-drawer.active {
  transform: translateX(0);
}

.mobile-nav-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-nav-logo {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-nav-close {
  padding: 8px;
  margin: -8px;
  color: var(--text-tertiary);
  cursor: pointer;
}

.mobile-nav-section {
  padding: 8px 0;
}

.mobile-nav-section-title {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.1s, color 0.1s;
  position: relative;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
  background: var(--primary-bg);
  color: var(--primary);
}

.mobile-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.mobile-nav-item-icon {
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-nav-item-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-weight: 500;
}

.mobile-nav-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-tertiary);
}

/* 顶部工具栏（移动端） */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  z-index: 99;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.mobile-topbar-menu {
  padding: 8px;
  margin: -8px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.mobile-topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.mobile-topbar-actions {
  display: flex;
  gap: 8px;
}

/* ===== 全局页面进度条 ===== */
.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.page-progress.active { opacity: 1; }
.page-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--info));
  border-radius: 0 2px 2px 0;
  transition: width 0.3s ease;
}
.page-progress.active .page-progress-bar {
  transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ===== 骨架屏增强 ===== */
.skeleton-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
}

.skeleton-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-line {
  height: 12px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.skeleton-line:last-child {
  margin-bottom: 0;
  width: 60%;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.skeleton-table-row {
  display: flex;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.skeleton-table-cell {
  flex: 1;
  height: 14px;
  border-radius: 4px;
}

.skeleton-table-cell:last-child {
  flex: 0 0 80px;
}

/* 表单骨架屏 */
.form-skeleton {
  max-width: 600px;
}

.form-skeleton-group {
  margin-bottom: 20px;
}

.form-skeleton-label {
  height: 14px;
  width: 80px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.form-skeleton-input {
  height: 40px;
  border-radius: var(--radius);
  width: 100%;
}

.form-skeleton-textarea {
  height: 100px;
  border-radius: var(--radius);
  width: 100%;
}

/* ===== 动画工具类 ===== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-shimmer {
  background: linear-gradient(90deg, var(--border) 25%, var(--border-light) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* 页面过渡 */
.page-transition-enter {
  opacity: 0;
  transform: translateY(8px);
}

.page-transition-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* 按钮加载状态 */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

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

/* 悬浮提示增强 */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* 键盘快捷键显示 */
kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
  box-shadow: 0 1px 0 var(--border);
}

/* 空状态增强 */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: var(--bg-hover);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}

.empty-state-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.empty-state-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* 滚动指示器 */
.scroll-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--bg-card));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.scroll-indicator.visible {
  opacity: 1;
}

/* 响应式工具 */
@media (max-width: 768px) {
  .mobile-topbar {
    display: flex;
  }

  /* 侧边栏抽屉由 mobile.css 托管（off-canvas），此处不再强制隐藏 */
  .sidebar {
    display: flex;
  }

  .main {
    margin-left: 0 !important;
    padding-top: 52px;
  }

  .command-palette-modal {
    margin: 0 8px;
    max-height: 80vh;
  }

  .command-palette-list {
    max-height: calc(80vh - 140px);
  }

  .toast-container {
    left: 16px;
    right: 16px;
    top: 16px;
    max-width: none;
  }

  .toast {
    width: 100%;
  }
}

/* 暗色模式优化 */
[data-theme="dark"] .command-palette-modal {
  border-color: var(--border);
}

[data-theme="dark"] .toast {
  border-color: var(--border);
}

[data-theme="dark"] .mobile-nav-drawer {
  border-right: 1px solid var(--border);
}
