/* 基础样式 */
*,*::before,*::after{
    box-sizing: border-box;
}

body {
    display: flex;
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    background-color: #f0f2f5;
    height: 100vh;
    margin: 0;
    padding: 10px;
    color: #333;

    /* 移动端适配 */
    @media (max-width: 768px) {
        padding: 0;
    }
}

/* 聊天容器 */
.chat-container {
    width: 90%;
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    gap: 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    padding: 24px;

    /* 移动端适配 */
    @media (max-width: 768px) {
        width: 100%;
        height: 100vh;
        margin: 0;
        padding: 12px;
        border-radius: 0;
        flex-direction: column;
    }
}

/* 侧边栏 */
.sidebar {
    width: 250px;
    border-right: 1px solid #eee;
    padding-right: 20px;

    /* 移动端适配 */
    @media (max-width: 768px) {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #eee;
        padding-right: 0;
        padding-bottom: 10px;
    }
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: bold;
    padding: 0 0 10px;
    border-bottom: 1px solid #eee;
    margin-bottom: 10px;
}

.session-list {
    overflow-y: auto;
    max-height: calc(100vh - 150px);

    /* 移动端适配 */
    @media (max-width: 768px) {
        min-height: 100px;
        max-height: 100px;
        padding: 0 5px;
    }
}

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.session-content {
    flex: 1;
    min-width: 0;
    margin-right: 8px;
}

.session-item:hover {
    background-color: #f5f5f5;
}

.session-item.active {
    background-color: #e3f2fd;
    border-left: 3px solid #1a73e8;
}

.session-title {
    font-size: 14px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-time {
    font-size: 12px;
    color: #666;
}

.session-delete-btn {
    padding: 4px;
    background: transparent;
    color: #999;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
}

.session-item:hover .session-delete-btn {
    opacity: 1;
}

.session-delete-btn:hover {
    background: #fee2e2;
    color: #ef4444;
    transform: none;
}

/* 主内容区 */
.main-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;

    /* 移动端适配 */
    @media (max-width: 768px) {
        height: calc(100vh - 210px);
    }
}

/* 标题区域 */
.chat-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.chat-header h1 {
    font-size: 24px;
    color: #1a73e8;
    margin: 0;
}

/* 聊天框 */
.chat-box {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    background: #fafafa;

    /* 移动端适配 */
    @media (max-width: 768px) {
        margin-bottom: 10px;
        border-radius: 8px;
    }
}

/* 聊天记录 */
.chat-list {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

/* 滚动条样式 */
.chat-list::-webkit-scrollbar {
    width: 8px;
}

.chat-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.chat-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.chat-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 输入区域 */
.input-area {
    display: flex;
    gap: 12px;
    position: relative;

    /* 移动端适配 */
    @media (max-width: 768px) {
        gap: 8px;
    }
}

textarea {
    flex: 1;
    height: 80px;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    resize: none;
    font-size: 15px;
    transition: border-color 0.3s;
    font-family: inherit;

    /* 移动端适配 */
    @media (max-width: 768px) {
        height: 60px;
        padding: 8px 12px;
        font-size: 14px;
        border-radius: 8px;
    }
}

textarea:focus {
    outline: none;
    border-color: #1a73e8;
}

/* 按钮样式 */
button {
    padding: 0 32px;
    background: #1a73e8;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 15px;
    font-weight: 500;

    /* 移动端适配 */
    @media (max-width: 768px) {
        padding: 0 20px;
        font-size: 14px;
    }
}

button:hover {
    background: #1557b0;
    transform: translateY(-1px);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* 消息样式 */
.message {
    margin: 16px 0;
    display: flex;
    width: 100%;
    justify-content: flex-start;
    clear: both;
}

.message-content-wrapper {
    display: flex;
    flex-direction: column-reverse;
    max-width: 80%;
    min-width: 50px;
    width: fit-content;

    /* 移动端适配 */
    @media (max-width: 768px) {
        max-width: 90%;
    }
}

.message-content {
    padding: 12px 18px;
    border-radius: 16px;
    word-wrap: break-word;
    position: relative;
    animation: fadeIn 0.3s ease-in-out;
    line-height: 1.5;
    margin: 0;
}

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

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

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

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

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

/* 模型切换开关 */
.model-switch {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
}

.switch-label {
    color: #666;
    font-size: 14px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #1a73e8;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* 思考中的消息样式 */
.thinking-timer {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin: 0;
    font-size: 12px;
}

.thinking-timer .timer {
    margin-left: 4px;
    font-family: monospace;
}

.thinking-timer + .reasoning-content,
.thinking-timer + .main-content-area {
    margin-top: 12px;
}

/* Markdown样式 */
.ai-message .message-content {
    font-size: 15px;
}

.ai-message .message-content p {
    margin: 0 0 10px 0;
}

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

.ai-message .message-content pre {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 10px 0;

    /* 移动端适配 */
    @media (max-width: 768px) {
        padding: 8px;
        font-size: 12px;
    }
}

.ai-message .message-content code {
    font-family: Consolas, Monaco, 'Andale Mono', monospace;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 3px;
}

.ai-message .message-content pre code {
    padding: 0;
    background: none;
}

.ai-message .message-content ul, 
.ai-message .message-content ol {
    margin: 10px 0;
    padding-left: 20px;
}

.ai-message .message-content blockquote {
    border-left: 4px solid #dfe2e5;
    margin: 10px 0;
    padding-left: 16px;
    color: #666;
}

.ai-message .message-content table {
    border-collapse: collapse;
    margin: 10px 0;
    width: 100%;
}

.ai-message .message-content table th,
.ai-message .message-content table td {
    border: 1px solid #dfe2e5;
    padding: 6px 13px;
}

.ai-message .message-content table th {
    background: #f6f8fa;
}

/* 链接样式 */
.ai-message .message-content a {
    color: #0366d6;
    text-decoration: none;
}

.ai-message .message-content a:hover {
    text-decoration: underline;
}

/* 行内代码 */
.ai-message .message-content :not(pre) > code {
    background: #f6f8fa;
    border-radius: 3px;
    padding: 2px 4px;
    font-size: 85%;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: normal;
    background: #f0f9ff;
    color: #1a73e8;
    border: 1px solid #e3f2fd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: #e3f2fd;
    transform: none;
}

.new-chat-btn svg {
    width: 16px;
    height: 16px;
}

.response-info {
    font-size: 10px;
    color: #666;
    text-align: right;
    padding: 4px 18px 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.copy-btn {
    padding: 3px;
    width: 20px;
    height: 20px;
    font-size: 10px;
    background: transparent;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-btn:hover {
    background: #f0f9ff;
    color: #1a73e8;
    border-color: #1a73e8;
}

.copy-btn svg {
    width: 14px;
    height: 14px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .copy-btn {
        padding: 2px;
        width: 18px;
        height: 18px;
    }

    .copy-btn svg {
        width: 12px;
        height: 12px;
    }
}

/* 临时文本区域样式 */
textarea.temp-copy {
    position: fixed;
    top: 0;
    left: 0;
    opacity: 0;
    pointer-events: none;
}

/* Toast样式 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    animation: toastFadeIn 0.3s ease, toastFadeOut 0.3s ease forwards;
    animation-delay: 0s, 1.7s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    word-break: break-word;
}

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

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

/* 移动端适配 */
@media (max-width: 768px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        padding: 10px 20px;
        font-size: 13px;
        text-align: center;
        margin: 0 auto;
    }
}

/* 推理内容样式 */
.reasoning-content {
    margin-bottom: 12px;
    padding: 0 6px;
    border-left: 2px solid #e0e5eb;
    font-size: 12px;
    color: #999;
    text-align: justify;
}

.reasoning-content p {
    margin: 0 0 6px 0;
}

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

.main-content-area {
    font-size: 15px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .reasoning-content {
        padding: 8px;
        font-size: 12px;
    }

    .main-content-area {
        font-size: 14px;
    }
}
