/* 对话详情页：后台管理精致版 */

:root {
  --dd-bg: #f0f2f5;
  --dd-surface: #ffffff;
  --dd-text: rgba(0, 0, 0, 0.88);
  --dd-text-2: rgba(0, 0, 0, 0.65);
  --dd-text-3: rgba(0, 0, 0, 0.45);
  --dd-border: #f0f0f0;
  --dd-line: #e8e8e8;
  --dd-primary: #1677ff;
  --dd-primary-soft: #e6f4ff;
  --dd-ai: #f4f5f7;
  --dd-radius: 10px;
}

html {
  overflow-anchor: none;
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 28px;
  background: var(--dd-surface);
  border-bottom: 1px solid var(--dd-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.stats-header__left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.scheme-tabs {
  display: inline-flex;
  align-items: center;
  margin-left: 16px;
  padding: 2px;
  background: #f5f5f5;
  border-radius: 8px;
  gap: 2px;
}

.scheme-tab {
  height: 28px;
  padding: 0 12px;
  border-radius: 6px;
  color: rgba(0, 0, 0, 0.65);
  font-size: 13px;
  line-height: 28px;
  text-decoration: none;
}

.scheme-tab:hover {
  color: #1677ff;
}

.scheme-tab.is-active {
  background: #fff;
  color: #1677ff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* 按学生：学校 + 姓名 */
.data-table--user th:first-child,
.data-table--user td:first-child {
  width: 40%;
}

.data-table--user th:last-child,
.data-table--user td:last-child {
  width: 60%;
}

.user-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--dd-primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.user-link__name {
  font-weight: 500;
}

.user-link__meta {
  color: var(--dd-text-3);
  font-size: 12px;
  font-weight: 400;
}

.user-link::after {
  content: "";
  width: 9px;
  height: 9px;
  box-sizing: border-box;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  flex-shrink: 0;
  opacity: 0.9;
}

.user-link:hover {
  color: #4096ff;
}

.user-link.is-open {
  font-weight: 600;
  color: #0958d9;
}

.user-link.is-open::after {
  transform: rotate(225deg) translateY(-1px);
}

.session-block {
  padding-bottom: 8px;
}

.session-block--split {
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px dashed var(--dd-line);
}

.session-block__label {
  display: inline-flex;
  align-items: center;
  margin-bottom: 14px;
  padding: 4px 10px;
  border-radius: 4px;
  background: #eef3f9;
  color: var(--dd-text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.session-block__msgs .chat-msg:last-child {
  margin-bottom: 0;
}

.chat-panel--user .chat-panel__body {
  max-height: 560px;
}

/* 按日期：学校 + 姓名 + 日期 */
.data-table--date th:nth-child(1),
.data-table--date td:nth-child(1) {
  width: 36%;
}

.data-table--date th:nth-child(2),
.data-table--date td:nth-child(2) {
  width: 28%;
}

.data-table--date th:nth-child(3),
.data-table--date td:nth-child(3) {
  width: 36%;
}

.date-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--dd-primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.date-link__name {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.date-link__meta {
  color: var(--dd-text-3);
  font-size: 12px;
  font-weight: 400;
}

.date-link::after {
  content: "";
  width: 9px;
  height: 9px;
  box-sizing: border-box;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  flex-shrink: 0;
  opacity: 0.9;
}

.date-link:hover {
  color: #4096ff;
}

.date-link.is-open {
  font-weight: 600;
  color: #0958d9;
}

.date-link.is-open::after {
  transform: rotate(225deg) translateY(-1px);
}

.session-block__school {
  margin-right: 8px;
  padding-right: 8px;
  border-right: 1px solid #d0d7de;
  color: var(--dd-text-3);
}

.chat-panel--date .chat-panel__body {
  max-height: 560px;
}

.stats-header__icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(145deg, #1677ff 0%, #3c9aff 100%);
}

.stats-header__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--dd-text);
}

.stats-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--dd-text-2);
  font-size: 14px;
}

.stats-header__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, #d9d9d9, #bfbfbf);
}

.stats-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

.filter-card,
.table-card {
  background: var(--dd-surface);
  border-radius: var(--dd-radius);
  padding: 20px 24px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.filter-card {
  margin-bottom: 16px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.filter-row--time {
  margin-bottom: 18px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--dd-border);
}

.time-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.time-preset {
  height: 32px;
  padding: 0 14px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  color: var(--dd-text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.time-preset:hover {
  color: var(--dd-primary);
  border-color: var(--dd-primary);
}

.time-preset.is-active {
  background: var(--dd-primary);
  border-color: var(--dd-primary);
  color: #fff;
}

.date-range {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  min-width: 260px;
  margin-left: 4px;
}

.date-range:hover {
  border-color: var(--dd-primary);
}

.date-range input[type="date"] {
  border: 0;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: var(--dd-text);
  width: 118px;
}

.date-range__sep {
  color: var(--dd-text-3);
  font-size: 12px;
}

.date-range__icon {
  width: 14px;
  height: 14px;
  border: 1.5px solid rgba(0, 0, 0, 0.3);
  border-radius: 2px;
  position: relative;
  flex-shrink: 0;
  opacity: 0.7;
}

.date-range__icon::before {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 3px;
  border-top: 1.5px solid rgba(0, 0, 0, 0.3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
  flex: 1 1 220px;
  max-width: 300px;
}

.field__label {
  font-size: 13px;
  color: var(--dd-text-2);
}

.field__control {
  position: relative;
  display: block;
}

.field__control input {
  width: 100%;
  height: 32px;
  padding: 0 28px 0 11px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-family: inherit;
  color: var(--dd-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field__control input:hover {
  border-color: var(--dd-primary);
}

.field__control input:focus {
  border-color: var(--dd-primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.field__clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.field__clear[hidden] {
  display: none;
}

.filter-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.table-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--dd-text-2);
}

#btn-export {
  flex-shrink: 0;
}

.table-card__export {
  gap: 8px;
  margin-left: auto;
}

.table-card__export > .req-marker {
  margin-left: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--dd-border);
  border-radius: 8px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--dd-text-2);
}

.pagination[hidden] {
  display: none;
}

.pagination__total {
  margin-right: auto;
}

.pagination__pager {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination__btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  color: var(--dd-text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.pagination__btn:hover:not(:disabled):not(.is-active) {
  color: var(--dd-primary);
  border-color: var(--dd-primary);
}

.pagination__btn.is-active {
  background: var(--dd-primary);
  border-color: var(--dd-primary);
  color: #fff;
  cursor: default;
}

.pagination__btn:disabled {
  color: rgba(0, 0, 0, 0.25);
  cursor: not-allowed;
  background: #f5f5f5;
}

.pagination__ellipsis {
  min-width: 24px;
  text-align: center;
  color: var(--dd-text-3);
}

.pagination__size select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-family: inherit;
  color: var(--dd-text);
  cursor: pointer;
}

.pagination__size select:hover {
  border-color: var(--dd-primary);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 13px 16px;
  text-align: left;
  border-bottom: 1px solid var(--dd-border);
  color: var(--dd-text);
  white-space: nowrap;
}

.data-table th {
  background: #fafafa;
  font-weight: 500;
  color: var(--dd-text-2);
  font-size: 13px;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

.session-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--dd-primary);
  font-size: 13px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.session-link::after {
  content: "";
  width: 9px;
  height: 9px;
  box-sizing: border-box;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  flex-shrink: 0;
  opacity: 0.9;
}

.session-link:hover {
  color: #4096ff;
}

.session-link.is-open {
  font-weight: 600;
  color: #0958d9;
}

.session-link.is-open::after {
  transform: rotate(225deg) translateY(-1px);
}

.empty-state {
  padding: 56px 16px;
  text-align: center;
  color: var(--dd-text-3);
  font-size: 14px;
}

/* 空状态文案可隐藏，但角标宿主始终可挂载 */
.empty-state-host {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 28px;
  margin-top: 8px;
  overflow: visible;
}

.empty-state-host .empty-state[hidden] {
  display: none !important;
}

.empty-state-host:has(.empty-state[hidden]) {
  justify-content: flex-start;
  min-height: 24px;
  padding-left: 4px;
}

.data-table tbody tr.is-active {
  background: #f0f7ff;
}

.data-table tbody tr.is-active:hover {
  background: #f0f7ff;
}

/* —— 行内展开会话 —— */
.chat-expand-row > td {
  padding: 0 !important;
  border-bottom: 1px solid var(--dd-border);
  background: #f7f9fc;
  white-space: normal;
}

.chat-panel {
  position: relative;
  margin: 0;
  border: 0;
  border-left: 3px solid var(--dd-primary);
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.chat-expand-row .req-marker {
  z-index: 60;
  position: relative;
}

.session-block__label.req-anchor-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  max-width: 100%;
  overflow: visible;
}

.chat-img-anchor {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  max-width: 100%;
  overflow: visible;
  position: relative;
  z-index: 2;
}

.chat-panel__body {
  max-height: 460px;
  overflow-y: auto;
  padding: 20px 28px 24px 18px;
  background: transparent;
}

.chat-panel__body::-webkit-scrollbar {
  width: 6px;
}

.chat-panel__body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.chat-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 4px 0 22px;
  font-size: 12px;
  color: var(--dd-text-3);
}

.chat-time::before,
.chat-time::after {
  content: "";
  width: 48px;
  height: 1px;
  background: var(--dd-line);
}

.chat-msg {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  align-items: flex-start;
}

.chat-msg:last-child {
  margin-bottom: 4px;
}

.chat-msg--ai {
  justify-content: flex-start;
  padding-right: 12%;
}

.chat-msg--user {
  justify-content: flex-end;
  padding-left: 12%;
}

.chat-msg__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  margin-top: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

div.chat-msg__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #3c9aff, #1677ff);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}

.chat-msg__main {
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.chat-msg--user .chat-msg__main {
  align-items: flex-end;
}

.chat-msg__name {
  font-size: 12px;
  color: var(--dd-text-3);
  line-height: 1.2;
  padding: 0 2px;
}

.chat-bubble {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--dd-text);
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-msg--ai .chat-bubble {
  background: #fff;
  border: 1px solid var(--dd-border);
  border-top-left-radius: 4px;
}

.chat-msg--user .chat-bubble {
  background: var(--dd-primary-soft);
  border: 1px solid #cce3ff;
  border-top-right-radius: 4px;
}

.chat-img {
  display: block;
  max-width: 200px;
  max-height: 160px;
  width: auto;
  height: auto;
  border-radius: 8px;
  cursor: zoom-in;
  border: 1px solid var(--dd-border);
  background: #fff;
  transition: box-shadow 0.15s;
}

.chat-img-anchor {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  max-width: 100%;
}

.session-block__label.req-anchor-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  max-width: 100%;
}

.chat-img:hover {
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.35);
}

.chat-msg__images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-msg--user .chat-msg__images {
  justify-content: flex-end;
}

/* 图片灯箱 */
.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  padding: 24px;
}

.img-lightbox[hidden] {
  display: none;
}

.img-lightbox__img {
  max-width: min(920px, 92vw);
  max-height: 88vh;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  background: #fff;
}

.img-lightbox__close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}

.img-lightbox__close:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* 导出确认弹窗 */
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.confirm-modal[hidden] {
  display: none;
}

.confirm-modal__mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.confirm-modal__panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08),
    0 3px 6px -4px rgba(0, 0, 0, 0.12),
    0 9px 28px 8px rgba(0, 0, 0, 0.05);
}

.confirm-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
}

.confirm-modal__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--dd-text);
}

.confirm-modal__close {
  width: 28px;
  height: 28px;
  margin: -4px -6px 0 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--dd-text-3);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.confirm-modal__close:hover {
  color: var(--dd-text);
  background: rgba(0, 0, 0, 0.04);
}

.confirm-modal__body {
  padding: 8px 20px 8px;
  color: var(--dd-text-2);
  font-size: 14px;
  line-height: 1.7;
}

.confirm-modal__body p {
  margin: 0 0 8px;
}

.confirm-modal__body p:last-child {
  margin-bottom: 0;
}

.confirm-modal__emphasize {
  color: var(--dd-primary);
  font-weight: 600;
}

.confirm-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
}

@media (max-width: 900px) {
  .stats-main {
    padding: 16px;
  }

  .filter-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .field {
    max-width: none;
  }

  .chat-msg--ai,
  .chat-msg--user {
    padding-left: 0;
    padding-right: 0;
  }
}
