/* ============================================================================
   组件层：按钮 / 表单 / 表格 / 分页 / 弹窗 / 提示 / 卡片 / 空状态
   视觉参照 qrbjx.com：8px 圆角按钮、1.5px 描边卡片、主色阴影
   ========================================================================== */

/* ------------------------------- 卡片 / 面板 ------------------------------- */

.card {
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.card-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 标题前的品牌色竖条，弱化版 qrbjx 的 info-card 左边框语言 */
.card-title::before {
  content: "";
  width: 3px;
  height: 15px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--primary), var(--geo));
}

.card-body {
  padding: 20px;
}

.card-body.tight {
  padding: 0;
}

/* -------------------------------- 按钮 -------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1.5px solid transparent;
  border-radius: 8px;
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  transition: var(--tr-fast);
  user-select: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn.is-disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* 主按钮：同 qrbjx .btn-primary */
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 6px 20px rgba(37, 99, 235, .4);
  transform: translateY(-1px);
}

/* 次按钮 */
.btn-default {
  background: var(--bg-white);
  color: var(--text-mid);
  border-color: var(--border-strong);
}

.btn-default:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-tint);
}

/* 危险按钮：删除类操作 */
.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, .28);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-dark);
  box-shadow: 0 6px 18px rgba(239, 68, 68, .38);
  transform: translateY(-1px);
}

/* 幽灵按钮 */
.btn-ghost {
  background: transparent;
  color: var(--text-light);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-dark);
}

/* 紫色系（知了GEO小蓝词模块用，区分业务线） */
.btn-geo {
  background: var(--geo);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, .3);
}

.btn-geo:hover:not(:disabled) {
  background: #6d28d9;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, .4);
}

.btn-sm {
  padding: 6px 12px;
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
}

.btn-lg {
  padding: 12px 26px;
  font-size: var(--fs-md);
}

.btn-block {
  width: 100%;
}

/* 按钮内 loading 旋转点 */
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

.btn-default.is-loading::after,
.btn-ghost.is-loading::after {
  border-color: rgba(37, 99, 235, .25);
  border-top-color: var(--primary);
}

/* -------------------------------- 表单 -------------------------------- */

.form-item {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  margin-bottom: 7px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-mid);
}

.form-label .req {
  color: var(--danger);
  margin-left: 3px;
}

.form-label .hint {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: var(--fs-base);
  color: var(--text-dark);
  transition: var(--tr-fast);
  appearance: none;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--bg-light);
  color: var(--text-muted);
  cursor: not-allowed;
}

.input.is-error,
.select.is-error,
.textarea.is-error {
  border-color: var(--danger);
}

.input.is-error:focus,
.select.is-error:focus,
.textarea.is-error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}

/* 下拉箭头：用内联 SVG 做背景，避免额外图标字体 */
.select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5 6 8.5l4-4' stroke='%2364748b' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.7;
}

.form-error {
  display: block;
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: var(--danger);
  min-height: 0;
}

.form-help {
  display: block;
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: var(--text-light);
  line-height: 1.6;
}

/* 只读结果块（如「消费」实时金额） */
.readout {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 9px 14px;
  background: var(--bg-tint);
  border: 1.5px solid rgba(37, 99, 235, .18);
  border-radius: 8px;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--primary);
  min-width: 110px;
}

.readout .unit {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-light);
}

/* 复选 / 单选 */
.checkbox,
.radio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: var(--fs-base);
  color: var(--text-mid);
  user-select: none;
}

.checkbox input,
.radio input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
  flex: none;
}

/* ------------------------------ 筛选工具条 ------------------------------ */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filter-bar .input,
.filter-bar .select {
  width: auto;
  min-width: 132px;
  flex: 0 1 auto;
}

.filter-bar .input[type="text"] {
  width: 160px;
}

.filter-bar .spacer {
  flex: 1 1 auto;
}

.filter-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* -------------------------------- 表格 -------------------------------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  min-width: 780px;
  font-size: var(--fs-base);
}

.table thead th {
  padding: 11px 14px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-light);
  text-align: left;
  white-space: nowrap;
  letter-spacing: .01em;
}

.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-mid);
  vertical-align: middle;
}

.table tbody tr {
  transition: background .15s ease;
}

.table tbody tr:hover {
  background: #f9fbff;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table .col-check {
  width: 42px;
  text-align: center;
}

.table .col-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.table .col-id {
  width: 70px;
  color: var(--text-light);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

.table .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table .col-money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
}

.table .col-actions {
  white-space: nowrap;
}

/* 表格里的主信息（关键词 / 链接）允许断行，长链接不撑破布局 */
.cell-strong {
  color: var(--text-dark);
  font-weight: 600;
  word-break: break-word;
}

.cell-link {
  color: var(--text-mid);
  word-break: break-all;
  font-size: var(--fs-sm);
  line-height: 1.5;
}

/* 移动端卡片化：<768 时表格转成两列信息卡 */
@media (max-width: 768px) {
  .table {
    min-width: 0;
  }

  .table thead {
    display: none;
  }

  .table tbody tr {
    display: block;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
  }

  .table tbody tr:last-child {
    border-bottom: none;
  }

  .table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    padding: 5px 0;
    border: none;
    text-align: left !important;
  }

  .table tbody td::before {
    content: attr(data-label);
    flex: none;
    width: 84px;
    color: var(--text-light);
    font-size: var(--fs-sm);
    font-weight: 500;
  }

  .table tbody td.col-check {
    width: auto;
    justify-content: flex-start;
  }

  .table tbody td.col-check::before {
    content: "选择";
  }

  .table tbody td.col-num,
  .table tbody td.col-money {
    white-space: normal;
  }

  /* 移动端操作列：去掉左侧标签，按钮占满，避免挤在右侧看不清 */
  .table tbody td.col-actions {
    justify-content: flex-end;
    padding-top: 10px;
    margin-top: 4px;
    border-top: 1px dashed var(--border-light);
  }

  .table tbody td.col-actions::before {
    content: "";
    width: 0;
  }
}

/* ------------------------------- 状态徽标 ------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success {
  background: rgba(16, 185, 129, .12);
  color: #059669;
}

.badge-muted {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.badge-warning {
  background: rgba(245, 158, 11, .13);
  color: #b45309;
}

.badge-danger {
  background: rgba(239, 68, 68, .12);
  color: var(--danger-dark);
}

.badge-primary {
  background: var(--bg-tint);
  color: var(--primary-dark);
}

.badge-geo {
  background: var(--bg-tint-geo);
  color: var(--geo);
}

.badge-plain::before {
  display: none;
}

/* 类型标签：不加圆点，纯色块 */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-hover);
  color: var(--text-mid);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

.tag-geo {
  background: var(--bg-tint-geo);
  color: var(--geo);
}

.tag-primary {
  background: var(--bg-tint);
  color: var(--primary-dark);
}

/* -------------------------------- 分页 -------------------------------- */

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.pager-info {
  font-size: var(--fs-sm);
  color: var(--text-light);
}

.pager-info b {
  color: var(--text-dark);
  font-weight: 600;
}

.pager-list {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-white);
  color: var(--text-mid);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: var(--tr-fast);
}

.pager-btn:hover:not(:disabled):not(.is-active) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-tint);
}

.pager-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.pager-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.pager-ellipsis {
  padding: 0 4px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

@media (max-width: 480px) {
  .pager {
    padding: 12px 14px;
  }

  .pager-list {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }
}

/* -------------------------------- 空状态 -------------------------------- */

.empty {
  padding: 56px 20px;
  text-align: center;
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--bg-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.empty-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: var(--fs-sm);
  color: var(--text-light);
  margin-bottom: 18px;
}

/* 骨架屏（首屏加载占位） */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e8eef6 37%, #f1f5f9 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: var(--r-sm);
  height: 14px;
}

.skeleton-row {
  display: flex;
  gap: 16px;
  padding: 14px 20px;
}

.skeleton-row .skeleton:nth-child(1) { width: 12%; }
.skeleton-row .skeleton:nth-child(2) { width: 24%; }
.skeleton-row .skeleton:nth-child(3) { width: 16%; }
.skeleton-row .skeleton:nth-child(4) { width: 20%; }
.skeleton-row .skeleton:nth-child(5) { width: 10%; }

/* -------------------------------- 提示条 -------------------------------- */

.alert {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  line-height: 1.7;
  border: 1px solid transparent;
}

.alert-info {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #075985;
}

.alert-geo {
  background: var(--bg-tint-geo);
  border-color: #ddd6fe;
  color: #5b21b6;
}

.alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.alert-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-success {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.alert .alert-body {
  flex: 1;
  min-width: 0;
}

.alert strong {
  font-weight: 700;
}

/* -------------------------------- 弹窗 -------------------------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: var(--z-modal);
  animation: fadeIn .18s ease;
}

.modal {
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--bg-white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  animation: modalIn .22s cubic-bezier(.2, .8, .3, 1);
  overflow: hidden;
}

.modal-lg {
  max-width: 680px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-dark);
}

.modal-close {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  color: var(--text-light);
  font-size: 20px;
  line-height: 1;
  transition: var(--tr-fast);
  flex: none;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-dark);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  font-size: var(--fs-base);
  color: var(--text-mid);
  line-height: 1.8;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border-light);
}

@media (max-width: 480px) {
  .modal-mask {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    max-width: none;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 88vh;
    animation: sheetIn .25s cubic-bezier(.2, .8, .3, 1);
  }

  .modal-foot .btn {
    flex: 1;
  }
}

/* -------------------------------- Toast -------------------------------- */

.toast-wrap {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 16px;
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-base);
  color: var(--text-dark);
  animation: toastIn .24s cubic-bezier(.2, .8, .3, 1);
  pointer-events: auto;
}

.toast-icon {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.toast-success { border-color: rgba(16, 185, 129, .35); }
.toast-success .toast-icon { color: var(--success); }
.toast-error { border-color: rgba(239, 68, 68, .35); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning { border-color: rgba(245, 158, 11, .35); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--primary); }

.toast.is-leaving {
  animation: toastOut .2s ease forwards;
}

@media (max-width: 480px) {
  .toast-wrap {
    top: auto;
    bottom: 20px;
  }
}

/* -------------------------------- 动画 -------------------------------- */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes sheetIn {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px); }
}
