/* ============================================================
   components.css · 通用组件:按钮/表单/卡片/徽章/表格/弹窗
   ============================================================ */

/* ---------- 面板/卡片 ---------- */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.panel h2 { font-size: 17px; margin-bottom: 14px; }
.panel h3 { font-size: 15px; margin: 16px 0 8px; }
.panel h4 { font-size: 13px; color: var(--text-secondary); margin: 10px 0 6px; }
.login-card { border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-pop); }

/* ---------- 表单 ---------- */
label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--text-secondary); }
input, select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: 14px; margin-top: 4px; font-family: inherit;
  color: var(--text-primary); background: var(--bg-card);
  transition: border-color .15s, box-shadow .15s;
}
input:not([type="checkbox"]):not([type="radio"]), select { min-height: 40px; }
textarea { min-height: 96px; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
@media (max-width: 768px) { .row { flex-direction: column; } }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card); font-size: 13px; cursor: pointer;
  color: var(--text-primary);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), background var(--dur-fast);
}
.btn:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0) scale(.96); }
.btn:focus-visible, .back-btn:focus-visible, .card-edit summary:focus-visible, .member-detail summary:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.btn.primary, .btn.ok, button.primary {
  background-color: var(--brand);
  background-image: var(--grad-brand);
  background-size: 160% 160%; background-position: 0% 50%;
  color: #fff; border-color: var(--brand);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}
.btn.primary:hover, .btn.ok:hover, button.primary:hover {
  background-color: var(--brand-hover);
  background-image: var(--grad-brand-hover);
  transform: translateY(-1px); box-shadow: var(--shadow-sm);
  color: #fff; border-color: var(--brand-hover);
}
.btn.primary:active, .btn.ok:active, button.primary:active { transform: translateY(0) scale(.98); }
.btn.bad { background: var(--bg-card); color: var(--danger); border-color: var(--danger); }
.btn.bad:hover { background: var(--danger); color: #fff; }
button.primary { min-height: 44px; padding: 10px 22px; font-size: 14px; border: none; }
button.primary.wide { width: 100%; }
.small-btn { min-height: 32px; padding: 4px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.small-btn:hover { box-shadow: var(--shadow-sm); color: var(--brand); }

/* ---------- 状态徽章(胶囊) ---------- */
.status, .tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: 999px;
  font-size: 12px; border: 1px solid; white-space: nowrap;
}
.status.todo, .tag.tg-gray { background: var(--neutral-bg); color: var(--neutral); border-color: var(--neutral-border); }
.status.submitted, .tag.tg-orange { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.status.approved, .tag.tg-green { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.status.rejected, .tag.tg-red { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.status.waiting_client, .tag.tg-blue { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.status.cancelled { background: var(--neutral-bg); color: var(--text-tertiary); border-color: var(--neutral-border); }
.status.submitted::before, .status.waiting_client::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: var(--bg-card); color: var(--text-secondary); font-weight: 500; white-space: nowrap; }
tbody tr { transition: background var(--dur-fast) var(--ease-out); }
tbody tr:hover td { background: var(--brand-soft); }
@media (max-width: 768px) {
  table {
    display:block; max-width:100%; overflow-x:auto; overscroll-behavior-x:contain;
    -webkit-overflow-scrolling:touch; white-space:nowrap;
  }
  .data-table-scroll { overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch; }
}

/* 进度条 */
.bar { width: 80px; height: 8px; background: var(--neutral-bg); border-radius: 999px; display: inline-block; vertical-align: middle; overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 999px;
  background-image: var(--grad-accent);
  transition: width .6s var(--ease-out);
}

/* ---------- 统计卡 ---------- */
.stat-row { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 18px 24px;
  flex: 1; min-width: 160px; text-align: center;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat .num {
  font-size: 32px; font-weight: 600; display: block; font-variant-numeric: tabular-nums;
  background: var(--grad-accent); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat span:last-child { font-size: 13px; color: var(--text-secondary); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(30, 27, 75, .55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  overscroll-behavior: contain;
  animation: fadeIn var(--dur-fast) var(--ease-out);
}
.modal-box { background: var(--bg-card); border-radius: var(--radius-xl); padding: 24px 28px; max-width: 440px; width: 90%; box-shadow: var(--shadow-pop); animation: zoomIn var(--dur) var(--ease-out); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* ---------- 消息 ---------- */
.msg-success { padding: 10px 14px; background: var(--success-bg); border-radius: var(--radius-md); border-left: 3px solid var(--success); color: var(--success); margin-bottom: 12px; animation: fadeUp var(--dur) var(--ease-out); }
.msg-error { padding: 10px 14px; background: var(--danger-bg); border-radius: var(--radius-md); border-left: 3px solid var(--danger); color: var(--danger); margin-bottom: 12px; animation: fadeUp var(--dur) var(--ease-out); }

/* ---------- 其他通用 ---------- */
.muted { color: var(--text-tertiary); }
.small { font-size: 12px; }
.error { color: var(--danger); font-size: 13px; }
.success { color: var(--success); font-size: 13px; }
.risk { color: var(--danger); font-size: 12px; font-weight: 600; }
.danger { color: var(--danger); font-weight: 600; }

/* ---------- 运营管理页：筛选、录入、表格与审批 ---------- */
.operation-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px 16px;
}
.operation-filter, .operation-filter-fields, .row-actions, .approval-actions, .approval-reject-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.operation-filter input { width: min(280px, 100%); }
.operation-filter select { width: auto; min-width: 120px; }
.operation-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px 12px;
  align-items: end;
}
.operation-form-grid label { margin: 0; }
.operation-form-grid .span-2 { grid-column: span 2; }
.operation-form-grid .span-full { grid-column: 1 / -1; }
.operation-form-grid .form-action { align-self: end; }
.data-table-panel { padding: 0; overflow: hidden; }
.data-table-scroll { width: 100%; overflow-x: auto; }
.data-table-scroll > table { min-width: 760px; margin: 0; }
.data-table-scroll > table th:first-child, .data-table-scroll > table td:first-child { padding-left: 20px; }
.data-table-scroll > table th:last-child, .data-table-scroll > table td:last-child { padding-right: 20px; }
.inline-edit-toggle { color: var(--brand); font-size: 12px; font-weight: 600; cursor: pointer; }
.inline-edit-form { display: grid; gap: 14px; margin-top: 12px; padding: 16px; border: 1px solid var(--brand-border); border-radius: var(--radius-md); background: var(--bg-soft); }
.inline-edit-actions { display: flex; justify-content: flex-end; gap: 8px; }
.month-picker-field { position:relative; display:flex; align-items:center; gap:10px; margin:0; }
.month-picker-title { color:var(--text-secondary); font-size:13px; white-space:nowrap; }
.month-picker-trigger { display:inline-flex; align-items:center; justify-content:space-between; gap:14px; min-width:184px; min-height:40px; padding:8px 11px 8px 12px; border:1px solid var(--border); border-radius:var(--radius-md); background:var(--bg-card); color:var(--text-primary); font:inherit; font-variant-numeric:tabular-nums; cursor:pointer; transition:border-color var(--dur-fast),box-shadow var(--dur-fast),background var(--dur-fast); }
.month-picker-trigger .ui-icon { width:17px; height:17px; color:var(--brand); }
.month-picker-trigger:hover { border-color:var(--brand-border); background:var(--brand-soft); }
.month-picker-trigger:focus-visible, .month-picker-year-button:focus-visible, .month-picker-month:focus-visible { outline:2px solid var(--brand); outline-offset:2px; }
.month-picker-popover { position:absolute; z-index:70; top:calc(100% + 8px); left:0; width:292px; max-height:calc(100dvh - 24px); padding:12px; overflow-y:auto; border:1px solid var(--border); border-radius:8px; background:var(--bg-card); box-shadow:var(--shadow-pop); }
.month-picker-header { display:grid; grid-template-columns:32px 1fr 32px; align-items:center; margin-bottom:10px; text-align:center; }
.month-picker-header strong { font-size:14px; font-variant-numeric:tabular-nums; }
.month-picker-year-button { display:grid; width:32px; height:32px; padding:0; border:0; border-radius:6px; place-items:center; background:transparent; color:var(--text-secondary); cursor:pointer; }
.month-picker-year-button:hover { background:var(--bg-hover); color:var(--brand); }
.month-picker-year-button .ui-icon { width:16px; height:16px; }
.month-picker-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
.month-picker-month { min-height:36px; border:1px solid transparent; border-radius:6px; background:transparent; color:var(--text-secondary); font:inherit; cursor:pointer; }
.month-picker-month:hover { border-color:var(--brand-border); background:var(--brand-soft); color:var(--brand-hover); }
.month-picker-month.is-selected { border-color:var(--brand); background:var(--brand); color:#fff; font-weight:600; }
.summary-card-link { color:var(--text-primary); text-decoration:none; cursor:pointer; }
.summary-card-link:hover { color:var(--text-primary); }
.approval-list { display: grid; }
.approval-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 76px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.approval-item:first-child { border-top: 1px solid var(--border); }
.approval-content { min-width: 0; flex: 1; }
.approval-title-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.approval-detail, .approval-note { margin-top: 5px; }
.approval-reject-form input { width: 160px; margin: 0; }

@media (max-width: 768px) {
  .panel { padding: 16px; margin-bottom: 12px; }
  .btn { min-height: 44px; }
  .small-btn { min-height: 40px; padding-right: 12px; padding-left: 12px; }
  th, td { padding: 10px 12px; }
  .operation-toolbar { align-items: stretch; min-height: 0; padding: 14px; }
  .operation-filter, .operation-filter-fields, .approval-actions, .approval-reject-form { align-items: stretch; width: 100%; }
  .operation-filter input, .operation-filter select, .approval-reject-form input { width: 100%; }
  .operation-filter .btn, .approval-actions .btn { flex: 1; }
  .operation-form-grid { grid-template-columns: 1fr; gap: 12px; }
  .operation-form-grid .span-2, .operation-form-grid .span-full { grid-column: auto; }
  .operation-form-grid .form-action { width: 100%; }
  .inline-edit-form { padding: 14px; }
  .month-picker-field { align-items:stretch; flex-wrap:wrap; width:100%; gap:6px; }
  .month-picker-title { width:100%; }
  .month-picker-trigger { width:100%; }
  .month-picker-popover { width:min(292px,calc(100vw - 48px)); }
  .approval-item { align-items: stretch; flex-direction: column; gap: 12px; }
  .data-table-scroll > table { min-width: 680px; }
}
