/**
 * 管理后台 - 样式表
 * 与现有Tailwind CSS配合使用，提供Admin模块专用样式
 */

/* ============================================================
   Admin布局
   ============================================================ */

/* Admin容器 - 左侧固定侧栏 + 右侧内容区 */
.admin-container {
  display: flex;
  min-height: calc(100vh - 57px); /* 减去顶部header高度 */
}

/* 左侧Admin导航栏 */
.admin-sidebar {
  width: 220px;
  min-width: 220px;
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
  position: fixed;
  left: 256px; /* 主站侧栏宽度 */
  top: 57px;   /* 主站header高度 */
  bottom: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 30;
}

/* 右侧内容区 */
.admin-content {
  flex: 1;
  margin-left: 476px; /* 主站侧栏(256px) + Admin侧栏(220px) */
  padding: 24px;
  min-height: calc(100vh - 57px);
}

/* Admin侧栏导航项 */
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: #c7d2fe;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  user-select: none;
}

.admin-nav-item:hover {
  background: rgba(129, 140, 248, 0.1);
  color: #a5b4fc;
}

.admin-nav-item.active {
  background: rgba(129, 140, 248, 0.2);
  color: #ffffff;
  border-left-color: #818cf8;
  font-weight: 600;
}

/* Admin Logo/标题 */
.admin-sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(129, 140, 248, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-sidebar-title {
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
}

.admin-sidebar-subtitle {
  color: rgba(199, 210, 254, 0.5);
  font-size: 11px;
}

/* ============================================================
   Admin统计卡片
   ============================================================ */
.admin-stat-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  transition: all 0.3s;
}

.admin-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.1);
}

.admin-stat-label {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-stat-value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 4px;
  color: #1e293b;
}

.admin-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* ============================================================
   V2 统计卡片（彩色竖条 + 环比箭头）
   ============================================================ */
.admin-stat-card-v2 {
  background: #ffffff;
  border-radius: 14px;
  padding: 18px 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-left-width: 4px;
  border-left-style: solid;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.25s;
}
.admin-stat-card-v2:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}
.border-l-indigo-500 { border-left-color: #6366f1; }
.border-l-emerald-500 { border-left-color: #10b981; }
.border-l-amber-500 { border-left-color: #f59e0b; }
.border-l-rose-500 { border-left-color: #f43f5e; }
.border-l-orange-500 { border-left-color: #f97316; }
.border-l-purple-500 { border-left-color: #a855f7; }

.admin-stat-card-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.admin-stat-label-v2 {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}
.admin-stat-value-v2 {
  font-size: 26px;
  font-weight: 800;
  font-family: 'Inter', 'PingFang SC', sans-serif;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}
.admin-stat-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  flex-wrap: wrap;
}
.admin-stat-period {
  color: #94a3b8;
}
.admin-stat-period-val {
  font-weight: 600;
  color: #475569;
}
.admin-stat-arrow {
  font-weight: 700;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
}
.admin-stat-arrow.up {
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}
.admin-stat-arrow.down {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.admin-stat-icon-v2 {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* 图表加载失败提示 */
.admin-chart-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: #94a3b8;
  font-size: 13px;
}

/* ============================================================
   Admin表格
   ============================================================ */
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.admin-table thead tr {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
}

.admin-table thead th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
}

.admin-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s;
}

.admin-table tbody tr:hover {
  background: #f8fafc;
}

.admin-table tbody td {
  padding: 12px 16px;
  font-size: 13px;
  color: #475569;
}

/* ============================================================
   Admin表单元素
   ============================================================ */
.admin-input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  background: #f8fafc;
  transition: all 0.2s;
  color: #1e293b;
}

.admin-input:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
  background: #ffffff;
}

.admin-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 36px;
}

/* ============================================================
   Admin按钮
   ============================================================ */
.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  white-space: nowrap;
}

.admin-btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
}

.admin-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 15px -3px rgba(102, 126, 234, 0.4);
}

.admin-btn-danger {
  background: #ef4444;
  color: #ffffff;
}

.admin-btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 6px 15px -3px rgba(239, 68, 68, 0.4);
}

.admin-btn-success {
  background: #10b981;
  color: #ffffff;
}

.admin-btn-success:hover {
  background: #059669;
}

.admin-btn-warning {
  background: #f59e0b;
  color: #ffffff;
}

.admin-btn-warning:hover {
  background: #d97706;
}

.admin-btn-ghost {
  background: transparent;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.admin-btn-ghost:hover {
  background: #f1f5f9;
  color: #475569;
}

/* ============================================================
   Admin徽章
   ============================================================ */
.admin-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-badge-success { background: #d1fae5; color: #065f46; }
.admin-badge-danger { background: #fee2e2; color: #991b1b; }
.admin-badge-warning { background: #fef3c7; color: #92400e; }
.admin-badge-info { background: #dbeafe; color: #1e40af; }
.admin-badge-neutral { background: #f1f5f9; color: #475569; }
.admin-badge-purple { background: #f3e8ff; color: #6b21a8; }

/* ============================================================
   Admin模块标题区
   ============================================================ */
.admin-page-header {
  margin-bottom: 24px;
}

.admin-page-title {
  font-size: 22px;
  font-weight: 800;
  color: #1e293b;
}

.admin-page-subtitle {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 4px;
}

/* ============================================================
   Admin过滤区
   ============================================================ */
.admin-filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

/* ============================================================
   Admin分页
   ============================================================ */
.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.admin-pagination button {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-pagination button:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

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

.admin-pagination button.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  border-color: transparent;
}

/* ============================================================
   Admin卡片面板
   ============================================================ */
.admin-panel {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.admin-panel-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   Admin加载状态
   ============================================================ */
.admin-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #94a3b8;
  font-size: 14px;
  gap: 10px;
}

.admin-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: admin-spin 0.8s linear infinite;
}

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

/* ============================================================
   Admin Tab标签（财务模块内切换）
   ============================================================ */
.admin-sub-tabs {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.admin-sub-tab {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: transparent;
}

.admin-sub-tab:hover {
  color: #475569;
}

.admin-sub-tab.active {
  background: #ffffff;
  color: #667eea;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ============================================================
   Admin空状态
   ============================================================ */
.admin-empty {
  text-align: center;
  padding: 60px 20px;
  color: #cbd5e1;
}

.admin-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.admin-empty-text {
  font-size: 14px;
  color: #94a3b8;
}

/* ============================================================
   响应式：移动端适配
   ============================================================ */
@media (max-width: 1024px) {
  /* 移动端：Admin侧栏折叠为顶部横向Tab */
  .admin-container {
    flex-direction: column;
    min-height: auto;
  }

  .admin-sidebar {
    position: fixed;
    left: 0;
    top: 60px; /* 移动端顶部导航高度 */
    width: 100%;
    height: auto;
    min-width: unset;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 40;
    border-bottom: 1px solid rgba(129, 140, 248, 0.2);
  }

  .admin-sidebar-header {
    display: none;
  }

  .admin-nav-item {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 12px;
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }

  .admin-nav-item.active {
    border-left: none;
    border-bottom-color: #818cf8;
  }

  .admin-content {
    margin-left: 0;
    margin-top: 110px; /* 顶部header + Admin横向Tab */
    padding: 16px;
    min-height: auto;
  }

  /* Admin统计卡片在移动端改为2列 */
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 640px) {
  .admin-stats-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .admin-table {
    font-size: 11px;
  }

  .admin-table thead th,
  .admin-table tbody td {
    padding: 8px 10px;
  }

  .admin-page-title {
    font-size: 18px;
  }
}

/* ============================================================
   Admin设置项
   ============================================================ */
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid #f1f5f9;
}

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

.settings-item-label {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.settings-item-desc {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

/* ============================================================
   Admin公告编辑
   ============================================================ */
.announcement-editor {
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.announcement-editor textarea {
  width: 100%;
  min-height: 80px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  resize: vertical;
  background: #ffffff;
  color: #1e293b;
  font-family: inherit;
}

.announcement-editor textarea:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

/* ============================================================
   毛玻璃卡片 V2
   ============================================================ */
.admin-card-glass {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.06), 0 1px 3px rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}

.admin-card-glass::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, rgba(129,140,248,0.6), rgba(118,75,162,0.4), transparent);
  border-radius: 0 0 0 0;
}

.admin-card-glass:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(102, 126, 234, 0.12), 0 2px 6px rgba(0,0,0,0.06);
}

/* ============================================================
   实时数据条
   ============================================================ */
.admin-realtime-strip {
  display: flex;
  gap: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 20px;
  overflow: hidden;
}

.admin-realtime-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  color: #ffffff;
  position: relative;
}

.admin-realtime-item:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0; top: 25%; bottom: 25%;
  width: 1px;
  background: rgba(255,255,255,0.2);
}

.admin-realtime-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.admin-realtime-label {
  font-size: 11px;
  opacity: 0.85;
  font-weight: 500;
}

.admin-realtime-value {
  font-size: 16px;
  font-weight: 800;
}

/* ============================================================
   快捷操作栏
   ============================================================ */
.admin-quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}

.admin-quick-btn:hover {
  border-color: #818cf8;
  color: #667eea;
  background: rgba(129,140,248,0.04);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

/* ============================================================
   SVG 仪表盘刻度环
   ============================================================ */
.admin-gauge-ring circle:first-child {
  fill: none;
}
.admin-gauge-ring circle:last-child {
  fill: none;
  transition: stroke-dasharray 0.8s ease;
}

/* ============================================================
   加强响应式
   ============================================================ */
@media (max-width: 1024px) {
  .admin-realtime-strip {
    flex-wrap: wrap;
    border-radius: 12px;
  }
  .admin-realtime-item {
    flex: 1 1 50%;
    padding: 10px 12px;
  }
  .admin-realtime-item:nth-child(2)::after {
    display: none;
  }
  .admin-card-glass {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (max-width: 640px) {
  .admin-quick-actions {
    flex-direction: column;
    gap: 6px;
  }
  .admin-quick-btn {
    justify-content: center;
  }
  .admin-realtime-item {
    flex: 1 1 100%;
  }
  .admin-realtime-item::after {
    display: none !important;
  }
  .admin-realtime-item:not(:last-child) {
    border-bottom: 1px solid rgba(255,255,255,0.15);
  }
  /* 表格横向滚动 */
  .admin-panel,
  div:has(> .admin-table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .admin-table {
    min-width: 600px;
  }
}
