#aipost-admin-chat-root {
  margin: 12px 0 0;
}

.aipost-admin-chat-icon-btn {
  width: 35px;
  height: 35px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.aipost-admin-chat-icon-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
}

.aipost-admin-chat-icon {
  width: 35px;
  height: 35px;
  display: block;
}

/* CGPS repeater 操作图标：由 FontAwesome <i> 改为内联 SVG <span> 后，需要补齐显示样式 */
.cgps-field-repeater .cgps-repeater-helper .cgps-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #999;
  padding: 5px;
}

.cgps-field-repeater .cgps-repeater-helper .cgps-svg:hover {
  color: #555;
}

.cgps-field-repeater .cgps-repeater-helper .cgps-svg svg {
  display: block;
}

.cgps-field-group .cgps-cloneable-helper .cgps-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 5px;
  color: #999;
}

.cgps-field-group .cgps-cloneable-helper .cgps-svg:hover {
  color: #555;
}

.cgps-field-group .cgps-cloneable-helper .cgps-svg svg {
  display: block;
}

/* CGPS 保存按钮图标（不依赖 Font Awesome） */
.cgps-buttons .cgps-top-save,
.cgps-buttons .cgps-save {
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 14px 14px;
  padding-left: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' d='M17 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-4-4zM12 19a3 3 0 1 1 0-6 3 3 0 0 1 0 6zM6 8V5h9v3H6z'/%3E%3C/svg%3E");
}

.cgps-buttons .button-secondary.cgps-reset-section,
.cgps-buttons .cgps-reset-all {
  padding-left: 12px;
  background-image: none;
}

.aipost-admin-chat-entry {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
}

.aipost-admin-chat-entry.aipost-admin-chat-entry--title {
  display: inline-flex;
  margin: 0;
  vertical-align: middle;
}

h1.aipost-admin-chat-page-title {
  display: inline-block;
  vertical-align: middle;
}

.aipost-admin-chat-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding-right: 20px;
}

#aipost-admin-chat-overlay {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 99998;
}

#aipost-admin-chat-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

#aipost-admin-chat-drawer {
  position: fixed;
  left: 24px;
  top: 90px;
  width: 980px;
  height: 640px;
  min-width: 520px;
  min-height: 420px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 140px);
  background: #fff;
  transform: scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

#aipost-admin-chat-drawer.is-open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.aipost-admin-chat-resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  z-index: 100000;
}

.aipost-admin-chat-resize-handle.nw { left: 0; top: 0; cursor: nwse-resize; }
.aipost-admin-chat-resize-handle.ne { right: 0; top: 0; cursor: nesw-resize; }
.aipost-admin-chat-resize-handle.sw { left: 0; bottom: 0; cursor: nesw-resize; }
.aipost-admin-chat-resize-handle.se { right: 0; bottom: 0; cursor: nwse-resize; }

.aipost-admin-chat-topbar {
  flex: 0 0 auto;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid #e5e7eb;
}

.aipost-admin-chat-topbar .left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aipost-admin-chat-topbar .right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#aipost-admin-chat-model {
  min-width: 220px;
  max-width: 360px;
}

.aipost-admin-chat-topbar .brand {
  font-weight: 700;
}

.aipost-admin-chat-brand-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.aipost-admin-chat-main {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100% - 54px);
  min-height: 0;
}

#aipost-admin-chat-sessions {
  border-right: 1px solid #e5e7eb;
  overflow: auto;
  overflow-x: hidden;
  padding: 10px;
  background: #fafafa;
  min-height: 0;
}

.aipost-admin-chat-sessions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.aipost-admin-chat-session-item {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  position: relative;
}

.aipost-admin-chat-session-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

/* 防止左侧卡片被长文本撑开导致横向滚动 */
.aipost-admin-chat-session-row > :first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.aipost-admin-chat-session-actions {
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.aipost-admin-chat-session-item:hover .aipost-admin-chat-session-actions {
  opacity: 1;
}

.aipost-admin-chat-session-delete {
  width: 26px;
  height: 26px;
  line-height: 24px;
  text-align: center;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  color: #991b1b;
}

.aipost-admin-chat-session-delete:hover {
  background: #fff1f2;
  border-color: #fecdd3;
}

.aipost-admin-chat-session-item.is-active {
  border-color: #2271b1;
}

.aipost-admin-chat-session-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.aipost-admin-chat-session-sub {
  margin-top: 4px;
  color: #6b7280;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.aipost-admin-chat-empty {
  color: #6b7280;
  padding: 12px 4px;
}

#aipost-admin-chat-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

#aipost-admin-chat-messages {
  flex: 1 1 auto;
  overflow: auto;
  padding: 16px;
  background: #fff;
  min-height: 0;
}

.aipost-admin-chat-msg {
  display: flex;
  margin-bottom: 10px;
}

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

.aipost-admin-chat-msg.assistant {
  justify-content: flex-start;
}

.aipost-admin-chat-bubble {
  max-width: 72%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  white-space: pre-wrap;
  line-height: 1.5;
}

.aipost-admin-chat-msg.user .aipost-admin-chat-bubble {
  background: #e8f1ff;
  border-color: #cfe1ff;
}

.aipost-admin-chat-msg.assistant .aipost-admin-chat-bubble {
  background: #f9fafb;
}

.aipost-admin-chat-composer {
  flex: 0 0 auto;
  border-top: 1px solid #e5e7eb;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

#aipost-admin-chat-input {
  width: 100%;
  min-height: 44px;
}

.aipost-admin-chat-status {
  padding: 8px 12px;
  font-size: 12px;
  color: #6b7280;
}

.aipost-admin-chat-status.bad {
  color: #991b1b;
}

@media (max-width: 960px) {
  .aipost-admin-chat-main {
    grid-template-columns: 1fr;
  }

  #aipost-admin-chat-sessions {
    display: none;
  }
}
