/**
 * Thinking Content Styles - AI思考内容展示组件
 * 素色设计风格
 * 版本: v3.0 (素色设计)
 */

/* ============================================
   1. 思考内容容器
   ============================================ */

.thinking-container {
    margin-bottom: var(--space-4);
    border-radius: var(--radius-lg);
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: all var(--transition-base);
    animation: thinkingAppear 0.4s ease-out;
}

.dark-mode .thinking-container {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
}

/* 思考内容出现动画 */
@keyframes thinkingAppear {
    from {
        opacity: 0;
        transform: translateY(-8px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 500px;
    }
}

/* 折叠状态 */
.thinking-container.collapsed .thinking-content {
    max-height: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
}

/* ============================================
   2. 思考内容头部
   ============================================ */

.thinking-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast);
}

.thinking-header:hover {
    background: rgba(0, 0, 0, 0.03);
}

.dark-mode .thinking-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.thinking-container.collapsed .thinking-header {
    padding: var(--space-2) var(--space-3);
}

/* 思考标题 */
.thinking-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
    min-width: 0;
}

/* 思考图标 - 素色设计 */
.thinking-title i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.dark-mode .thinking-title i {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

.thinking-container.collapsed .thinking-title i {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
}

.thinking-title span:first-of-type {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thinking-container.collapsed .thinking-title span:first-of-type {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

/* 思考状态 */
.thinking-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-left: var(--space-2);
}

/* 思考中动画 */
.thinking-container:not(.collapsed) .thinking-title i {
    animation: thinkingPulse 2s ease-in-out infinite;
}

@keyframes thinkingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* 折叠按钮 */
.thinking-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
}

.thinking-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
}

.dark-mode .thinking-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
}

.thinking-toggle i {
    transition: transform var(--transition-base);
}

.thinking-container.collapsed .thinking-toggle i {
    transform: rotate(0deg);
}

.thinking-container:not(.collapsed) .thinking-toggle i {
    transform: rotate(180deg);
}

/* ============================================
   3. 思考内容主体
   ============================================ */

.thinking-content {
    padding: 0 var(--space-4) var(--space-4);
    overflow: hidden;
    transition: all var(--transition-base);
    max-height: 400px;
    opacity: 1;
}

/* 思考气泡 */
.thinking-bubble {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    color: var(--text-secondary);
    padding: var(--space-3);
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all var(--transition-base);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 思考气泡内 Markdown 内容样式 */
.thinking-bubble p {
    font-size: var(--font-size-sm);
    margin: var(--space-2) 0;
    line-height: var(--line-height-relaxed);
}

.thinking-bubble p:first-child {
    margin-top: 0;
}

.thinking-bubble p:last-child {
    margin-bottom: 0;
}

.thinking-bubble h1,
.thinking-bubble h2,
.thinking-bubble h3,
.thinking-bubble h4 {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    margin: var(--space-3) 0 var(--space-2);
    color: var(--text-secondary);
}

.thinking-bubble ul,
.thinking-bubble ol {
    font-size: var(--font-size-sm);
    margin: var(--space-2) 0;
    padding-left: var(--space-5);
}

.thinking-bubble li {
    font-size: var(--font-size-sm);
    margin: var(--space-1) 0;
}

.thinking-bubble code {
    font-family: var(--font-family-mono);
    font-size: 0.8125em;
    background: rgba(0, 0, 0, 0.05);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
}

.thinking-bubble pre {
    font-size: 0.8125rem;
    background: rgba(0, 0, 0, 0.04);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: var(--space-2) 0;
}

.thinking-bubble pre code {
    background: transparent;
    padding: 0;
    font-size: 0.8125rem;
}

.thinking-bubble blockquote {
    border-left: 3px solid var(--text-quaternary);
    padding: var(--space-2) var(--space-3);
    margin: var(--space-2) 0;
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
}

.dark-mode .thinking-bubble {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
}

/* 流式输出光标效果 */
.thinking-bubble.streaming::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--text-tertiary);
    margin-left: 2px;
    animation: typingCursor 1s step-end infinite;
    vertical-align: text-bottom;
}

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

/* ============================================
   4. 流式指示器
   ============================================ */

.thinking-content .streaming-indicator {
    display: flex;
    gap: 4px;
    margin-top: var(--space-2);
    justify-content: flex-start;
}

.thinking-content .streaming-dot {
    width: 6px;
    height: 6px;
    background: var(--text-tertiary);
    border-radius: var(--radius-full);
    animation: thinkingDot 1.4s infinite ease-in-out;
}

.thinking-content .streaming-dot:nth-child(1) {
    animation-delay: 0s;
}

.thinking-content .streaming-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-content .streaming-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinkingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   5. 响应式设计
   ============================================ */

@media (max-width: 768px) {
    .thinking-container {
        margin-bottom: var(--space-3);
    }
    
    .thinking-header {
        padding: var(--space-2) var(--space-3);
    }
    
    .thinking-title i {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }
    
    .thinking-content {
        padding: 0 var(--space-3) var(--space-3);
        max-height: 300px;
    }
    
    .thinking-bubble {
        padding: var(--space-2);
        font-size: 0.8125rem;
    }

    .thinking-bubble p {
        font-size: 0.8125rem;
    }

    .thinking-bubble h1,
    .thinking-bubble h2,
    .thinking-bubble h3,
    .thinking-bubble h4 {
        font-size: 0.8125rem;
    }

    .thinking-bubble ul,
    .thinking-bubble ol {
        font-size: 0.8125rem;
    }

    .thinking-bubble li {
        font-size: 0.8125rem;
    }

    .thinking-bubble pre {
        font-size: 0.75rem;
    }

    .thinking-bubble pre code {
        font-size: 0.75rem;
    }

    .thinking-bubble blockquote {
        font-size: 0.8125rem;
    }
}

/* ============================================
   6. 可访问性
   ============================================ */

.thinking-header:focus {
    outline: 2px solid rgba(0, 0, 0, 0.2);
    outline-offset: 2px;
}

.dark-mode .thinking-header:focus {
    outline-color: rgba(255, 255, 255, 0.3);
}

.thinking-toggle:focus {
    outline: 2px solid rgba(0, 0, 0, 0.2);
    outline-offset: 2px;
}

.dark-mode .thinking-toggle:focus {
    outline-color: rgba(255, 255, 255, 0.3);
}

/* 减少动画模式 */
@media (prefers-reduced-motion: reduce) {
    .thinking-container {
        animation: none;
    }
    
    .thinking-title i {
        animation: none;
    }
    
    .thinking-bubble.streaming::after {
        animation: none;
        opacity: 1;
    }
    
    .thinking-content .streaming-dot {
        animation: none;
    }
}

/* ============================================
   7. 打印样式
   ============================================ */

@media print {
    .thinking-container {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .thinking-toggle {
        display: none;
    }
    
    .thinking-content {
        max-height: none !important;
        opacity: 1 !important;
    }
}
