/* 郭标平台 UI/UX增强 v1.0 - 体验打磨 */
/* 核心原则：白色极简、无花哨动画、只在有实际价值的地方加动效 */

/* ==================== 1. 全局Loading指示器 ==================== */
.global-loading {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: 9999;
  pointer-events: none;
}
.global-loading.active {
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: loadingSlide 1.5s ease infinite;
}
@keyframes loadingSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* 页面级加载覆盖 */
.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 13px;
  gap: 12px;
}
.page-loading .spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 2. 页面过渡 ==================== */
.page {
  animation: pageIn 0.2s ease;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== 3. 增强Toast通知 ==================== */
.toast {
  position: fixed;
  top: 60px;
  right: 20px;
  padding: 10px 20px 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 10000;
  max-width: 360px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.25s ease;
  cursor: pointer;
  line-height: 1.4;
}
.toast:hover { opacity: 0.85; }
.toast.success {
  background: #f6ffed;
  color: #389e0d;
  border: 1px solid #b7eb8f;
}
.toast.error {
  background: #fff2f0;
  color: #cf1322;
  border: 1px solid #ffa39e;
}
.toast.warning {
  background: #fffbe6;
  color: #d48806;
  border: 1px solid #ffe58f;
}
.toast.info {
  background: #e6f7ff;
  color: #0050b3;
  border: 1px solid #91d5ff;
}
.toast-icon {
  font-size: 15px;
  flex-shrink: 0;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==================== 4. 空状态 ==================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--text-muted);
  text-align: center;
}
.empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.3;
}
.empty-state .empty-title {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.empty-state .empty-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ==================== 5. 骨架屏 ==================== */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeletonShine 1.5s ease infinite;
  border-radius: 4px;
}
@keyframes skeletonShine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-row {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
}
.skeleton-cell {
  height: 14px;
  border-radius: 3px;
}

/* ==================== 6. 按钮增强 ==================== */
.btn {
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn .btn-spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 4px;
  vertical-align: middle;
}

/* ==================== 7. 表单增强 ==================== */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
}
.form-input, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(82,196,26,0.15);
}
.form-input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(255,77,79,0.15);
}
.form-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: 3px;
}

/* ==================== 8. 侧边栏增强 ==================== */
.nav-group-title {
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}
.nav-group-title:hover {
  color: #aaa;
}
.nav-group-title::after {
  content: '';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-top-color: #888;
  transition: transform 0.2s;
}
.nav-group-title.collapsed::after {
  transform: translateY(-50%) rotate(-90deg);
}

/* 侧边栏用户头像 */
.sidebar-user {
  padding: 10px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 12px;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 10px;
  color: #888;
}

/* ==================== 9. 表格增强 ==================== */
table.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 20px;
}
table.data-table th.sortable::after {
  content: '⇅';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #ccc;
}
table.data-table th.sortable.asc::after {
  content: '↑';
  color: var(--primary);
}
table.data-table th.sortable.desc::after {
  content: '↓';
  color: var(--primary);
}
table.data-table tr {
  transition: background 0.1s;
}
table.data-table td {
  transition: background 0.1s;
}

/* 表格行操作按钮 */
.row-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
table.data-table tr:hover .row-actions {
  opacity: 1;
}

/* ==================== 10. 模态框增强 ==================== */
.modal-overlay {
  transition: opacity 0.2s;
  opacity: 0;
}
.modal-overlay.show {
  opacity: 1;
}
.modal {
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ==================== 11. 卡片增强 ==================== */
.stat-card {
  transition: box-shadow 0.2s, transform 0.15s;
}
.stat-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

/* ==================== 12. 快捷键提示 ==================== */
.kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 11px;
  background: #f5f5f5;
  border: 1px solid #d9d9d9;
  border-radius: 3px;
  color: var(--text-secondary);
  font-family: monospace;
}

/* ==================== 13. 标签页增强 ==================== */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  gap: 0;
}
.tab-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tab-item:hover {
  color: var(--text);
}
.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ==================== 14. 进度条 ==================== */
.progress-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar .progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ==================== 15. 工具提示 ==================== */
[data-tooltip] {
  position: relative;
}
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 11px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  margin-bottom: 4px;
}

/* ==================== 16. 响应式增强 ==================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 199;
    display: none;
  }
  .sidebar-overlay.active {
    display: block;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .modal {
    margin: 10px;
    max-height: 90vh;
  }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr;
  }
  .page {
    padding: 12px;
  }
  .toast {
    left: 10px;
    right: 10px;
    max-width: none;
  }
}

/* 移动端菜单按钮（默认隐藏） */
.mobile-menu-btn {
  display: none;
  width: 36px; height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
}

/* ==================== 17. 登录页增强 ==================== */
.login-page .form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(82,196,26,0.12);
}
.login-page .btn-primary {
  height: 40px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 1px;
}
.login-error {
  color: var(--danger);
  font-size: 12px;
  text-align: center;
  min-height: 18px;
  margin-top: 4px;
}

/* ==================== 18. 数字变化动画 ==================== */
.number-change {
  transition: color 0.3s;
}
.number-change.increase {
  color: var(--primary-dark) !important;
}
.number-change.decrease {
  color: var(--danger) !important;
}
