.collapsible-panel {
  margin-bottom: 8px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
}

.collapsible-panel:hover {
  border-color: rgba(0, 0, 0, 0.1);
}

.collapsible-panel .ant-collapse-header {
  display: flex !important;
  align-items: center;
  padding: 8px 12px !important;
  background: rgba(0, 0, 0, 0.02);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.collapsible-panel .ant-collapse-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* Custom arrow icon */
.collapsible-panel-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  transition: transform 0.2s ease;
  color: var(--accent-color, #1890ff);
}

.collapsible-panel-arrow.expanded {
  transform: rotate(90deg);
}

/* Panel content */
.collapsible-panel .ant-collapse-content {
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.collapsible-panel .ant-collapse-content-box {
  padding: 12px !important;
}

/* Header title */
.collapsible-panel-title {
  flex: 1;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.85);
}

/* Accent color theming via CSS variable */
.collapsible-panel[style*="--accent-color"] .collapsible-panel-arrow {
  color: var(--accent-color);
}

.collapsible-panel[style*="--accent-color"] .collapsible-panel-title {
  color: var(--accent-color, rgba(0, 0, 0, 0.85));
}

/* Left border for agent collaboration panels */
.collapsible-panel.agent-collaboration {
  border-left: 3px solid var(--accent-color, #9B7EBD);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Tool output panel specific styles */
.tool-output-panel {
  --accent-color: #722ed1;
}

.tool-output-panel.streaming {
  border-color: var(--accent-color);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.tool-output-event {
  padding: 6px 8px;
  margin: 4px 0;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 4px;
  font-size: 13px;
}

.tool-output-event-name {
  font-weight: 500;
  color: rgba(0, 0, 0, 0.85);
}

.tool-output-event-status {
  margin-left: 8px;
  font-size: 12px;
}

.tool-output-event-status.running {
  color: #1890ff;
}

.tool-output-event-status.success {
  color: #52c41a;
}

.tool-output-event-status.failed {
  color: #ff4d4f;
}

/* Thinking panel specific styles */
.thinking-panel {
  --accent-color: #13c2c2;
}

.thinking-panel-preview {
  color: rgba(0, 0, 0, 0.45);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

/* Status indicator */
.panel-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  margin-left: 8px;
}

.panel-status-badge.streaming {
  background: rgba(24, 144, 255, 0.1);
  color: #1890ff;
}

.panel-status-badge.done {
  background: rgba(82, 196, 26, 0.1);
  color: #52c41a;
}

.panel-status-badge.failed {
  background: rgba(255, 77, 79, 0.1);
  color: #ff4d4f;
}

/* ========== 深色主题适配 ========== */

[data-theme='dark'] .collapsible-panel {
  border-color: var(--border-color);
  background: var(--bg-elevated);
}

[data-theme='dark'] .collapsible-panel:hover {
  border-color: var(--color-primary-opacity-30);
}

[data-theme='dark'] .collapsible-panel .ant-collapse-header {
  background: var(--bg-base);
}

[data-theme='dark'] .collapsible-panel .ant-collapse-header:hover {
  background: var(--color-primary-opacity-10);
}

[data-theme='dark'] .collapsible-panel .ant-collapse-content {
  border-top-color: var(--border-color);
}

[data-theme='dark'] .collapsible-panel-title {
  color: var(--text-primary);
}

[data-theme='dark'] .collapsible-panel[style*="--accent-color"] .collapsible-panel-title {
  color: var(--accent-color);
}

[data-theme='dark'] .tool-output-event {
  background: var(--bg-base);
}

[data-theme='dark'] .tool-output-event-name {
  color: var(--text-primary);
}

[data-theme='dark'] .thinking-panel-preview {
  color: var(--text-secondary);
}

[data-theme='dark'] .panel-status-badge.streaming {
  background: var(--color-primary-opacity-10);
  color: var(--color-primary);
}

[data-theme='dark'] .panel-status-badge.done {
  background: rgba(82, 196, 26, 0.15);
  color: #52c41a;
}

[data-theme='dark'] .panel-status-badge.failed {
  background: rgba(255, 77, 79, 0.15);
  color: #ff4d4f;
}

/* ========== 深色主题适配 ========== */

[data-theme='dark'] .collapsible-panel {
  border-color: var(--border-color);
  background: var(--bg-elevated);
}

[data-theme='dark'] .collapsible-panel:hover {
  border-color: var(--color-primary-opacity-30);
}

[data-theme='dark'] .collapsible-panel .ant-collapse-header {
  background: var(--bg-base);
}

[data-theme='dark'] .collapsible-panel .ant-collapse-header:hover {
  background: var(--color-primary-opacity-10);
}

[data-theme='dark'] .collapsible-panel .ant-collapse-content {
  border-top-color: var(--border-color);
  background: var(--bg-elevated);
}

[data-theme='dark'] .collapsible-panel .ant-collapse-content-box {
  background: var(--bg-elevated);
}

[data-theme='dark'] .collapsible-panel-title {
  color: var(--text-primary);
}

[data-theme='dark'] .collapsible-panel[style*="--accent-color"] .collapsible-panel-title {
  color: var(--accent-color);
}

[data-theme='dark'] .tool-output-event {
  background: var(--bg-base);
}

[data-theme='dark'] .tool-output-event-name {
  color: var(--text-primary);
}

[data-theme='dark'] .thinking-panel-preview {
  color: var(--text-secondary);
}

[data-theme='dark'] .panel-status-badge.streaming {
  background: var(--color-primary-opacity-10);
  color: var(--color-primary);
}

[data-theme='dark'] .panel-status-badge.done {
  background: rgba(82, 196, 26, 0.15);
  color: #52c41a;
}

[data-theme='dark'] .panel-status-badge.failed {
  background: rgba(255, 77, 79, 0.15);
  color: #ff4d4f;
}

/* Thinking panel 深色模式增强 */
[data-theme='dark'] .thinking-panel {
  background: var(--bg-elevated);
}

[data-theme='dark'] .thinking-panel .collapsible-panel {
  background: var(--bg-elevated);
  border-color: var(--border-color);
}

[data-theme='dark'] .thinking-panel .ant-collapse-header {
  background: var(--bg-base) !important;
}

[data-theme='dark'] .thinking-panel .ant-collapse-content {
  background: var(--bg-elevated) !important;
}

[data-theme='dark'] .thinking-panel .ant-collapse-content-box {
  background: var(--bg-elevated) !important;
}

[data-theme='dark'] .thinking-panel pre {
  color: var(--text-primary) !important;
  background: transparent !important;
}

/* Ant Design Collapse ghost 模式深色适配 */
[data-theme='dark'] .ant-collapse {
  background: transparent;
}

[data-theme='dark'] .ant-collapse-header {
  color: var(--text-primary);
}

[data-theme='dark'] .ant-collapse-content {
  background: transparent;
  border-top-color: var(--border-color);
}

[data-theme='dark'] .ant-collapse-content-box {
  color: var(--text-primary);
}