/**
 * 系统账户报表Tab样式
 * [2026-01-04] 新增：用于系统账户报表显示
 * 回滚方式：删除此文件
 */
@use '@/styles/variables' as *;
@use '@/styles/mixins' as *;

.container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* 加载状态 */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  gap: 16px;
  color: #6b7280;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* 错误状态 */
.error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  gap: 16px;
  color: #ef4444;
}

.retryButton {
  padding: 8px 16px;
  background-color: #3b82f6;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;

  &:hover {
    background-color: #2563eb;
  }
}

/* 空状态 */
.empty {
  text-align: center;
  padding: 48px;
  color: #9ca3af;
}

/* Tab 切换 */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background-color: #f3f4f6;
  border-radius: 8px;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 16px;
  background-color: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #4b5563;
  transition: all 0.2s ease;

  &:hover {
    background-color: rgba(255, 255, 255, 0.5);
  }

  &.active {
    background-color: #fff;
    color: #1f2937;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }
}

/* 内容区域 */
.content {
  background-color: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 区块标题 */
.section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sectionTitle {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.subTitle {
  margin: 16px 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: #374151;
}

/* 卡片网格 */
.cardGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

/* 账户卡片 */
.accountCard {
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cardHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.accountInfo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: #f3f4f6;
  border-radius: 6px;
}

.accountLabel {
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
}

.accountValue {
  font-size: 14px;
  color: #374151;
  font-family: monospace;
  background: #fff;
  padding: 2px 8px;
  border-radius: 4px;
}

.accountSequence {
  font-size: 12px;
  color: #9ca3af;
  font-family: monospace;
}

.cardBody {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.statRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.statLabel {
  font-size: 13px;
  color: #6b7280;
}

.statValue {
  font-size: 14px;
  font-weight: 500;
  color: #1f2937;
}

/* 汇总卡片 */
.summaryCards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.summaryCard {
  flex: 1;
  min-width: 150px;
  background-color: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summaryLabel {
  font-size: 13px;
  color: #0369a1;
}

.summaryValue {
  font-size: 20px;
  font-weight: 600;
  color: #0c4a6e;
}

/* 表格 */
.tableWrapper {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;

  th,
  td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
  }

  th {
    background-color: #f9fafb;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
  }

  td {
    color: #4b5563;
  }

  tbody tr:hover {
    background-color: #f9fafb;
  }
}

.emptyTable {
  text-align: center;
  padding: 32px;
  color: #9ca3af;
  background-color: #f9fafb;
  border-radius: 8px;
}

/* 状态标签 */
.statusBadge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 4px;
  background-color: #e5e7eb;
  color: #4b5563;

  &.active {
    background-color: #dcfce7;
    color: #166534;
  }

  /* [2026-01-06] 新增：收益状态样式 */
  &.settled {
    background-color: #dcfce7;
    color: #166534;
  }

  &.expired {
    background-color: #fee2e2;
    color: #991b1b;
  }

  &.pending {
    background-color: #fef3c7;
    color: #92400e;
  }
}

/* [2026-01-07] 新增：明细列表切换区域样式 */
.toggleSection {
  margin-top: 16px;
  text-align: center;
}

.toggleButton {
  padding: 8px 20px;
  background-color: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;

  &:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
  }
}

.entriesSection {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.entriesHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.filterGroup {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #374151;

  label {
    font-weight: 500;
  }
}

.filterSelect {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  background-color: #fff;
  cursor: pointer;

  &:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
  }
}

.paginationInfo {
  text-align: center;
  padding: 12px;
  font-size: 13px;
  color: #6b7280;
  background-color: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

/* 页脚 */
.footer {
  text-align: right;
  font-size: 12px;
  color: #9ca3af;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

/* [2026-01-05] 新增：分类账明细样式 */
.sectionHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.refreshButton {
  padding: 6px 12px;
  background-color: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;

  &:hover {
    background-color: #e5e7eb;
  }
}

.ledgerGroup {
  margin-top: 16px;
}

.ledgerCard {
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.ledgerCardHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  background-color: #fff;
  border-bottom: 1px solid #e5e7eb;
  transition: background-color 0.2s ease;

  &:hover {
    background-color: #f9fafb;
  }
}

.ledgerCardTitle {
  display: flex;
  align-items: center;
  gap: 12px;

  .accountName {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
  }

  .accountSequence {
    font-size: 12px;
    color: #9ca3af;
    font-family: monospace;
  }
}

.ledgerCardInfo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ledgerCount {
  font-size: 13px;
  color: #6b7280;
}

.expandIcon {
  font-size: 12px;
  color: #9ca3af;
}

.ledgerCardBody {
  padding: 16px;
  background-color: #fff;
}

.emptyLedger {
  text-align: center;
  padding: 24px;
  color: #9ca3af;
  font-size: 14px;
}

.entryTypeBadge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 4px;
  background-color: #e5e7eb;
  color: #4b5563;
}

.amountPositive {
  color: #059669;
  font-weight: 500;
}

.amountNegative {
  color: #dc2626;
  font-weight: 500;
}

.memo {
  font-size: 13px;
  color: #6b7280;
  word-break: break-word;
}

.sourceAccount {
  font-size: 13px;
  font-family: monospace;
  color: #374151;
}

/* [2026-01-06] 新增：详细明细列表样式 */
.detailsSection {
  margin-top: 24px;
  border-top: 1px solid #e5e7eb;
  padding-top: 16px;
}

.toggleDetailsButton {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;

  &:hover {
    background-color: #e5e7eb;
  }
}

.detailsContent {
  margin-top: 16px;
}

.orderId {
  font-family: monospace;
  font-size: 12px;
  color: #6b7280;
}

.statusBadge {
  &.settled {
    background-color: #dcfce7;
    color: #166534;
  }
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding: 12px;
  background-color: #f9fafb;
  border-radius: 8px;
}

.pageButton {
  padding: 6px 14px;
  background-color: #fff;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;

  &:hover:not(:disabled) {
    background-color: #f3f4f6;
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.pageInfo {
  font-size: 13px;
  color: #6b7280;
}

/* [2026-01-07] 新增：固定账户卡片底部样式 */
.cardFooter {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.viewLedgerButton {
  width: 100%;
  padding: 8px 12px;
  background-color: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;

  &:hover:not(:disabled) {
    background-color: #e5e7eb;
    border-color: #9ca3af;
  }

  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }

  &Active {
    background-color: #3b82f6;
    color: #fff;
    border-color: #3b82f6;

    &:hover:not(:disabled) {
      background-color: #2563eb;
      border-color: #2563eb;
    }
  }
}

/* [2026-01-07] 新增：选中卡片样式 */
.accountCardSelected {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* [2026-01-07] 更新：公共明细区域样式 */
.sharedLedgerSection {
  margin-top: 24px;
  padding: 20px;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.sharedLedgerHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.sharedLedgerTitle {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.closeLedgerButton {
  padding: 6px 14px;
  background-color: #fff;
  color: #6b7280;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;

  &:hover {
    background-color: #f3f4f6;
    color: #374151;
  }
}

/* [2026-02-28] 新增：区域账户表格行可点击样式 */
.clickableRow {
  cursor: pointer;
  transition: background-color 0.15s ease;

  &:hover {
    background-color: #eff6ff !important;
  }
}

.selectedRow {
  cursor: pointer;
  background-color: #eff6ff !important;
  border-left: 3px solid #3b82f6;
}

.accountLedgerSection {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  max-height: 400px;
  overflow-y: auto;

  .table {
    font-size: 12px;

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