/* ============================================================
   全局重置 & 基础变量
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --sider-width: 240px;
  --header-height: 56px;

  /* 侧栏色 */
  --sider-bg: #111827;
  --sider-border: rgba(255,255,255,0.06);
  --sider-logo-text: #f9fafb;

  /* 导航 */
  --nav-item-color: #9ca3af;
  --nav-item-hover-bg: rgba(255,255,255,0.05);
  --nav-item-hover-color: #e5e7eb;
  --nav-active-bg: rgba(99,102,241,0.15);
  --nav-active-color: #a5b4fc;
  --nav-active-border: #6366f1;
  --nav-group-title-color: #4b5563;

  /* 顶栏 */
  --header-bg: #ffffff;
  --header-border: #e5e7eb;
  --header-shadow: 0 1px 3px rgba(0,0,0,0.06);

  /* 内容区 */
  --content-bg: #f3f4f6;
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --card-shadow: 0 1px 4px rgba(0,0,0,0.06);
  --card-radius: 10px;

  /* 品牌色 */
  --brand: #6366f1;
  --brand-hover: #4f46e5;
  --brand-light: rgba(99,102,241,0.08);

  /* 文字 */
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--content-bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* loader */
.loader {
  position: fixed; inset: 0;
  background: var(--sider-bg);
  z-index: 999;
}

#blazor-error-ui {
  background: #fef3c7;
  bottom: 0; left: 0;
  padding: 0.6rem 1.25rem 0.7rem;
  position: fixed; width: 100%;
  box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
  display: none; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ============================================================
   App Shell
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   侧栏
   ============================================================ */
.app-sider {
  width: var(--sider-width);
  background: var(--sider-bg);
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sider-border);
  overflow: hidden;
}

/* Logo */
.app-logo {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--sider-border);
  flex-shrink: 0;
}
.app-logo-text {
  color: var(--sider-logo-text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* 导航区 */
.app-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.app-nav::-webkit-scrollbar { width: 4px; }
.app-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

/* 分组标题 */
.nav-group { margin-bottom: 20px; }
.nav-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--nav-group-title-color);
  padding: 0 12px;
  margin-bottom: 6px;
}

.nav-group-title-icon {
  width: 12px;
  text-align: center;
  opacity: 0.9;
}

/* 导航项 */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--nav-item-color);
  font-size: 13.5px;
  font-weight: 450;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover {
  background: var(--nav-item-hover-bg);
  color: var(--nav-item-hover-color);
  text-decoration: none;
}
.nav-item--active {
  background: var(--nav-active-bg) !important;
  color: var(--nav-active-color) !important;
}
.nav-item--active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--nav-active-border);
  border-radius: 0 2px 2px 0;
}
.nav-item-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
  flex-shrink: 0;
  margin-left: 4px;
}
.nav-item--active .nav-item-dot { opacity: 1; background: var(--nav-active-border); }
.nav-item--top { margin-bottom: 4px; }
.nav-item-icon { display: flex; align-items: center; flex-shrink: 0; opacity: 0.7; }
.nav-item-icon {
  width: 14px;
  justify-content: center;
  font-size: 13px;
}
.nav-item--active .nav-item-icon { opacity: 1; color: var(--nav-active-color); }
.nav-item-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 侧栏底部 */
.app-sider-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--sider-border);
  flex-shrink: 0;
}
.sider-version {
  font-size: 11px;
  color: var(--nav-group-title-color);
}

/* ============================================================
   主体区域
   ============================================================ */
.app-main {
  flex: 1;
  margin-left: var(--sider-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 顶栏 */
.app-header {
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  box-shadow: var(--header-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0;
  z-index: 50;
  flex-shrink: 0;
}

/* 面包屑 */
.app-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13.5px;
}
.breadcrumb-home { display: flex; align-items: center; color: var(--text-muted); }
.breadcrumb-sep { color: var(--text-muted); }
.breadcrumb-current { color: var(--text-primary); font-weight: 500; }

/* 右侧操作 */
.app-header-right { display: flex; align-items: center; gap: 16px; }

/* 用户 */
.app-user { display: flex; align-items: center; gap: 8px; }
.app-user-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.app-user-name { font-size: 13.5px; color: var(--text-secondary); }

/* 退出按钮 */
.app-logout-btn {
  display: flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--card-border);
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.app-logout-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}
.app-login-link {
  color: var(--brand); font-weight: 500;
  text-decoration: none; font-size: 14px;
}
.app-login-link:hover { text-decoration: underline; }

/* 内容区 */
.app-content {
  flex: 1;
  padding: 24px;
  background: var(--content-bg);
}

/* ============================================================
   AntDesign 组件覆盖
   ============================================================ */

/* 卡片 */
.app-content .ant-card,
.ant-card {
  border-radius: var(--card-radius) !important;
  border: 1px solid var(--card-border) !important;
  box-shadow: var(--card-shadow) !important;
  background: var(--card-bg) !important;
}
.ant-card-head {
  border-bottom: 1px solid #f3f4f6 !important;
  padding: 0 20px !important;
  min-height: 50px !important;
}
.ant-card-head-title {
  font-size: 15px !important;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
  padding: 14px 0 !important;
}
.ant-card-body { padding: 20px !important; }

/* 表格 */
.ant-table-wrapper { border-radius: 8px; overflow: hidden; }
.ant-table { background: transparent !important; }
.ant-table-thead > tr > th {
  background: #f9fafb !important;
  color: #374151 !important;
  font-weight: 600 !important;
  font-size: 12.5px !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--card-border) !important;
  padding: 10px 16px !important;
}
.ant-table-tbody > tr > td {
  font-size: 13.5px !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid #f3f4f6 !important;
  padding: 11px 16px !important;
}
.ant-table-tbody > tr:last-child > td { border-bottom: none !important; }
.ant-table-tbody > tr:hover > td { background: #f5f3ff !important; }
.ant-table-tbody > tr.ant-table-row:hover > td { background: #f5f3ff !important; }
.ant-empty-description { color: var(--text-muted) !important; }
.ant-pagination { margin: 16px 0 4px !important; }

/* 按钮 */
.ant-btn {
  border-radius: 7px !important;
  font-size: 13.5px !important;
  height: 32px !important;
  padding: 0 14px !important;
  transition: all 0.15s !important;
  font-weight: 500 !important;
}
.ant-btn-primary {
  background: var(--brand) !important;
  border-color: var(--brand) !important;
  box-shadow: 0 1px 3px rgba(99,102,241,0.35) !important;
}
.ant-btn-primary:hover {
  background: var(--brand-hover) !important;
  border-color: var(--brand-hover) !important;
}
.ant-btn-dangerous {
  background: #fff !important;
  border-color: #fca5a5 !important;
  color: #ef4444 !important;
}
.ant-btn-dangerous:hover {
  border-color: #ef4444 !important;
  color: #ef4444 !important;
  background: #fff1f2 !important;
}
.ant-btn-sm { height: 28px !important; padding: 0 10px !important; font-size: 12.5px !important; }

/* 输入框 */
.ant-input,
.ant-input-affix-wrapper {
  border-radius: 7px !important;
  border-color: var(--card-border) !important;
  font-size: 13.5px !important;
  height: 32px !important;
  line-height: 32px !important;
  box-sizing: border-box !important;
  vertical-align: middle !important;
}
.ant-input-affix-wrapper > .ant-input {
  height: auto !important;
  line-height: inherit !important;
  vertical-align: inherit !important;
}
.ant-input:focus, .ant-input-affix-wrapper:focus,
.ant-input-focused, .ant-input-affix-wrapper-focused {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.1) !important;
}

/* Select */
.ant-select-selector {
  border-radius: 7px !important;
  border-color: var(--card-border) !important;
  font-size: 13.5px !important;
  min-height: 32px !important;
}
.ant-select-focused .ant-select-selector {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.1) !important;
}
.ant-select-item-option-selected:not(.ant-select-item-option-disabled) {
  background: var(--brand-light) !important;
  color: var(--brand) !important;
  font-weight: 500 !important;
}
.ant-select-item-option-active:not(.ant-select-item-option-disabled) {
  background: #f5f3ff !important;
}

/* 表单 */
.ant-form-item-label > label {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--text-secondary) !important;
}
.ant-form-item { margin-bottom: 16px !important; }

/* Modal */
.ant-modal-content { border-radius: 12px !important; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.15) !important; }
.ant-modal-header { border-bottom: 1px solid #f3f4f6 !important; padding: 16px 24px !important; }
.ant-modal-title { font-size: 16px !important; font-weight: 600 !important; color: var(--text-primary) !important; }
.ant-modal-body { padding: 20px 24px !important; }
.ant-modal-footer { border-top: 1px solid #f3f4f6 !important; padding: 12px 24px !important; }

/* Popconfirm */
.ant-popover-inner { border-radius: 10px !important; box-shadow: 0 8px 24px rgba(0,0,0,0.12) !important; }

/* Space */
.ant-space { gap: 10px !important; }

/* 查询区 label 不换行 */
.ant-space-item > span,
.ant-space-item > label {
  white-space: nowrap;
}
/* 查询区每个 Space Item 本身也不折行 */
.ant-space-item {
  white-space: nowrap;
  flex-shrink: 0;
}
/* 强制查询区行内元素文字不断词 */
.ant-card-body .ant-space span,
.ant-card-body .ant-space label {
  white-space: nowrap !important;
  word-break: keep-all !important;
}
/* 内层 ant-space（label+input组合）不换行 */
.ant-space .ant-space {
  flex-wrap: nowrap !important;
}
.ant-space .ant-space .ant-space-item {
  flex-shrink: 0 !important;
}

/* InputNumber */
.ant-input-number { border-radius: 7px !important; font-size: 13.5px !important; }
.ant-input-number-focused { border-color: var(--brand) !important; box-shadow: 0 0 0 2px rgba(99,102,241,0.1) !important; }

/* Tag */
.ant-tag { border-radius: 5px !important; font-size: 12px !important; }

/* Pagination */
.ant-pagination-item { border-radius: 7px !important; }
.ant-pagination-item-active { border-color: var(--brand) !important; }
.ant-pagination-item-active a { color: var(--brand) !important; }

/* Tooltip */
.ant-tooltip-inner { border-radius: 6px !important; font-size: 12.5px !important; }

/* 筛选区标签文字 */
.app-content span { font-size: 13.5px; }

/* 月度账单差异行标红 */
.text-danger { color: #ef4444 !important; }
.ant-table-row-danger { background-color: #fff1f2 !important; }
.ant-table-row-danger:hover > td { background-color: #ffe4e6 !important; }

/* LeptonX logo 变量 */
:root {
  --lpx-logo: url('/images/logo/leptonxlite/logo-light-thumbnail.png') !important;
  --lpx-logo-icon: url('/images/logo/leptonxlite/logo-light-thumbnail.png') !important;
}
:root .abp-account-layout .lpx-brand-logo {
  --lpx-logo: url('/images/logo/leptonxlite/logo-dark-thumbnail.png') !important;
  background-position: left;
}

/* 首屏加载动效 */
#app-loading.app-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--sider-bg);
  transition: opacity 0.35s ease-out, visibility 0.35s ease-out;
}
body.blazor-loaded #app-loading.app-loading {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.app-loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: app-loading-spin 0.85s linear infinite;
}
.app-loading-text {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.02em;
}
@keyframes app-loading-spin {
  to { transform: rotate(360deg); }
}
