/* Chat Interface Styles - BYD Official Style */

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--background-light);
    max-width: 100%;
    margin: 0 auto;
}

/* PC端优化 */
@media (min-width: 769px) {
    .chat-container {
        max-width: 1400px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    }
}

/* Chat Header - BYD Dark Gray Style */
.chat-header {
    background-color: var(--primary-dark);
    color: white;
    padding: 16px 24px;
    box-shadow: var(--shadow-subtle);
    z-index: 10;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.ai-avatar {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

/* Custom avatar from channel - no padding needed */
.ai-avatar img.ai-avatar-img {
    padding: 0;
    object-fit: cover;
    border-radius: 4px;
}

.header-info h1 {
    font-size: 18px;
    font-weight: 400;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.status-indicator {
    font-size: 13px;
    opacity: 0.8;
    font-weight: 300;
}

.status-indicator::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #4ade80;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

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

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    background-color: var(--background-light);
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
}

/* PC端消息区域优化 */
@media (min-width: 769px) {
    .messages-area {
        padding: 32px 10%;
    }
}

.message {
    display: flex;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
    align-items: flex-start;
}

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

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

.message.ai {
    justify-content: flex-start;
}

/* Avatar in message */
.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* AI Avatar Image - Custom avatar from channel */
.message-avatar .ai-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    background-color: white;
}

/* Default SVG logo padding */
.message-avatar img:not(.ai-avatar-img) {
    padding: 6px;
    object-fit: contain;
}

.message.ai .message-avatar {
    margin-right: 12px;
}

.message.user .message-avatar {
    margin-left: 12px;
    background-color: var(--primary-gray);
    color: white;
    font-weight: 400;
    font-size: 14px;
}

.message-content {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

/* PC端消息宽度优化 */
@media (min-width: 769px) {
    .message-content {
        max-width: 60%;
    }
}

@media (min-width: 1200px) {
    .message-content {
        max-width: 50%;
    }
}

.message.user .message-content {
    align-items: flex-end;
}

.message.ai .message-content {
    align-items: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 8px;
    word-wrap: break-word;
    position: relative;
    line-height: 1.6;
    font-size: 15px;
    font-weight: 300;
    box-shadow: var(--shadow-subtle);
}

.message.user .message-bubble {
    background-color: var(--primary-gray);
    color: white;
}

.message.ai .message-bubble {
    background-color: white;
    color: var(--text-dark);
    border: 1px solid var(--border-light);
}

.message-time {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 6px;
    padding: 0 4px;
    font-weight: 300;
}

/* Typing Indicator - Spinner Loading */
.typing-indicator {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    align-items: center;
}

.typing-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(43, 43, 43, 0.1);
    border-top-color: var(--primary-gray);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.thinking-text {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 300;
    margin-left: 4px;
}

/* Input Area */
.input-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background-color: white;
    border-top: 1px solid var(--border-light);
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
}

/* PC端输入区域优化 */
@media (min-width: 769px) {
    .input-area {
        padding: 20px 10%;
    }
}

.voice-button,
.send-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    border-radius: 4px;
    background-color: var(--background-light);
    color: var(--text-gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.voice-button:hover {
    background-color: #e8e8e8;
}

.voice-button:active,
.send-button:active {
    transform: scale(0.95);
}

.send-button {
    background-color: var(--primary-dark);
    color: white;
}

.send-button:hover {
    background-color: var(--primary-gray);
}

/* PC端按钮优化 */
@media (min-width: 769px) {
    .voice-button,
    .send-button {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }
}

.text-input-container {
    flex: 1;
    display: flex;
    align-items: center;
}

.message-input {
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    padding: 11px 16px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 15px;
    font-family: inherit;
    font-weight: 300;
    resize: none;
    overflow-y: auto;
    background-color: var(--background-light);
    transition: border-color 0.3s ease;
    line-height: 1.5;
}

.message-input:focus {
    border-color: var(--primary-dark);
    background-color: white;
}

.message-input::placeholder {
    color: var(--text-light);
}

/* PC端输入框优化 */
@media (min-width: 769px) {
    .message-input {
        min-height: 48px;
        max-height: 150px;
        font-size: 16px;
        padding: 13px 16px;
    }
}

/* Voice Recording */
.voice-recording {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--accent-red);
    color: white;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 300;
}

.recording-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: white;
    animation: pulse 1s infinite;
}

/* Scrollbar Styling */
.messages-area::-webkit-scrollbar {
    width: 6px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-header {
        padding: 14px 16px;
    }
    
    .header-content {
        gap: 12px;
    }
    
    .ai-avatar {
        width: 40px;
        height: 40px;
    }
    
    .header-info h1 {
        font-size: 16px;
    }
    
    .messages-area {
        padding: 16px 12px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .message-bubble {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .input-area {
        padding: 12px 16px;
        gap: 10px;
    }
    
    .voice-button,
    .send-button {
        width: 40px;
        height: 40px;
    }
    
    .message-input {
        font-size: 14px;
        min-height: 40px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 375px) {
    .header-info h1 {
        font-size: 15px;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .message-bubble {
        font-size: 13px;
    }
}

/* 大屏幕优化 */
@media (min-width: 1400px) {
    .messages-area {
        padding: 32px 15%;
    }
    
    .input-area {
        padding: 20px 15%;
    }
    
    .message-content {
        max-width: 45%;
    }
}


/* Markdown Styles for AI Messages */
.message.ai .message-bubble p {
    margin: 0.5em 0;
}

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

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

.message.ai .message-bubble h1,
.message.ai .message-bubble h2,
.message.ai .message-bubble h3,
.message.ai .message-bubble h4 {
    margin: 1em 0 0.5em 0;
    font-weight: 600;
    color: var(--primary-dark);
}

.message.ai .message-bubble h1:first-child,
.message.ai .message-bubble h2:first-child,
.message.ai .message-bubble h3:first-child,
.message.ai .message-bubble h4:first-child {
    margin-top: 0;
}

.message.ai .message-bubble ul,
.message.ai .message-bubble ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message.ai .message-bubble li {
    margin: 0.3em 0;
    line-height: 1.6;
}

.message.ai .message-bubble code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message.ai .message-bubble pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 1em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.message.ai .message-bubble pre code {
    background-color: transparent;
    padding: 0;
}

.message.ai .message-bubble blockquote {
    border-left: 3px solid var(--primary-dark);
    padding-left: 1em;
    margin: 0.5em 0;
    color: #666;
}

.message.ai .message-bubble strong {
    font-weight: 600;
    color: var(--primary-dark);
}

.message.ai .message-bubble em {
    font-style: italic;
}

.message.ai .message-bubble a {
    color: var(--primary-dark);
    text-decoration: underline;
}

.message.ai .message-bubble hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin: 1em 0;
}

.message.ai .message-bubble table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5em 0;
}

.message.ai .message-bubble th,
.message.ai .message-bubble td {
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.5em;
    text-align: left;
}

.message.ai .message-bubble th {
    background-color: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

/* History Divider */
.history-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    padding: 0 20px;
}

.history-divider::before,
.history-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #ccc, transparent);
}

.history-divider span {
    color: #999;
    font-size: 12px;
    padding: 0 16px;
    white-space: nowrap;
}

/* Quick Questions in Welcome Bubble */
.welcome-message .message-bubble a[href^="#q"] {
    display: inline-block;
    background-color: #f5f5f5;
    color: var(--primary-dark);
    padding: 6px 14px;
    border-radius: 16px;
    text-decoration: none;
    font-size: 14px;
    margin: 4px 4px 4px 0;
    transition: all 0.2s ease;
    border: 1px solid var(--border-light);
}

.welcome-message .message-bubble a[href^="#q"]:hover {
    background-color: var(--primary-dark);
    color: white;
    border-color: var(--primary-dark);
}

.welcome-message .message-bubble a[href^="#q"]:active {
    transform: scale(0.96);
}

/* Quick Questions */
.quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 0;
    margin: 8px 0 16px 52px;
}

.quick-question-btn {
    background-color: white;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 300;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-question-btn:hover {
    background-color: var(--primary-dark);
    color: white;
    border-color: var(--primary-dark);
}

.quick-question-btn:active {
    transform: scale(0.96);
}

/* 移动端快捷问题优化 */
@media (max-width: 768px) {
    .quick-questions {
        margin: 8px 0 16px 0;
        padding: 12px 0;
    }
    
    .quick-question-btn {
        font-size: 13px;
        padding: 6px 12px;
    }
}
