/* AI答疑页面样式 - DeepSeek风格 */

/* CSS变量定义 */
:root {
    --primary-color: #10a37f;
    --primary-hover: #0d8b6d;
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-sidebar: #f9f9fa;
    --text-primary: #1a1a1a;
    --text-secondary: #6e6e80;
    --border-color: #e5e5e7;
    --user-message-bg: #f7f7f8;
    --ai-message-bg: #ffffff;
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.12);
    --transition-speed: 0.3s;
}

/* 深色主题 */
[data-theme="dark"] {
    --bg-primary: #212121;
    --bg-secondary: #2f2f2f;
    --bg-sidebar: #171717;
    --text-primary: #ececf1;
    --text-secondary: #8e8ea0;
    --border-color: #424242;
    --user-message-bg: #2f2f2f;
    --ai-message-bg: #212121;
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* 重置默认样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    transition: background-color var(--transition-speed), color var(--transition-speed);
    position: fixed;
    width: 100%;
    height: 100%;
}

/* 主容器 */
.chat-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-speed), background-color var(--transition-speed);
    z-index: 100;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background-color: var(--bg-secondary);
    border-color: var(--primary-color);
}

.new-chat-btn .icon {
    font-size: 18px;
    font-weight: bold;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-history-item {
    padding: 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-history-item:hover {
    background-color: var(--bg-secondary);
}

.chat-history-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-delete {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
    flex-shrink: 0;
}

.chat-history-item:hover .chat-history-delete {
    display: block;
}

.chat-history-delete:hover {
    color: #ff4d4f;
}

.chat-history-item.active {
    background-color: var(--bg-secondary);
    border-left: 3px solid var(--primary-color);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.back-home {
    display: block;
    padding: 12px;
    text-align: center;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
}

.back-home:hover {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
}

/* 主聊天区域 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    position: relative;
}

/* 顶部导航栏 */
.chat-header {
    padding: 16px 24px;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-primary);
    box-shadow: none;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
}

.menu-toggle span {
    width: 20px;
    height: 2px;
    background-color: var(--text-primary);
    transition: all 0.3s;
}

.chat-title {
    display: none;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.new-chat-mobile {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    transition: all 0.2s;
    align-items: center;
    justify-content: center;
}

.new-chat-mobile svg {
    width: 22px;
    height: 22px;
}

.new-chat-mobile:hover {
    background-color: var(--bg-secondary);
    transform: scale(1.05);
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: var(--bg-secondary);
}

/* 消息显示区域 */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    scroll-behavior: smooth;
}

/* 隐藏滚动条但保持滚动功能 */
.messages-container::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* 欢迎消息 */
.welcome-message {
    max-width: 800px;
    margin: 60px auto;
    text-align: center;
    padding: 40px;
}

.welcome-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: 50%;
    overflow: hidden;
}

.welcome-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.welcome-message h2 {
    font-size: 28px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.quick-questions {
    margin-top: 32px;
}

.quick-title {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.question-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.question-chip {
    padding: 10px 20px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.question-chip:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

/* 消息气泡 */
.message {
    max-width: 800px;
    margin: 0 auto 24px;
    display: flex;
    gap: 16px;
    animation: fadeIn 0.3s ease-in;
}

/* 用户消息靠右 */
.message.user {
    flex-direction: row-reverse;
    text-align: right;
}

/* AI消息靠左 */
.message.ai {
    flex-direction: row;
    text-align: left;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background-color: var(--primary-color);
    color: white;
}

.message.ai .message-avatar {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.message-content {
    flex: 1;
    padding: 16px;
    border-radius: 12px;
    line-height: 1.8;
    max-width: 85%;
}

.message.user .message-content {
    background-color: #ffffff;
    color: var(--text-primary);
    border: none;
    border-bottom-right-radius: 4px;
    box-shadow: none;
}

.message.user .message-content .message-text {
    color: var(--text-primary);
}

.message.ai .message-content {
    background-color: var(--ai-message-bg);
    border: none;
    border-bottom-left-radius: 4px;
}

.message-text {
    color: inherit;
    word-wrap: break-word;
}

/* 思考过程中的文本样式 */
.thinking-text {
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.8;
}

.thinking-dots span {
    animation: thinkingDot 1.4s infinite;
    display: inline-block;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinkingDot {
    0%, 20% {
        opacity: 0;
        transform: translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-3px);
    }
    80%, 100% {
        opacity: 0;
        transform: translateY(0);
    }
}

.message.user .message-text {
    color: white;
}

.message.ai .message-text {
    color: var(--text-primary);
}

.message-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    opacity: 0.8;
}

.message.user .message-time {
    color: rgba(255, 255, 255, 0.8);
}

/* 加载动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* 输入区域 */
.input-area {
    padding: 20px 24px;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.input-container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    gap: 8px;
    align-items: center;
    background-color: var(--bg-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    padding: 5px 10px;
    transition: all 0.3s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    min-height: 38px;
}

.input-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(16, 163, 127, 0.15), 0 4px 16px rgba(16, 163, 127, 0.1);
    transform: translateY(-1px);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 80px;
    font-family: inherit;
    line-height: 1.4;
    padding: 3px 0;
    height: 20px;
}

#messageInput::placeholder {
    color: var(--text-secondary);
    font-size: 15px;
}

.send-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(16, 163, 127, 0.3);
}

.send-btn:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(16, 163, 127, 0.4);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.input-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 10px;
    opacity: 0.8;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 0;
    height: 0;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 响应式设计 - 平板和手机 */
@media (max-width: 768px) {
    .chat-container {
        height: 100dvh;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100dvh;
        max-height: 100dvh;
        transform: translateX(-100%);
        box-shadow: var(--shadow-medium);
        padding-bottom: env(safe-area-inset-bottom);
        box-sizing: border-box;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: flex;
    }

    .new-chat-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .chat-header {
        padding: 12px 16px;
    }

    .chat-title {
        font-size: 14px;
    }

    .messages-container {
        padding: 16px;
    }

    .welcome-message {
        margin: 30px auto;
        padding: 20px;
    }

    .welcome-icon {
        font-size: 48px;
    }

    .welcome-message h2 {
        font-size: 22px;
    }

    .question-chips {
        flex-direction: column;
    }

    .question-chip {
        width: 100%;
    }

    .input-area {
        padding: 16px;
    }

    .message {
        gap: 12px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .message-content {
        padding: 12px;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 480px) {
    .welcome-message h2 {
        font-size: 20px;
    }

    .welcome-message p {
        font-size: 14px;
    }

    .message-text {
        font-size: 14px;
    }

    #messageInput {
        font-size: 14px;
    }
}

/* 遮罩层（移动端菜单打开时） */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.overlay.show {
    display: block;
}
