/* ============================================================
   轩辕财务系统 v3.0 — 全局主题样式
   设计灵魂：黑色商务感 · 极简高级 · 黑白金配色
   铁律：禁止大面积色块（绿/红/金），所有强调通过「描边 + 留白」
   ============================================================ */

/* ---------- 色彩变量 ---------- */
:root {
  --bg-primary: #0A0A0A;        /* 近黑背景（后台/深色模式） */
  --bg-white: #FFFFFF;          /* 纯白背景（前台主背景） */
  --bg-light: #F8F8F8;          /* 浅灰背景（卡片/表格交替） */
  --bg-hover: #F5F5F5;          /* 表格hover背景 */

  --text-primary: #000000;      /* 纯黑文字 */
  --text-white: #FFFFFF;          /* 纯白文字 */
  --text-secondary: #666666;    /* 次要文字 */
  --text-muted: #9E9E9E;        /* 禁用/辅助文字 */

  --gold: #D4AF37;              /* 香槟金：仅描边/图标/关键数字 */
  --gold-light: #E8C84D;        /* 金色hover */
  --gold-bg: rgba(212,175,55,0.05); /* 金色极淡背景 */

  --green: #2E7D32;             /* 墨绿：仅限描边/小图标 */
  --green-light: #4CAF50;       /* 绿色hover */

  --red: #C62828;               /* 暗红：仅限描边/小图标 */
  --red-light: #E53935;         /* 红色hover */

  --border: #E0E0E0;            /* 默认边框 */
  --border-light: #F0F0F0;      /* 浅色边框 */
  --border-gold: #D4AF37;       /* 金色边框 */

  --radius-sm: 4px;             /* 微圆角 */
  --radius-md: 6px;             /* 中等圆角 */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease-out;
}

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  color: var(--text-primary);
  background: var(--bg-white);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- 排版 ---------- */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }

p { margin-bottom: 0.5rem; }

a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover { color: var(--gold); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: none;
  white-space: nowrap;
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(212,175,55,0.3);
}

/* 主要按钮：金色描边 + 金色文字 */
.btn-primary {
  border-color: var(--gold);
  color: var(--gold);
  background: transparent;
}

.btn-primary:hover {
  background: var(--gold-bg);
  border-color: var(--gold-light);
  color: var(--gold-light);
}

/* 次要按钮：灰色描边 */
.btn-secondary {
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

/* 危险按钮：暗红描边 */
.btn-danger {
  border-color: var(--red);
  color: var(--red);
}

.btn-danger:hover {
  background: rgba(198,40,40,0.05);
  border-color: var(--red-light);
}

/* 成功按钮：墨绿描边 */
.btn-success {
  border-color: var(--green);
  color: var(--green);
}

.btn-success:hover {
  background: rgba(46,125,50,0.05);
  border-color: var(--green-light);
}

/* 文字按钮（无框） */
.btn-text {
  border: none;
  padding: 0.25rem 0.5rem;
  color: var(--text-secondary);
}

.btn-text:hover { color: var(--gold); }

/* 按钮尺寸 */
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.625rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* 按钮禁用 */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- 输入框 ---------- */
.input,
.select,
.textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 1px 0 0 var(--gold); /* 金色下划线 */
}

/* 数字输入框：聚焦时金色下划线呼吸灯效果 */
@keyframes breathe-gold {
  0%, 100% { box-shadow: 0 1px 0 0 var(--gold); }
  50% { box-shadow: 0 2px 0 0 var(--gold-light), 0 0 4px rgba(212,175,55,0.3); }
}

.input-number:focus {
  animation: breathe-gold 2s ease-in-out infinite;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:disabled,
.select:disabled {
  background: var(--bg-light);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* 输入框错误状态（红色描边） */
.input-error {
  border-color: var(--red) !important;
}

.input-error:focus {
  box-shadow: 0 1px 0 0 var(--red) !important;
}

/* 输入框成功状态（绿色描边） */
.input-success {
  border-color: var(--green) !important;
}

.input-success:focus {
  box-shadow: 0 1px 0 0 var(--green) !important;
}

/* 表单标签 */
.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group {
  margin-bottom: 1rem;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: box-shadow var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
}

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  background: var(--bg-light);
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

/* 表格行hover：背景色微变 */
.table tbody tr {
  transition: background var(--transition-fast);
}

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

/* ---------- 侧滑菜单（Drawer）---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  background: var(--bg-primary);
  color: var(--text-white);
  z-index: 999;
  transition: transform var(--transition-normal);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* 移动端：全屏侧滑 */
.drawer-mobile {
  width: 80%;
  max-width: 280px;
  transform: translateX(-100%);
}

.drawer-mobile.open {
  transform: translateX(0);
}

/* 桌面端：左侧常驻窄边栏 */
.drawer-desktop {
  width: 60px;
  transition: width var(--transition-normal);
}

.drawer-desktop:hover {
  width: 200px;
}

.drawer-desktop .drawer-text {
  opacity: 1;
  width: auto;
  overflow: hidden;
  transition: opacity var(--transition-fast);
}

.drawer-desktop:hover .drawer-text {
  opacity: 1;
  width: auto;
}

/* 汉堡按钮 */
.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 1rem;
  cursor: pointer;
  background: none;
  border: none;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: all var(--transition-fast);
}

.hamburger:hover span {
  background: var(--gold);
}

/* 菜单项 */
.drawer-menu {
  list-style: none;
  padding: 0.5rem 0;
  flex: 1;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.drawer-item:hover,
.drawer-item.active {
  color: var(--gold);
  background: rgba(212,175,55,0.08);
  border-left: 3px solid var(--gold);
}

.drawer-item i {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

/* ---------- 弹窗（Modal）---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(10px); /* 毛玻璃背景 */
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition-normal);
  position: relative;
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

/* 金色顶部细线装饰 */
.modal-card::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.modal-close:hover {
  color: var(--red);
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-light);
}

/* ---------- Toast提示 ---------- */
.toast-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.3s ease-out;
  pointer-events: auto;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-success {
  border: 1px solid var(--green);
  color: var(--green);
  background: rgba(46,125,50,0.05);
}

.toast-error {
  border: 1px solid var(--red);
  color: var(--red);
  background: rgba(198,40,40,0.05);
}

.toast-info {
  border: 1px solid var(--gold);
  color: var(--gold);
  background: var(--gold-bg);
}

/* ---------- 状态标记 ---------- */
/* 成功/通过：绿色描边小圆点 */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid;
  flex-shrink: 0;
}

.status-dot.success {
  border-color: var(--green);
  background: transparent;
}

.status-dot.error {
  border-color: var(--red);
  background: transparent;
}

/* 文字状态标签 */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 100px;
  border: 1px solid;
  font-weight: 500;
  white-space: nowrap;
  vertical-align: middle;
}

.status-tag.success {
  border-color: var(--green);
  color: var(--green);
}

.status-tag.error {
  border-color: var(--red);
  color: var(--red);
}

.status-tag.warning {
  border-color: var(--gold);
  color: var(--gold);
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  justify-content: center;
  padding: 1rem 0;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  background: var(--bg-white);
  transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.page-btn.active {
  border-color: var(--gold);
  background: var(--gold-bg);
  color: var(--gold);
  font-weight: 600;
}

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

/* ---------- 加载动画 ---------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* 后台卡片（深色模式专用） */
.admin-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.admin-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* 后台表格包装器 */
.admin-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.08);
}

/* 后台专用表格 */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table th {
  background: rgba(255,255,255,0.05);
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  vertical-align: middle;
}

.admin-table td {
  padding: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.85);
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

/* 成功按钮（绿色描边） */
.btn-success {
  border-color: var(--green);
  color: var(--green);
  background: transparent;
}

.btn-success:hover {
  background: rgba(46,125,50,0.05);
  border-color: var(--green-light);
}

/* 危险按钮（红色描边） */
.btn-danger {
  border-color: var(--red);
  color: var(--red);
  background: transparent;
}

.btn-danger:hover {
  background: rgba(198,40,40,0.05);
  border-color: var(--red-light);
}

/* 统计网格（仪表盘用） */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  margin-top: 0.5rem;
}

/* 信息网格（user.php 用） */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.info-item .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.info-item .value {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}

.info-item .value.empty {
  color: var(--text-muted);
  font-weight: 400;
}

/* ---------- 页面切换动画 ---------- */
.page-enter {
  animation: page-in 0.3s ease-out;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 自己/许金色标记 ---------- */
.self-marker {
  display: inline-flex;
  align-items: center;
  padding-left: 0.5rem;
  border-left: 3px solid var(--gold);
  background: var(--gold-bg);
}

.self-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--gold);
  color: var(--bg-primary);
  font-size: 0.625rem;
  font-weight: 700;
  border-radius: 2px;
  margin-right: 0.5rem;
}

/* ---------- 布局工具 ---------- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

.text-center { text-align: center; }
.text-right { text-align: right; }

.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

/* 数字高亮（金色） */
.number-gold {
  color: var(--gold);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 金额显示 */
.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* 隐藏 */
.hidden { display: none !important; }

/* ---------- 响应式断点 ---------- */
@media (min-width: 768px) {
  .mobile-only { display: none !important; }
}

@media (max-width: 767px) {
  .desktop-only { display: none !important; }

  .container {
    padding: 0 0.75rem;
  }

  .drawer-desktop {
    display: none;
  }

  .table-wrap {
    margin: 0 -0.75rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .modal-card {
    max-width: 100%;
    max-height: 100vh;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }

  .modal-overlay.open .modal-card {
    transform: translateY(0);
  }
}

/* 桌面端 */
@media (min-width: 768px) {
  .drawer-mobile {
    display: none;
  }

  .has-drawer-desktop {
    padding-left: 60px;
  }

  .has-drawer-desktop:hover {
    padding-left: 200px;
  }
}
