/**
 * Chat Showcase Component - 对话模式文件展示区
 * 当用户点击对话中的文件标签时，展开右侧展示区显示文件预览
 * 
 * @created 2026-01-27
 * @module components/chat-showcase
 */

/* ===== 展示区容器 ===== */
.chat-showcase {
  display: none;
  flex-direction: column;
  width: 0;
  min-width: 0;
  max-width: 0;
  height: 100%;
  background: var(--background, #0a0a0a);
  border-left: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              min-width 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              max-width 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 展示区展开状态 */
.chat-showcase.open {
  display: flex;
  width: 50%;
  min-width: 320px;
  max-width: 800px;
}

/* ===== 展示区头部（Tab 栏） ===== */
.showcase-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.showcase-tabs-scroll {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.showcase-tabs-scroll::-webkit-scrollbar {
  display: none;
}

/* ===== 关闭按钮 ===== */
.showcase-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm, 0.25rem);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.showcase-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

.showcase-close-btn svg {
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* ===== Tab 标签（复用 file-tab 样式） ===== */
.showcase-tab {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm, 0.25rem);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  max-width: 180px;
}

.showcase-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

.showcase-tab.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 1);
}

.showcase-tab-icon {
  font-size: 0.875rem;
  flex-shrink: 0;
}

.showcase-tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.showcase-tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  margin-left: 0.25rem;
  border-radius: 2px;
  color: rgba(255, 255, 255, 0.4);
  opacity: 0;
  transition: all 0.15s ease;
}

.showcase-tab:hover .showcase-tab-close {
  opacity: 1;
}

.showcase-tab-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

.showcase-tab-close svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* ===== 展示区主体（包含预览区和侧边栏） ===== */
.showcase-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ===== 展示区内容（预览区） ===== */
.showcase-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===== 预览头部 ===== */
.showcase-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.showcase-preview-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

.showcase-preview-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

#showcase-preview-filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.showcase-preview-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ===== 预览内容区 ===== */
.showcase-preview-content {
  flex: 1;
  overflow: auto;
  padding: 0;
  background: rgba(0, 0, 0, 0.3);
}

#showcase-preview-code {
  margin: 0;
  padding: 1rem;
  background: transparent;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.75rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
  white-space: pre-wrap;
  word-break: break-all;
  overflow: auto;
}

#showcase-preview-code code {
  background: transparent;
  padding: 0;
}

#showcase-markdown-preview {
  padding: 1rem;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.6;
}

/* ===== 预览状态栏 ===== */
.showcase-preview-status {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.375rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

/* ===== 视图切换按钮 ===== */
.showcase-preview-actions .preview-view-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm, 0.25rem);
  padding: 0.125rem;
}

.showcase-preview-actions .view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: transparent;
  border: none;
  border-radius: 0.125rem;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.15s ease;
}

.showcase-preview-actions .view-toggle-btn:hover {
  color: rgba(255, 255, 255, 0.7);
}

.showcase-preview-actions .view-toggle-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

.showcase-preview-actions .view-toggle-btn svg {
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* ===== 空状态 ===== */
.showcase-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.875rem;
  text-align: center;
  padding: 2rem;
}

.showcase-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* ===== 响应式适配 ===== */
@media (max-width: 1024px) {
  .chat-showcase.open {
    width: 45%;
    min-width: 280px;
  }
}

@media (max-width: 768px) {
  /* 移动端：展示区占满剩余空间或覆盖聊天面板 */
  .chat-showcase.open {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    max-width: none;
    min-width: 0;
    z-index: 100;
    border-left: none;
  }
  
  .showcase-close-btn {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* ===== 动画 ===== */
@keyframes showcaseSlideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.chat-showcase.open .showcase-content {
  animation: showcaseSlideIn 0.3s ease-out;
}

/* ===== 操作按钮 ===== */
.showcase-action-btn {
  padding: 0.25rem 0.625rem;
  font-size: 0.6875rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm, 0.25rem);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.15s ease;
}

.showcase-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.95);
}

.showcase-save-btn {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.4);
  color: rgba(34, 197, 94, 0.9);
}

.showcase-save-btn:hover {
  background: rgba(34, 197, 94, 0.3);
  border-color: rgba(34, 197, 94, 0.6);
  color: rgb(34, 197, 94);
}

/* ===== 编辑区 textarea ===== */
.showcase-edit-area {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.4);
  border: none;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.75rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.9);
  resize: none;
  outline: none;
}

.showcase-edit-area:focus {
  background: rgba(0, 0, 0, 0.5);
}

/* ===== HTML iframe 预览 ===== */
.showcase-preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* ===== 未保存提示 ===== */
.showcase-unsaved {
  color: rgba(234, 179, 8, 0.9);
  font-weight: 500;
  padding: 0.125rem 0.375rem;
  background: rgba(234, 179, 8, 0.15);
  border-radius: 0.25rem;
}

/* ===== Tab 脏状态指示 ===== */
.showcase-tab.dirty .showcase-tab-name::after {
  content: '●';
  margin-left: 0.25rem;
  color: rgba(234, 179, 8, 0.8);
  font-size: 0.5rem;
}

/* ===== 会话文件侧边栏 ===== */
.session-files-sidebar {
  width: 180px;
  min-width: 140px;
  max-width: 240px;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.2);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  transition: width 0.2s ease, min-width 0.2s ease;
}

.session-files-sidebar.collapsed {
  width: 32px;
  min-width: 32px;
  max-width: 32px;
}

.session-files-sidebar.collapsed .session-files-list,
.session-files-sidebar.collapsed .session-files-title {
  display: none;
}

.session-files-sidebar.collapsed .session-files-header {
  justify-content: center;
}

.session-files-sidebar.collapsed .session-files-toggle svg {
  transform: rotate(180deg);
}

/* ===== 侧边栏头部 ===== */
.session-files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.625rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.session-files-title {
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-files-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm, 0.25rem);
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.session-files-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

.session-files-toggle svg {
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  transition: transform 0.2s ease;
}

/* ===== 文件列表 ===== */
.session-files-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.375rem;
}

.session-files-list::-webkit-scrollbar {
  width: 4px;
}

.session-files-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

/* ===== 空状态 ===== */
.session-files-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0.5rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.3);
}

.session-files-empty-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.session-files-empty-text {
  font-size: 0.6875rem;
}

/* ===== 文件项 ===== */
.session-file-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.5rem;
  margin-bottom: 0.125rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 0.25rem);
  cursor: pointer;
  transition: all 0.15s ease;
}

.session-file-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
}

.session-file-item.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.session-file-icon {
  font-size: 0.875rem;
  flex-shrink: 0;
}

.session-file-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.session-file-name {
  font-size: 0.6875rem;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  color: rgba(255, 255, 255, 0.85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-file-action {
  font-size: 0.5625rem;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.session-file-action.created {
  color: rgba(34, 197, 94, 0.7);
}

.session-file-action.edited {
  color: rgba(59, 130, 246, 0.7);
}

.session-file-action.read {
  color: rgba(168, 162, 158, 0.6);
}

/* ===== 响应式适配 ===== */
@media (max-width: 768px) {
  .session-files-sidebar {
    display: none;
  }
}

/* ===== 浅色主题样式 - 颜色反转 ===== */

/* 展示区容器 - 浅色主题 */
body:not(.dark) .chat-showcase {
  background: #f8f8f8;
  border-left: 1px solid rgba(0, 0, 0, 0.1);
}

/* 展示区头部 - 浅色主题 */
body:not(.dark) .showcase-header {
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* 关闭按钮 - 浅色主题 */
body:not(.dark) .showcase-close-btn {
  color: rgba(0, 0, 0, 0.5);
}

body:not(.dark) .showcase-close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.9);
}

/* Tab 标签 - 浅色主题 */
body:not(.dark) .showcase-tab {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.6);
}

body:not(.dark) .showcase-tab:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.15);
  color: rgba(0, 0, 0, 0.9);
}

body:not(.dark) .showcase-tab.active {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.2);
  color: rgba(0, 0, 0, 1);
}

body:not(.dark) .showcase-tab-close {
  color: rgba(0, 0, 0, 0.4);
}

body:not(.dark) .showcase-tab-close:hover {
  background: rgba(0, 0, 0, 0.15);
  color: rgba(0, 0, 0, 0.9);
}

/* 预览头部 - 浅色主题 */
body:not(.dark) .showcase-preview-header {
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

body:not(.dark) .showcase-preview-title {
  color: rgba(0, 0, 0, 0.9);
}

/* 预览内容区 - 浅色主题 */
body:not(.dark) .showcase-preview-content {
  background: rgba(0, 0, 0, 0.03);
}

body:not(.dark) #showcase-preview-code {
  color: rgba(0, 0, 0, 0.8);
}

body:not(.dark) #showcase-markdown-preview {
  color: rgba(0, 0, 0, 0.9);
}

/* 预览状态栏 - 浅色主题 */
body:not(.dark) .showcase-preview-status {
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.4);
}

/* 视图切换按钮 - 浅色主题 */
body:not(.dark) .showcase-preview-actions .preview-view-toggle {
  background: rgba(0, 0, 0, 0.05);
}

body:not(.dark) .showcase-preview-actions .view-toggle-btn {
  color: rgba(0, 0, 0, 0.4);
}

body:not(.dark) .showcase-preview-actions .view-toggle-btn:hover {
  color: rgba(0, 0, 0, 0.7);
}

body:not(.dark) .showcase-preview-actions .view-toggle-btn.active {
  background: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.9);
}

/* 空状态 - 浅色主题 */
body:not(.dark) .showcase-empty {
  color: rgba(0, 0, 0, 0.4);
}

/* 操作按钮 - 浅色主题 */
body:not(.dark) .showcase-action-btn {
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: rgba(0, 0, 0, 0.7);
}

body:not(.dark) .showcase-action-btn:hover {
  background: rgba(0, 0, 0, 0.12);
  border-color: rgba(0, 0, 0, 0.2);
  color: rgba(0, 0, 0, 0.95);
}

/* 编辑区 textarea - 浅色主题 */
body:not(.dark) .showcase-edit-area {
  background: rgba(0, 0, 0, 0.04);
  color: rgba(0, 0, 0, 0.9);
}

body:not(.dark) .showcase-edit-area:focus {
  background: rgba(0, 0, 0, 0.06);
}

/* 会话文件侧边栏 - 浅色主题 */
body:not(.dark) .session-files-sidebar {
  background: rgba(0, 0, 0, 0.02);
  border-left: 1px solid rgba(0, 0, 0, 0.06);
}

/* 侧边栏头部 - 浅色主题 */
body:not(.dark) .session-files-header {
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

body:not(.dark) .session-files-title {
  color: rgba(0, 0, 0, 0.5);
}

body:not(.dark) .session-files-toggle {
  color: rgba(0, 0, 0, 0.4);
}

body:not(.dark) .session-files-toggle:hover {
  background: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.8);
}

/* 文件列表滚动条 - 浅色主题 */
body:not(.dark) .session-files-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}

/* 空状态 - 浅色主题 */
body:not(.dark) .session-files-empty {
  color: rgba(0, 0, 0, 0.3);
}

/* 文件项 - 浅色主题 */
body:not(.dark) .session-file-item {
  background: rgba(0, 0, 0, 0.02);
}

body:not(.dark) .session-file-item:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.1);
}

body:not(.dark) .session-file-item.active {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.15);
}

body:not(.dark) .session-file-name {
  color: rgba(0, 0, 0, 0.85);
}

body:not(.dark) .session-file-action {
  color: rgba(0, 0, 0, 0.4);
}
