/**
 * FastIM 悬浮窗覆盖样式 — 必须在 fastim_default.css 之后加载。
 * 解决：默认 100% 缩放下顶部被裁切（需手动放大页面才正常）的问题。
 */
.im-system-card__text--danger {
  color: #e53935 !important;
  font-weight: 600;
}

@media (min-width: 769px) {
  body.fastim-widget-mode {
    --fastim-widget-height: min(680px, calc(100dvh - 80px, 100vh - 80px));
    --window-height: var(--fastim-widget-height) !important;
  }

  body.fastim-widget-mode .fastim-modal,
  body.fastim-widget-mode .fastim-modal.in {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    right: 24px !important;
    bottom: 24px !important;
    width: min(920px, calc(100vw - 48px)) !important;
    height: min(680px, calc(100dvh - 80px, 100vh - 80px)) !important;
    max-height: calc(100dvh - 80px, 100vh - 80px) !important;
    background: transparent !important;
    overflow: hidden !important;
    transform: none !important;
    overscroll-behavior: contain;
  }

  body.fastim-widget-mode .fastim-modal.fastim-widget-user-positioned {
    top: var(--fastim-widget-top) !important;
    left: var(--fastim-widget-left) !important;
    right: auto !important;
    bottom: auto !important;
  }

  body.fastim-widget-dragging {
    user-select: none;
  }

  body.fastim-widget-mode .fastim-modal:not(.fastim-layout-fullscreen) .fastim-window-search,
  body.fastim-widget-mode .fastim-modal:not(.fastim-layout-fullscreen) .chat-window-header,
  body.fastim-widget-mode .fastim-modal:not(.fastim-layout-fullscreen) .fastim-sidebar-tabs,
  body.fastim-widget-mode .fastim-modal:not(.fastim-layout-fullscreen) .fastim-sidebar-user {
    cursor: move;
  }

  body.fastim-widget-mode .fastim-modal:not(.fastim-layout-fullscreen) .fastim-window-search input,
  body.fastim-widget-mode .fastim-modal:not(.fastim-layout-fullscreen) .fastim-window-search .window-search-right,
  body.fastim-widget-mode .fastim-modal:not(.fastim-layout-fullscreen) .chat-window-header .chat-user-menu,
  body.fastim-widget-mode .fastim-modal:not(.fastim-layout-fullscreen) .chat-window-header .fastim-click,
  body.fastim-widget-mode .fastim-modal:not(.fastim-layout-fullscreen) .fastim-sidebar-tabs .fastim-click,
  body.fastim-widget-mode .fastim-modal:not(.fastim-layout-fullscreen) .fastim-sidebar-user .fastim-click {
    cursor: auto;
  }

  /* 禁用 FastIM 默认 translate(-25%) 入场动画，这是顶部被裁切的主因 */
  body.fastim-widget-mode .fastim-modal .fastim-window,
  body.fastim-widget-mode .fastim-modal .fastim-window.modal-dialog,
  body.fastim-widget-mode .fastim-modal.in .fastim-window.modal-dialog,
  body.fastim-widget-mode .fastim-fade .fastim-window.modal-dialog,
  body.fastim-widget-mode .fastim-fade.in .fastim-window.modal-dialog {
    pointer-events: auto;
    margin: 0 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    box-shadow: 0 12px 40px rgba(13, 27, 57, 0.22);
    border-radius: 12px;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: row !important;
    overscroll-behavior: contain;
  }

  body.fastim-widget-mode .fastim-modal.fastim-fade {
    transition: none !important;
  }

  body.fastim-widget-mode .fastim-modal .fastim-window-sidebar {
    width: 56px !important;
    min-width: 56px !important;
    flex: 0 0 56px !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow: visible !important;
    position: relative !important;
  }

  body.fastim-widget-mode .fastim-modal .fastim-window-middle {
    display: flex !important;
    flex-direction: column !important;
    width: 240px !important;
    min-width: 200px !important;
    flex: 0 0 240px !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  body.fastim-widget-mode .fastim-modal .fastim-window-middle,
  body.fastim-widget-mode .fastim-modal .fastim-window-right,
  body.fastim-widget-mode .fastim-modal .fastim-window-sidebar {
    height: 100% !important;
    max-height: 100% !important;
  }

  body.fastim-widget-mode .fastim-window.fastim-session-list-collapsed .fastim-window-middle {
    display: flex !important;
    width: 240px !important;
    flex: 0 0 240px !important;
  }

  body.fastim-widget-mode .fastim-window-right {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    width: auto !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  body.fastim-widget-mode .fastim-sidebar-menu {
    position: absolute !important;
    bottom: 5px !important;
    left: 0;
    right: 0;
    width: 100%;
  }

  body.fastim-widget-mode .fastim-sidebar-menu-box.fastim-popup-menu {
    position: absolute !important;
    left: calc(100% + 6px) !important;
    bottom: 0 !important;
    top: auto !important;
    right: auto !important;
    width: max-content !important;
    min-width: 108px !important;
    white-space: nowrap !important;
  }

  body.fastim-widget-mode .fastim-sidebar-menu-box.fastim-popup-menu div {
    white-space: nowrap !important;
    writing-mode: horizontal-tb !important;
  }

  body.fastim-widget-mode .fastim-window-right > .fastim-close {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 1200 !important;
    margin: 0 !important;
  }

  body.fastim-widget-mode .fastim-window-right > .session-window {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
  }

  body.fastim-widget-mode .session-window {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  /* 仅显示 FastIM 当前打开的窗口（jQuery show/hide 用 inline display 控制） */
  body.fastim-widget-mode .session-window > .message-window[style*='display: block'],
  body.fastim-widget-mode .session-window > .message-window[style*='display:block'],
  body.fastim-widget-mode .session-window > .service-window[style*='display: block'],
  body.fastim-widget-mode .session-window > .service-window[style*='display:block'],
  body.fastim-widget-mode .session-window > .fake-tourist[style*='display: block'],
  body.fastim-widget-mode .session-window > .fake-tourist[style*='display:block'] {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  body.fastim-widget-mode .session-window > .message-window[style*='display: none'],
  body.fastim-widget-mode .session-window > .message-window[style*='display:none'],
  body.fastim-widget-mode .session-window > .service-window[style*='display: none'],
  body.fastim-widget-mode .session-window > .service-window[style*='display:none'],
  body.fastim-widget-mode .session-window > .fake-tourist[style*='display: none'],
  body.fastim-widget-mode .session-window > .fake-tourist[style*='display:none'] {
    display: none !important;
  }

  body.fastim-widget-mode .chat-window-header {
    flex: 0 0 46px !important;
    background: #fff;
  }

  body.fastim-widget-mode .chat-window-record {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
  }

  body.fastim-widget-mode .chat-records,
  body.fastim-widget-mode .service-message,
  body.fastim-widget-mode .fastim-session-ul,
  body.fastim-widget-mode .fastim-unread-session-ul,
  body.fastim-widget-mode .fastim-scrollbar,
  body.fastim-widget-mode .fastim-address-list,
  body.fastim-widget-mode #fastim-message {
    overscroll-behavior: contain;
  }

  body.fastim-widget-mode .chat-records,
  body.fastim-widget-mode .service-message {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }

  body.fastim-widget-mode .chat-window-input {
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 135px !important;
  }

  body.fastim-widget-mode .fastim-session-list,
  body.fastim-widget-mode .fastim-unread-session-list,
  body.fastim-widget-mode .fastim-address-list {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  body.fastim-widget-mode .fastim-button-container {
    display: none !important;
  }

  body.fastim-widget-mode .fastim-modal.fastim-layout-fullscreen {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    background: #fff !important;
    pointer-events: auto;
    z-index: 9999;
  }

  body.fastim-widget-mode .fastim-modal.fastim-layout-fullscreen .fastim-window,
  body.fastim-widget-mode .fastim-modal.fastim-layout-fullscreen .fastim-window.modal-dialog {
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  body.fastim-widget-mode .fastim-window-right > .fastim-layout-fullscreen-btn {
    position: absolute !important;
    top: 10px !important;
    right: 44px !important;
    z-index: 1200 !important;
  }
}

.chat-record-sendtime {
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.chat-record-nickname--time-only {
  margin-bottom: 2px;
}

/* 申诉客服处理弹窗 — 覆盖 fastim_default 中 .fastim-popup 的绝对定位 */
.fastim-appeal-process-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 100000;
}

.fastim-appeal-process-popup {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: min(420px, calc(100vw - 32px)) !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 0 18px !important;
  background: #fff !important;
  border-radius: 12px !important;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .22) !important;
  z-index: 100001 !important;
  box-sizing: border-box;
}

.fastim-appeal-process-popup .fastim-appeal-process-title {
  padding: 16px 18px 12px;
  margin: 0;
  border-bottom: 1px solid #e2e8f0;
}

.fastim-appeal-process-body {
  padding: 16px 18px 0;
}

.fastim-appeal-process-popup .fastim-appeal-field {
  margin-bottom: 14px;
}

.fastim-appeal-process-popup .fastim-appeal-readonly {
  display: block;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: #0f172a;
  background: #f8fafc;
}

.fastim-appeal-process-popup .fastim-appeal-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  line-height: 1.4;
}

.fastim-appeal-process-popup .fastim-appeal-input,
.fastim-appeal-process-popup .fastim-appeal-textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: #0f172a;
  background: #fff;
}

.fastim-appeal-process-popup .fastim-appeal-textarea {
  min-height: 96px;
  resize: vertical;
}

.fastim-appeal-process-popup .fastim-appeal-radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fastim-appeal-process-popup .fastim-appeal-radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

.fastim-appeal-process-popup .fastim-appeal-radio-item input[type="radio"] {
  margin: 0;
  flex-shrink: 0;
}

.fastim-appeal-process-popup .fastim-appeal-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 14px 18px 0;
  border-top: 1px solid #e2e8f0;
}

.fastim-appeal-process-popup .fastim-appeal-actions .im-button {
  margin: 0;
  min-width: 88px;
}
