/* LLM Studio - Chat Messages, Reasoning Accordion & Code Blocks */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
    scroll-behavior: smooth;
}

.chat-scroll-inner {
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 0 140px 0;
    display: flex;
    flex-direction: column;
    gap: 28px;
    flex: 1;
}

/* Welcome Screen */
.welcome-screen {
    margin: auto;
    text-align: center;
    max-width: 760px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 30px 0;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero-avatar {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    box-shadow: 0 10px 30px var(--primary-glow);
}

.hero-avatar.qwen-mark {
    padding: 7px;
    background: rgba(255, 255, 255, 0.94);
}

.welcome-screen h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.welcome-screen p {
    font-size: 14.5px;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 580px;
}

.quick-prompts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 12px;
    width: 100%;
    margin-top: 10px;
}

.prompt-chip {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.chip-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.chip-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chip-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-main);
}

.chip-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.prompt-chip:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md), 0 0 15px var(--primary-glow);
}

/* Message Rows & Bubbles */
.message-row {
    display: flex;
    gap: 16px;
    width: 100%;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-row.user {
    justify-content: flex-end;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    margin-top: 2px;
}

.assistant .avatar {
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    color: white;
}

.assistant .avatar.qwen-avatar {
    padding: 4px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.assistant .avatar.qwen-avatar .qwen-logo-image {
    border-radius: 7px;
}

.assistant .bubble-wrapper {
    max-width: 100%;
}

.user .avatar {
    background: var(--user-bubble-bg);
    color: white;
}

.bubble-wrapper {
    max-width: 90%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.user .bubble-wrapper {
    align-items: flex-end;
    max-width: 82%;
}

.bubble {
    line-height: 1.7;
    font-size: 14.5px;
    word-break: break-word;
}

.user .bubble {
    background: var(--user-bubble-bg);
    color: var(--user-bubble-text);
    padding: 14px 18px;
    border-radius: 18px 18px 4px 18px;
    box-shadow: var(--shadow-md);
    font-weight: 400;
}

.assistant .bubble {
    color: var(--assistant-text);
    background: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
}

/* DeepSeek R1 Style Thinking / Reasoning Accordion */
.reasoning-accordion {
    background: var(--reasoning-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin: 4px 0 16px 0;
    padding: 0;
    overflow: hidden;
    transition: all 0.25s ease;
}

.reasoning-accordion summary {
    padding: 10px 14px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    outline: none;
    transition: background 0.2s;
}

.reasoning-accordion summary:hover {
    background: rgba(99, 102, 241, 0.08);
}

.summary-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.thinking-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    animation: thinkingPulse 1.2s infinite ease-in-out;
}

.thinking-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    font-size: 12.5px;
    font-weight: 600;
    padding: 8px 0 12px;
}

@keyframes thinkingPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(0.7); }
}

.chevron-icon {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.25s ease;
}

.reasoning-accordion[open] .chevron-icon {
    transform: rotate(180deg);
}

.reasoning-content {
    padding: 12px 16px 14px 16px;
    font-size: 13px;
    color: var(--reasoning-text);
    line-height: 1.65;
    border-top: 1px dashed rgba(99, 102, 241, 0.15);
}

.reasoning-content p {
    margin-bottom: 8px;
}

.reasoning-content p:last-child {
    margin-bottom: 0;
}

/* Typing Cursor Effect */
.typing-cursor {
    display: inline-block;
    width: 6px;
    height: 16px;
    background-color: var(--primary);
    margin-left: 4px;
    vertical-align: middle;
    animation: blink 0.8s infinite;
    border-radius: 2px;
}

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

/* Action Toolbar Below Assistant Message */
.assistant-action-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.action-btn:hover {
    color: var(--text-main);
    background: var(--bg-sidebar);
}

.message-metrics-badge {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 14px;
    margin-left: auto;
}

.message-metrics-badge strong {
    color: var(--text-main);
}

/* Markdown Elements in Assistant Messages */
.assistant .bubble p { margin-bottom: 12px; }
.assistant .bubble p:last-child { margin-bottom: 0; }

.assistant .bubble h1, .assistant .bubble h2, .assistant .bubble h3, .assistant .bubble h4 {
    margin: 16px 0 8px 0;
    font-weight: 700;
    color: var(--text-main);
}

.assistant .bubble ul, .assistant .bubble ol {
    margin: 8px 0 12px 24px;
    line-height: 1.65;
}

.assistant .bubble li { margin-bottom: 4px; }

.assistant .bubble blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
    margin: 12px 0;
    color: var(--text-muted);
    font-style: italic;
}

.assistant .bubble table {
    border-collapse: collapse;
    width: 100%;
    margin: 14px 0;
    font-size: 13.5px;
}

.assistant .bubble th, .assistant .bubble td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.assistant .bubble th {
    background: var(--bg-sidebar);
    font-weight: 600;
}

/* Code Blocks & Syntax Highlighting */
.code-block-wrapper {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 14px 0;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.code-block-header {
    background: var(--code-header-bg);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-family: var(--font-mono);
    font-size: 12px;
    color: #94a3b8;
}

.copy-code-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.copy-code-btn:hover {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
}

.bubble pre {
    background: transparent;
    padding: 14px 16px;
    margin: 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13.5px;
    color: var(--code-text);
    line-height: 1.6;
}

.bubble code {
    font-family: var(--font-mono);
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13.5px;
}

.bubble pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}
