/**
 * 租户端数据列表：桌面表格 + 移动端卡片栈（.tenant-list-shell--mobile-cards）
 */

.tenant-list-shell {
  margin-top: 1.25rem;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.tenant-list-scroll {
  overflow-x: auto;
}

.tenant-list-table {
  min-width: 100%;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: #334155;
}

.tenant-list-thead {
  background-color: #f8fafc;
  text-align: left;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  border-bottom: 2px solid #e2e8f0;
}

.tenant-list-th {
  padding: 0.75rem 1rem;
}

.tenant-list-th--align-right {
  text-align: right;
}

.tenant-list-tbody > tr + tr {
  border-top: 1px solid #f1f5f9;
}

.tenant-list-td {
  padding: 0.75rem 1rem;
  color: #0f172a;
}

.tenant-list-td--muted {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-variant-numeric: lining-nums tabular-nums;
  color: #475569;
}

.tenant-list-td--mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  font-size: 0.75rem;
  line-height: 1rem;
  color: #475569;
}

.tenant-list-td--nowrap {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
  color: #475569;
}

.tenant-list-td--actions {
  text-align: right;
}

.tenant-list-td--cell {
  color: inherit;
}

.tenant-list-td--empty {
  padding: 0;
}

.tenant-list-empty-inner {
  display: flex;
  min-height: 6rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  text-align: center;
}

.tenant-list-td--loading,
.tenant-list-td--error {
  padding: 1.5rem 1rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  text-align: center;
}

.tenant-list-td--loading {
  color: #64748b;
}

.tenant-list-td--error {
  color: #b91c1c;
}

/* 列表底栏：字号统一 12px（0.75rem），勿在 React 里用 Tailwind 改 footer 字号 */
.tenant-list-footer {
  --tenant-list-footer-font-size: 0.75rem;
  border-top: 1px solid #e2e8f0;
  background: rgb(248 250 252 / 0.9);
  padding: 0.625rem 0.75rem;
  padding-bottom: max(0.625rem, env(safe-area-inset-bottom, 0px));
  font-size: var(--tenant-list-footer-font-size);
  line-height: 1.25rem;
  color: #475569;
}

.tenant-list-footer--pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.tenant-list-footer-left {
  font: inherit;
  font-variant-numeric: lining-nums tabular-nums;
  color: #475569;
}

.tenant-list-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
}

.tenant-list-pager-btn {
  border: 1px solid #e2e8f0;
  background: #fff;
  padding: 0.25rem 0.625rem;
  font: inherit;
  line-height: 1.25rem;
  font-weight: 500;
  color: #334155;
  border-radius: 0;
  cursor: pointer;
}

.tenant-list-pager-btn:hover:not(:disabled) {
  background: #f8fafc;
}

.tenant-list-pager-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  color: #64748b;
  font-weight: 400;
}

.tenant-list-pager-label {
  min-width: 5.5rem;
  padding: 0 0.25rem;
  text-align: center;
  font: inherit;
  line-height: 1.25rem;
  color: #475569;
  font-variant-numeric: lining-nums tabular-nums;
}

/* 跳至：各端与桌面相同（横排分隔线），避免移动端单独折行变大 */
.tenant-list-pager-jump {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid #e2e8f0;
  width: auto;
}

.tenant-list-pager-jump-label {
  font: inherit;
  line-height: 1.25rem;
  color: #475569;
}

.tenant-list-pager-input {
  width: 3.5rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  padding: 0.25rem 0.5rem;
  font: inherit;
  line-height: 1.25rem;
  text-align: center;
  color: #1e293b;
  border-radius: 0;
  font-variant-numeric: lining-nums tabular-nums;
}

.tenant-list-pager-input:focus {
  outline: none;
  border-color: #94a3b8;
}

.tenant-list-pager-input:disabled {
  opacity: 0.5;
}

/* —— 分页底栏 · 移动端（紧凑两行，隐藏跳至；与桌面分开展示） —— */
@media (max-width: 767px) {
  .tenant-list-footer--pager {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
  }

  .tenant-list-footer-left {
    width: 100%;
    text-align: center;
    color: #64748b;
  }

  .tenant-list-pager {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.375rem;
    width: 100%;
    align-items: stretch;
  }

  .tenant-list-pager-jump {
    display: none;
  }

  .tenant-list-pager-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.25rem;
  }

  .tenant-list-pager-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: 0.375rem 0.5rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 0.8125rem;
    white-space: nowrap;
  }

  .tenant-list-shell--mobile-cards .tenant-list-footer--pager {
    margin-top: 0.5rem;
    border: none;
    border-top: 1px solid #e2e8f0;
    box-shadow: none;
    background: rgb(248 250 252 / 0.95);
  }
}

/* —— 分页底栏 · 桌面（横排 + 跳至） —— */
@media (min-width: 768px) {
  .tenant-list-footer--pager {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
  }

  .tenant-list-footer-left {
    text-align: left;
    color: #475569;
  }

  .tenant-list-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.375rem;
    width: auto;
  }

  .tenant-list-pager-jump {
    display: inline-flex;
  }
}

/* —— 操作区（桌面链接 / 移动大按钮） —— */
.tenant-list-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

/* —— 移动端：表格 → 卡片栈 —— */
@media (max-width: 767px) {
  .tenant-list-shell--mobile-cards {
    margin-top: 1rem;
    overflow: visible;
    border: none;
    background: transparent;
    box-shadow: none;
  }

  .tenant-list-shell--mobile-cards .tenant-list-scroll {
    overflow-x: visible;
  }

  .tenant-list-shell--mobile-cards .tenant-list-table {
    display: block;
    min-width: 0;
  }

  .tenant-list-shell--mobile-cards .tenant-list-thead {
    display: none;
  }

  .tenant-list-shell--mobile-cards .tenant-list-tbody {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .tenant-list-shell--mobile-cards .tenant-list-tbody > tr {
    display: flex;
    flex-direction: column;
    border: 1px solid #e2e8f0;
    background: #fff;
    box-shadow: 0 1px 3px 0 rgb(15 23 42 / 0.06);
  }

  .tenant-list-shell--mobile-cards .tenant-list-tbody > tr + tr {
    border-top: none;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border-top: 1px solid #f1f5f9;
    text-align: right;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 42%;
    padding-top: 0.125rem;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #94a3b8;
    text-align: left;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td--primary {
    order: -20;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 1rem 1rem 0.75rem;
    border-top: none;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    color: #0f172a;
    text-align: left;
    word-break: break-word;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td--muted {
    word-break: break-word;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td--primary::before {
    display: none;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td--hide-mobile-card,
  .tenant-list-shell--mobile-cards .tenant-list-td.hidden:not(.tenant-list-td--expand-mobile) {
    display: none !important;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td--expand-mobile.hidden {
    display: flex !important;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td--cell {
    align-items: center;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td--cell > * {
    margin-left: auto;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td--actions {
    order: 30;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    text-align: left;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td--actions::before {
    margin-bottom: 0.5rem;
    max-width: none;
    font-size: 0.6875rem;
  }

  .tenant-list-shell--mobile-cards .tenant-list-row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
    justify-content: stretch;
  }

  .tenant-list-shell--mobile-cards .tenant-list-row-actions > a,
  .tenant-list-shell--mobile-cards .tenant-list-row-actions > button {
    display: inline-flex;
    min-height: 2.75rem;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.25;
    color: #334155;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
  }

  .tenant-list-shell--mobile-cards .tenant-list-row-actions > a:hover,
  .tenant-list-shell--mobile-cards .tenant-list-row-actions > button:hover:not(:disabled) {
    border-color: #cbd5e1;
    background: #f8fafc;
  }

  .tenant-list-shell--mobile-cards .tenant-list-row-actions > .tenant-list-action--primary,
  .tenant-list-shell--mobile-cards .tenant-list-row-actions > a.text-primary {
    grid-column: 1 / -1;
    border-color: #1e293b;
    background: #1e293b;
    color: #fff;
  }

  .tenant-list-shell--mobile-cards .tenant-list-row-actions > a.text-primary:hover {
    background: #0f172a;
    border-color: #0f172a;
    color: #fff;
  }

  .tenant-list-shell--mobile-cards .tenant-list-row-actions > button:disabled,
  .tenant-list-shell--mobile-cards .tenant-list-row-actions > span {
    grid-column: 1 / -1;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    border: 1px dashed #e2e8f0;
    background: #f8fafc;
    font-size: 0.8125rem;
    color: #94a3b8;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td--loading,
  .tenant-list-shell--mobile-cards .tenant-list-td--error,
  .tenant-list-shell--mobile-cards .tenant-list-td--empty {
    display: block;
    order: 0;
    padding: 2rem 1rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    text-align: center;
  }

  .tenant-list-shell--mobile-cards .tenant-list-td--loading::before,
  .tenant-list-shell--mobile-cards .tenant-list-td--error::before,
  .tenant-list-shell--mobile-cards .tenant-list-td--empty::before {
    display: none;
  }

  .tenant-list-shell--mobile-cards .tenant-list-footer:not(.tenant-list-footer--pager) {
    margin-top: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0;
    box-shadow: 0 1px 2px 0 rgb(15 23 42 / 0.04);
  }
}
