/* =============================================================
   composer.css — 发帖弹框样式
   项目：ZSXQ WEB（知识星球 Web 端像素级还原）

   内容顺序：
     1. 遮罩层（.composer-overlay）
     2. 弹框容器与头部（.composer-modal、.composer-modal-head）
     3. Tab 标签（普通主题 / 富文本）
     4. 面板区域（.composer-pane）
     5. 普通主题输入区（.composer-normal）
     6. 富文本输入区（.composer-richtext、工具栏）
     7. 图片预览区（.composer-img-preview、缩略图、删除按钮）
     8. 文件附件区（.composer-file-preview）
     9. 底部工具栏（.composer-modal-foot、工具按钮、发表按钮）

   注意：
     - composer-overlay 的 z-index 为 100，高于 .chip-panel 的日期弹框（z-index: 200）
       但低于 .lightbox（z-index: 300），因此图片灯箱可在发帖框内正常使用
     - 富文本工具栏使用 document.execCommand（已弃用 API，演示用途，生产应替换为 ProseMirror 等）
   ============================================================= */

/* ─── 1. 遮罩 ───────────────────────────────────────────────── */

.composer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.4);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.composer-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ─── 2. Modal 面板 ─────────────────────────────────────────── */

.composer-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% + 20px));
  width: 640px;
  max-width: calc(100vw - 32px);
  max-height: 80vh;
  background: rgba(255, 255, 255, 1);
  border-radius: 20px;
  box-shadow: 0 16px 48px 0 rgba(15, 20, 25, 0.16);
  z-index: 101;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.composer-modal.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

/* ─── 3. 头部：Tab + 关闭按钮 ───────────────────────────────── */

.composer-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  border-bottom: 1px solid rgba(15, 20, 25, 0.06);
  flex-shrink: 0;
}

/* Tab 列表 */
.composer-tabs {
  display: flex;
  gap: 4px;
}

.composer-tab {
  border: 0;
  background: transparent;
  padding: 0 12px;
  height: 36px;
  font-size: 14px;
  font-family: PingFangSC-Regular, "PingFang SC", sans-serif;
  font-weight: 400;
  color: rgba(153, 153, 153, 1);
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
  position: relative;
}

.composer-tab:hover {
  color: rgba(15, 20, 25, 1);
  background: rgba(15, 20, 25, 0.04);
}

/* 选中 Tab：文字加粗变深 + 底部绿色指示条 */
.composer-tab.is-active {
  font-family: PingFangSC-Semibold, "PingFang SC", sans-serif;
  font-weight: 600;
  color: rgba(15, 20, 25, 1);
  background: transparent;
}

.composer-tab.is-active::after {
  content: '';
  position: absolute;
  bottom: -8px; /* 对齐头部底部分割线 */
  left: 12px;
  right: 12px;
  height: 2px;
  background: var(--green);
  border-radius: 1px;
}

/* 关闭按钮 */
.composer-modal-close {
  border: 0;
  background: transparent;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.composer-modal-close:hover {
  background: rgba(15, 20, 25, 0.06);
}

/* ─── 4. 内容面板 ───────────────────────────────────────────── */

.composer-pane[hidden] { display: none; }

.composer-pane {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

/* ─── 5. 普通主题 textarea ──────────────────────────────────── */

.composer-textarea {
  width: 100%;
  min-height: 160px;
  border: 0;
  outline: none;
  resize: none;
  font-size: 15px;
  font-family: PingFangSC-Regular, "PingFang SC", sans-serif;
  color: rgba(15, 20, 25, 1);
  line-height: 24px;
  background: transparent;
  box-sizing: border-box;
}

.composer-textarea::placeholder {
  color: rgba(153, 153, 153, 1);
}

/* ─── 6. 长文章 ─────────────────────────────────────────────── */

/* 标题输入框 */
.composer-article-title {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(15, 20, 25, 0.08);
  outline: none;
  padding: 0 0 12px;
  font-size: 18px;
  font-family: PingFangSC-Semibold, "PingFang SC", sans-serif;
  font-weight: 600;
  color: rgba(15, 20, 25, 1);
  background: transparent;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.composer-article-title::placeholder {
  color: rgba(153, 153, 153, 1);
  font-weight: 600;
  font-family: PingFangSC-Semibold, "PingFang SC", sans-serif;
}

.composer-article-title:focus {
  border-bottom-color: var(--green);
}

/* 富文本工具条 */
.composer-richtext-toolbar {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.composer-richtext-toolbar button {
  border: 0;
  background: transparent;
  padding: 4px 8px;
  height: 28px;
  min-width: 28px;
  font-size: 13px;
  font-family: PingFangSC-Regular, "PingFang SC", sans-serif;
  color: rgba(51, 51, 51, 1);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.composer-richtext-toolbar button:hover {
  background: rgba(15, 20, 25, 0.06);
  color: rgba(15, 20, 25, 1);
}

.composer-richtext-toolbar button.is-active {
  background: rgba(22, 185, 152, 0.1);
  color: var(--green);
}

/* 富文本编辑区 */
.composer-richtext {
  min-height: 240px;
  outline: none;
  font-size: 15px;
  font-family: PingFangSC-Regular, "PingFang SC", sans-serif;
  color: rgba(15, 20, 25, 1);
  line-height: 26px;
}

/* contenteditable placeholder 用伪元素实现 */
.composer-richtext:empty::before {
  content: attr(data-placeholder);
  color: rgba(153, 153, 153, 1);
  pointer-events: none;
}

/* ─── 7. 底部工具栏 ─────────────────────────────────────────── */

.composer-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid rgba(15, 20, 25, 0.06);
  flex-shrink: 0;
}

.composer-foot-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.composer-tool-btn {
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: PingFangSC-Regular, "PingFang SC", sans-serif;
  color: rgba(102, 102, 102, 1);
  transition: background 0.15s ease, color 0.15s ease;
}

.composer-tool-btn:hover {
  background: rgba(15, 20, 25, 0.05);
  color: rgba(15, 20, 25, 1);
}

.composer-tool-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* 图片按钮在长文章模式下隐藏 */
.composer-tool-btn[data-visible="normal"].is-hidden {
  display: none;
}

/* 发表按钮 */
.composer-submit {
  height: 34px;
  padding: 0 20px;
  background: var(--green);
  color: rgba(255, 255, 255, 1);
  border: 0;
  border-radius: 8px;
  font-size: 14px;
  font-family: PingFangSC-Medium, "PingFang SC", sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

.composer-submit:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.composer-submit:hover:not(:disabled) {
  opacity: 0.85;
}

/* ─── 8. 图片预览区 ─────────────────────────────────────────── */

.composer-img-preview[hidden],
.composer-file-preview[hidden] { display: none; }

.composer-img-preview {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, 1fr);
}

/* 每个缩略图容器：正方形，相对定位承载删除按钮 */
.composer-img-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(15, 20, 25, 0.04);
}

.composer-img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 删除按钮：右上角半透明黑底圆形 */
.composer-img-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: rgba(15, 20, 25, 0.55);
  color: rgba(255, 255, 255, 1);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.composer-img-remove:hover {
  background: rgba(15, 20, 25, 0.8);
}

/* 追加按钮：虚线边框占位格 */
.composer-img-add {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1.5px dashed rgba(15, 20, 25, 0.2);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: rgba(153, 153, 153, 1);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.composer-img-add:hover {
  border-color: var(--green);
  color: var(--green);
}

/* ─── 9. 文件附件区 ─────────────────────────────────────────── */

.composer-file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(247, 249, 251, 1);
  border-radius: 10px;
  border: 1px solid rgba(15, 20, 25, 0.06);
}

.composer-file-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-family: PingFangSC-Semibold, "PingFang SC", sans-serif;
  font-weight: 600;
  color: rgba(255, 255, 255, 1);
  flex-shrink: 0;
  background: rgba(153, 153, 153, 1);
}

.composer-file-icon--pdf  { background: rgba(220, 53, 53, 1); }
.composer-file-icon--doc  { background: rgba(37, 99, 235, 1); }
.composer-file-icon--xls  { background: rgba(22, 163, 74, 1); }
.composer-file-icon--ppt  { background: rgba(234, 88, 12, 1); }
.composer-file-icon--zip  { background: rgba(107, 114, 128, 1); }

.composer-file-info {
  flex: 1;
  min-width: 0;
}

.composer-file-name {
  font-size: 13px;
  font-family: PingFangSC-Regular, "PingFang SC", sans-serif;
  color: rgba(15, 20, 25, 1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-file-size {
  font-size: 12px;
  font-family: PingFangSC-Regular, "PingFang SC", sans-serif;
  color: rgba(153, 153, 153, 1);
  margin-top: 2px;
}

.composer-file-remove {
  border: 0;
  background: transparent;
  padding: 4px;
  cursor: pointer;
  color: rgba(153, 153, 153, 1);
  font-size: 16px;
  line-height: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.composer-file-remove:hover {
  color: rgba(15, 20, 25, 1);
  background: rgba(15, 20, 25, 0.06);
}

