/* 基本样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 容器样式 */
.container {
    max-width: 100%;
    height: 100%;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
header {
    text-align: center;
    padding: 10px 0;
    background-color: #007bff;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
    position: relative;
}

header h1 {
    font-size: 1.4rem;
    margin-bottom: 0;
    font-weight: bold;
}

/* 聊天容器样式 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background-color: #f5f7fa;
    position: relative;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    background-image: linear-gradient(to bottom, rgba(24, 144, 255, 0.05), rgba(24, 144, 255, 0.02));
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* 自定义滚动条 */
.chat-container::-webkit-scrollbar {
    width: 4px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

/* 聊天消息样式 */
.chat-message {
    display: flex;
    margin-bottom: 18px;
    position: relative;
    align-items: flex-start;
}

.user-message {
    flex-direction: row-reverse;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    z-index: 2;
    margin-top: 0;
}

.user-avatar {
    background-color: #1890ff;
    color: white;
}

.ai-avatar {
    background-image: url('images/img.png');
    background-color: transparent;
}

/* 新的气泡样式 */
.message-content {
    max-width: 80%;
    padding: 12px 16px;
    margin: 0 8px;
    border-radius: 18px;
    position: relative;
    line-height: 1.5;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    text-align: left;
    animation: fadeIn 0.3s ease-out;
}

/* 小箭头效果 */
.message-content:after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    bottom: 0;
}

.user-message .message-content {
    background-color: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.user-message .message-content:after {
    border-bottom-color: #007bff;
    border-right: 0;
    right: 0;
}

.ai-message .message-content {
    background-color: #f1f1f1;
    color: #333;
    border-bottom-left-radius: 4px;
}

.ai-message .message-content:after {
    border-bottom-color: #f1f1f1;
    border-left: 0;
    left: 0;
}

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

.message-time {
    position: absolute;
    font-size: 0.7rem;
    color: #999;
    bottom: -15px;
}

.user-message .message-time {
    right: 40px;
}

.ai-message .message-time {
    left: 40px;
}

/* 欢迎消息样式 */
.welcome-message-bubble {
    margin-top: 5px;
}

.welcome-message-bubble .message-content {
    font-size: 1rem;
    line-height: 1.4;
    background: #e6f7ff !important;
    border-left: 4px solid #007bff !important;
    padding: 10px 16px !important;
    white-space: normal !important;
    text-align: center;
    max-width: 90% !important;
    margin-left: 8px !important;
    border-radius: 16px !important;
}

.welcome-message-bubble .message-content:after {
    display: none;
}

/* 输入容器样式 */
.input-container {
    padding: 10px;
    background-color: white;
    border-top: 1px solid #eaeaea;
    z-index: 10;
    position: relative;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.input-container form {
    display: flex;
    align-items: center;
    max-width: 95%;
    margin: 0 auto;
}

.input-container textarea {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    resize: none;
    min-height: 24px;
    max-height: 96px;
    font-family: inherit;
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    overflow-y: auto;
    width: 85%;
    line-height: 1.6;
    white-space: pre-wrap;
    box-sizing: border-box;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.input-container textarea:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

.input-container button {
    margin-left: 10px;
    padding: 0 20px;
    height: 40px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3);
}

.input-container button:hover {
    background-color: #0069d9;
    transform: translateY(-1px);
}

.input-container button:active {
    transform: translateY(1px);
}

.input-container button:disabled {
    background-color: #b8daff;
    cursor: not-allowed;
    box-shadow: none;
}

/* 加载动画样式 */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(24, 144, 255, 0.2);
    border-radius: 50%;
    border-top-color: #1890ff;
    animation: spin 1s ease-in-out infinite;
}

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

.loading-text {
    margin-top: 10px;
    color: #666;
    font-size: 0.9rem;
}

/* 思考中动画 */
.thinking-dots {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    background: #e2e8f0;
    border-radius: 12px;
    padding: 8px 12px;
    margin-top: 8px;
}

.thinking-dots .dot {
    border-radius: 50%;
    height: 6px;
    width: 6px;
    background: #93a2b7;
    opacity: 0;
    animation: blink 1s infinite;
}

.thinking-dots .dot:nth-child(1) {
    animation-delay: 0.3333s;
}

.thinking-dots .dot:nth-child(2) {
    animation-delay: 0.6666s;
}

.thinking-dots .dot:nth-child(3) {
    animation-delay: 0.9999s;
}

@keyframes blink {
    50% {
        opacity: 1;
    }
}

/* 页脚样式 */
footer {
    text-align: center;
    padding: 8px 0;
    color: #999;
    font-size: 0.8rem;
    background-color: white;
    border-top: 1px solid #eaeaea;
}

.footer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    margin-bottom: 3px;
}

.clear-button {
    background: none;
    border: none;
    color: #999;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: all 0.2s;
}

.clear-button:hover {
    background-color: #f5f5f5;
    color: #007bff;
}

.version {
    color: #999;
    font-size: 0.8rem;
}

/* Markdown样式优化 */
.markdown-body {
    padding: 0;
    background: transparent !important;
    font-family: inherit !important;
    line-height: 1.4 !important;
    font-size: 0.95rem !important;
    color: inherit !important;
}

.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3, 
.markdown-body h4 {
    margin-top: 8px !important;
    margin-bottom: 4px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    color: #333 !important;
}

.markdown-body h3 {
    font-size: 1.15em !important;
    border-bottom: 1px solid #eaecef !important;
    padding-bottom: 0.2em !important;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.2em !important;
    margin-bottom: 8px !important;
    margin-top: 4px !important;
}

.markdown-body li {
    margin-bottom: 2px !important;
}

.markdown-body li + li {
    margin-top: 0.1em !important;
}

.markdown-body strong {
    font-weight: 600 !important;
    color: #24292e !important;
}

.markdown-body p {
    margin-top: 0 !important;
    margin-bottom: 6px !important;
}

.markdown-body br + br {
    display: none !important;
}

.markdown-body a {
    color: #0366d6;
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.markdown-body pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 3px;
    margin-bottom: 16px;
}

.markdown-body pre code {
    padding: 0;
    background-color: transparent;
}

/* 响应式设计 */
@media (min-width: 768px) {
    .container {
        max-width: 600px;
        height: 100%;
        border-left: 1px solid #eaeaea;
        border-right: 1px solid #eaeaea;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .input-container form {
        max-width: 90%;
    }
}

@media (max-width: 900px) {
    .container {
        max-width: 100vw;
        border: none;
    }
    .chat-container {
        max-width: 100vw;
        padding: 10px 4px;
    }
}

@media (max-width: 600px) {
    html, body {
        font-size: 15px;
        width: 100vw;
        height: 100vh;
        margin: 0;
        padding: 0;
        overflow-x: hidden;
    }
    body {
        min-width: 100vw;
        min-height: 100vh;
        background-color: #f5f7fa;
    }
    .container {
        max-width: 100vw;
        height: 100vh;
        min-height: 100vh;
        margin: 0;
        padding: 0;
        border: none;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }
    header h1 {
        font-size: 1.2rem;
    }
    .chat-container {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 6px 2px 6px 2px;
        background: #f5f7fa;
        font-size: 1rem;
        min-height: 0;
        max-width: 100vw;
    }
    .chat-message {
        margin-bottom: 8px;
    }
    .message-content {
        max-width: 92vw;
        padding: 10px 10px;
        border-radius: 16px;
        font-size: 1rem;
        margin: 0 2px;
    }
    .avatar {
        width: 24px;
        height: 24px;
        font-size: 12px;
        margin: 0 2px;
    }
    .message-time {
        font-size: 0.7rem;
        bottom: -12px;
        left: unset;
        right: unset;
        margin: 0 2px;
    }
    .user-message .message-time {
        right: 28px;
    }
    .ai-message .message-time {
        left: 28px;
    }
    .input-container {
        padding: 6px 2px;
        background: #fff;
        border-top: 1px solid #eaeaea;
        box-shadow: 0 -1px 6px rgba(0,0,0,0.03);
    }
    .input-container form {
        display: flex;
        align-items: flex-end;
        max-width: 100vw;
        margin: 0 auto;
    }
    .input-container textarea {
        font-size: 1rem;
        min-height: 38px;
        max-height: 120px;
        padding: 8px 10px;
        border-radius: 16px;
        width: 78vw;
        margin-right: 6px;
        resize: none;
        line-height: 1.5;
        overflow-y: auto;
        box-sizing: border-box;
    }
    .input-container button {
        font-size: 1rem;
        height: 38px;
        padding: 0 12px;
        border-radius: 16px;
        flex-shrink: 0;
    }
    .welcome-message-bubble .message-content {
        font-size: 1rem;
        padding: 8px 8px !important;
        border-radius: 14px !important;
        max-width: 96vw !important;
    }
    footer {
        font-size: 0.85rem;
        padding: 4px 0;
    }
    .footer-actions {
        padding: 0 4px;
    }
    .clear-button {
        font-size: 0.9rem;
        padding: 3px 6px;
    }
    .version {
        font-size: 0.85rem;
    }
}

@media (max-width: 420px) {
    html, body {
        font-size: 13px;
    }
    .message-content {
        max-width: 96vw;
        font-size: 0.98rem;
        padding: 8px 6px;
    }
    .input-container textarea {
        width: 72vw;
        font-size: 0.98rem;
        min-height: 36px;
        max-height: 100px;
        padding: 6px 6px;
    }
    .input-container button {
        font-size: 0.98rem;
        height: 36px;
        padding: 0 8px;
        border-radius: 14px;
    }
    .avatar {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
}

/* 手机端风格整体适配（即使在PC端也像App） */
.mobile-style {
    max-width: 430px;
    min-width: 320px;
    margin: 0 auto;
    height: 100vh;
    background: #f5f7fa;
    border-radius: 18px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid #eaeaea;
}
.mobile-style header {
    border-radius: 18px 18px 0 0;
    font-size: 1.1rem;
    padding: 14px 0 10px 0;
    background: #007bff;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.mobile-style .chat-container {
    background: #f5f7fa;
    padding: 10px 4px 10px 4px;
    flex: 1;
    overflow-y: auto;
    border-radius: 0;
    max-width: 100vw;
}
.mobile-style .chat-message {
    margin-bottom: 10px;
}
.mobile-style .message-content {
    border-radius: 18px;
    font-size: 1rem;
    padding: 10px 14px;
    max-width: 85vw;
    margin: 0 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.mobile-style .user-message .message-content {
    background: #007bff;
    color: #fff;
    border-bottom-right-radius: 8px;
}
.mobile-style .ai-message .message-content {
    background: #f1f1f1;
    color: #333;
    border-bottom-left-radius: 8px;
}
.mobile-style .avatar {
    width: 28px;
    height: 28px;
    font-size: 13px;
    margin: 0 2px;
}
.mobile-style .message-time {
    font-size: 0.7rem;
    color: #999;
    bottom: -13px;
    left: unset;
    right: unset;
    margin: 0 2px;
}
.mobile-style .input-container {
    background: #fff;
    border-top: 1px solid #eaeaea;
    box-shadow: 0 -1px 6px rgba(0,0,0,0.03);
    padding: 14px 4px 12px 4px;
    border-radius: 0 0 18px 18px;
}
.mobile-style .input-container form {
    display: flex;
    align-items: stretch;
    max-width: 100vw;
    margin: 0 auto;
    height: auto;
}
.mobile-style .input-container textarea {
    flex: 1;
    font-size: 16px;
    min-height: 32px;
    max-height: 120px;
    padding: 8px 12px;
    border-radius: 18px;
    margin-right: 6px;
    resize: none;
    line-height: 1.6;
    overflow-y: auto;
    box-sizing: border-box;
    border: 1px solid #eaeaea;
    background: #f7fafd;
    display: block;
    align-self: stretch;
}
.mobile-style .input-container button {
    min-height: 32px;
    font-size: 1rem;
    width: 64px;
    padding: 0 6px;
    border-radius: 16px;
    flex-shrink: 0;
    background: #007bff;
    color: #fff;
    border: none;
    box-shadow: 0 2px 6px rgba(0,123,255,0.13);
    transition: background 0.2s;
    margin-bottom: 0;
    align-self: stretch;
}
.mobile-style .input-container button:hover {
    background: #005ecb;
}
.mobile-style footer {
    font-size: 0.85rem;
    padding: 6px 0 2px 0;
    background: #fff;
    border-radius: 0 0 18px 18px;
    box-shadow: 0 -1px 6px rgba(0,0,0,0.03);
}
.mobile-style .footer-actions {
    padding: 0 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mobile-style .clear-button {
    font-size: 0.9rem;
    padding: 4px 10px;
    border-radius: 10px;
    background: #f5f7fa;
    border: 1px solid #eaeaea;
    color: #007bff;
    transition: background 0.2s;
}
.mobile-style .clear-button:hover {
    background: #e6f0fa;
}
.mobile-style .version {
    font-size: 0.85rem;
    color: #999;
} 

html, body, textarea, input, button {
    font-size: 16px !important;
    font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

.mobile-style .input-container textarea {
    min-height: 48px;
    max-height: 180px;
    height: auto;
    overflow-y: auto;
    resize: none;
    line-height: 1.6;
    font-size: 16px;
    width: 100%;
    box-sizing: border-box;
    display: block;
    -webkit-overflow-scrolling: touch;
    touch-action: auto;
}