/* ============================================
   前端全局样式 - 杂盒子插件站
   灰色调，简洁风格，去AI味
   ============================================ */

/* --- CSS 变量定义 --- */
:root {
  --primary: #4A5568;
  --primary-light: #EDF2F7;
  --primary-dark: #2D3748;
  --secondary: #718096;
  --warning: #D69E2E;
  --danger: #C53030;
  --success: #38A169;

  --bg-main: #F5F7FA;
  --bg-card: #FFFFFF;
  --bg-hover: #F7FAFC;
  --border: #E2E8F0;
  --border-light: #EDF2F7;

  --text-primary: #1A202C;
  --text-secondary: #4A5568;
  --text-hint: #A0AEC0;
  --text-disabled: #CBD5E0;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.10);

  --sidebar-width: 240px;
  --header-height: 56px;
}

/* --- 全局重置 --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- 滚动条样式 --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-disabled);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-hint);
}

/* --- 链接样式 --- */
a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-dark);
}

/* --- 表格样式 --- */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
}

.table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
}

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

.table tr:hover td {
  background: var(--bg-hover);
}

/* --- 输入框样式 --- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-card);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(113, 128, 150, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-hint);
}

/* --- 文本截断 --- */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- 卡片悬浮效果 --- */
.card-hover {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* --- 代码字体 --- */
code,
pre,
.font-mono {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}

/* --- 按钮基础样式 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--text-hint);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-success {
  background: var(--success);
  color: #FFFFFF;
}

.btn-success:hover:not(:disabled) {
  opacity: 0.9;
}

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

.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
}

/* --- 表单提示 --- */
.form-hint {
  font-size: 12px;
  color: var(--text-hint);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* --- 状态标签 --- */
.status-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.status-tag-success {
  background: #E6FFFA;
  color: #276749;
}

.status-tag-warning {
  background: #FFFAF0;
  color: #975A16;
}

.status-tag-danger {
  background: #FFF5F5;
  color: #9B2C2C;
}

.status-tag-info {
  background: #EBF8FF;
  color: #2C5282;
}

.status-tag-default {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* --- 空状态 --- */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-hint);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state .empty-text {
  font-size: 14px;
}

/* --- 分页样式 --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 0;
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-card);
  transition: all 0.2s ease;
}

.pagination a:hover {
  border-color: var(--secondary);
  color: var(--primary);
  background: var(--bg-hover);
}

.pagination .active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

.pagination .disabled {
  color: var(--text-disabled);
  cursor: not-allowed;
}

.pagination-ellipsis {
  border: none !important;
  background: transparent !important;
}

/* --- 后台侧边栏滚动条 --- */
.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* --- 闪存消息 --- */
.flash-message {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.flash-success {
  background: #F0FFF4;
  color: #276749;
  border: 1px solid #C6F6D5;
}

.flash-error {
  background: #FFF5F5;
  color: #9B2C2C;
  border: 1px solid #FED7D7;
}

.flash-warning {
  background: #FFFAF0;
  color: #975A16;
  border: 1px solid #FEEBC8;
}

.flash-info {
  background: #EBF8FF;
  color: #2C5282;
  border: 1px solid #BEE3F8;
}

/* --- 授权码显示 --- */
.license-code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-primary);
  background: var(--bg-hover);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  display: inline-block;
  user-select: all;
}

/* --- 价格显示 --- */
.price {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.price-free {
  font-size: 24px;
  font-weight: 700;
  color: var(--success);
}

.price-symbol {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-hint);
}

/* --- 插件卡片 --- */
.plugin-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.plugin-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.plugin-card .plugin-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--bg-hover);
  color: var(--secondary);
}

/* --- 后台布局 --- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--primary-dark);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.admin-sidebar .sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 14px;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.admin-sidebar .nav-item:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.05);
}

.admin-sidebar .nav-item.active {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.08);
  border-left-color: var(--secondary);
}

.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.admin-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.admin-content {
  padding: 24px;
  flex: 1;
}

/* --- 前台顶部导航 --- */
.site-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .nav-link {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.site-header .nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.site-header .nav-link.active {
  color: var(--primary);
  font-weight: 500;
}

/* --- 统计卡片 --- */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-hint);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--bg-hover);
  color: var(--secondary);
}

/* --- 柱状图 --- */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 180px;
  padding: 16px 0;
}

.bar-chart .bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.bar-chart .bar {
  width: 100%;
  max-width: 40px;
  background: var(--secondary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height 0.3s ease;
  min-height: 2px;
}

.bar-chart .bar:hover {
  background: var(--primary);
}

.bar-chart .bar-label {
  font-size: 11px;
  color: var(--text-hint);
}

.bar-chart .bar-value {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- 徽章 --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-success {
  background: #E6FFFA;
  color: #276749;
}

.badge-warning {
  background: #FFFAF0;
  color: #975A16;
}

.badge-danger {
  background: #FFF5F5;
  color: #9B2C2C;
}

/* --- Toast 提示 --- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
}

.toast-success {
  background: var(--success);
  color: #FFFFFF;
}

.toast-error {
  background: var(--danger);
  color: #FFFFFF;
}

.toast-info {
  background: var(--primary);
  color: #FFFFFF;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* --- 响应式 --- */
@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
  }

  .admin-content {
    padding: 16px;
  }

  .table {
    font-size: 13px;
  }

  .table th,
  .table td {
    padding: 8px 10px;
  }
}
