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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background-color: #f0f2f5;
    overflow: hidden; /* 防止整个页面滚动，内容区域内部滚动 */
    height: 100vh;
}

:root {
    --qa-surface: #ffffff;
    --qa-surface-muted: #F5F7FA;
    --qa-text: #333333;
    --qa-muted: #64748B;
    --qa-border: #E5E7EB;
    --qa-primary: #D32F2F;
    --qa-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --qa-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.08);
    --qa-ring: 0 0 0 3px rgba(211, 47, 47, 0.15);
    --qa-separator: #E5E7EB;
    --qa-separator-soft: rgba(229, 231, 235, 0.5);
}

/* -------------------------------------------------------------------------- */
/*                                  登录页面样式                                  */
/* -------------------------------------------------------------------------- */

.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* 左深右浅的红色渐变 */
    background: linear-gradient(135deg, #c62828 0%, #ff8a80 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 40px;
    flex-direction: column;
}

.login-top-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #FF5252;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.login-layout {
    display: flex;
    width: 100%;
    max-width: 1200px;
    height: 600px;
    align-items: center;
    justify-content: center;
}

/* 左侧内容 */
.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start; /* 左对齐 */
    padding-right: 60px;
    padding-left: 60px;
    color: white;
}

.login-left-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-title-main {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 2px;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.login-title-sub {
    font-size: 36px;
    font-weight: 400;
    letter-spacing: 1px;
    margin-bottom: 40px;
    text-align: right; /* 对齐上面的标题 */
}

.login-decorative-icons {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    opacity: 0.8;
}

.login-decorative-icons i {
    font-size: 24px;
    border: 1px solid rgba(255,255,255,0.5);
    padding: 10px;
    border-radius: 8px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 右侧登录卡片 */
.login-right {
    flex: 1;
    display: flex;
    justify-content: flex-start; /* 靠左一些，贴近中间 */
    padding-left: 40px;
}

.login-card {
    background: white;
    width: 400px;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    gap: 30px;
    min-height: 480px;
    justify-content: center;
}

.login-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.login-header-title-red {
    font-size: 24px;
    color: #D32F2F;
    font-weight: 600;
    letter-spacing: 1px;
}

.login-header-title-black {
    font-size: 20px;
    color: #333;
    font-weight: 400;
    letter-spacing: 1px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    color: #999;
}

.login-input {
    width: 100%;
    padding: 8px 0;
    border: none;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    border-radius: 0;
}

.login-input:focus {
    border-bottom-color: #D32F2F;
}

.login-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: -5px;
}

.remember-me {
    font-size: 13px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.remember-me input {
    cursor: pointer;
}

.login-hint {
    font-size: 12px;
    color: #ccc;
    /* margin-top removed as it's now in flex container */
}

.login-btn {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper input {
    width: 100%;
    padding-right: 35px; /* Make space for the eye icon */
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #999;
    font-size: 14px;
    transition: color 0.2s;
    z-index: 10;
}

.toggle-password:hover {
    color: #D32F2F;
}

.login-btn {
    background: #FF5252;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 24px; /* 胶囊状 */
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 20px;
    letter-spacing: 4px;
    box-shadow: 0 4px 12px rgba(255, 82, 82, 0.3);
    text-align: center;
    text-indent: 4px; /* 补偿 letter-spacing 导致的右侧偏移 */
    display: block; /* 确保是 block 元素，虽然在 flex item 中默认会拉伸 */
    width: 100%;
}

.login-btn:hover {
    background: #D32F2F;
    transform: translateY(-1px);
}

.login-btn:active {
    transform: translateY(1px);
}

.login-footer {
    position: absolute;
    bottom: 20px;
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    text-align: center;
}

/* 响应式调整 */
@media (max-width: 900px) {
    .login-layout {
        flex-direction: column;
        height: auto;
    }
    
    .login-left {
        align-items: center;
        text-align: center;
        padding: 40px 20px;
        margin-bottom: 20px;
    }
    
    .login-title-sub {
        text-align: center;
    }
    
    .login-right {
        padding: 0;
        justify-content: center;
        width: 100%;
    }
    
    .login-card {
        width: 90%;
        max-width: 400px;
    }
}

/* -------------------------------------------------------------------------- */
/*                                  主应用布局                                  */
/* -------------------------------------------------------------------------- */

.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    background: white;
    overflow: hidden;
}

/* 侧边栏 */
.app-sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid var(--qa-separator);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.app-sidebar__header {
    padding: 20px;
    border-bottom: 1px solid var(--qa-separator-soft);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.app-logo i {
    color: var(--qa-primary);
    font-size: 24px;
}

.app-sidebar__actions {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-sidebar__btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.app-sidebar__btn:hover {
    background: #f5f5f5;
    border-color: #d0d0d0;
}

.app-sidebar__btn--primary {
    background: white;
    border-color: var(--qa-primary);
    color: var(--qa-primary);
}

.app-sidebar__btn--primary:hover {
    background: #FFEBEE;
}

.app-history {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0 10px;
}

.app-history__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 10px;
    color: #666;
    font-size: 12px;
    font-weight: 500;
}

.icon-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.icon-btn:hover {
    color: var(--qa-primary);
    background: rgba(0,0,0,0.05);
}

.qa-assistant__history-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* 复用原有的历史记录项样式，稍作调整 */
.qa-assistant__history-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: #495057;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.qa-assistant__history-item:hover {
    background: #e9ecef;
}

.qa-assistant__history-item--active {
    background: #e3f2fd;
    color: #1976d2;
}

.qa-assistant__history-item-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.qa-assistant__history-item-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.qa-assistant__history-item-btn {
    opacity: 0;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 2px;
    transition: opacity 0.2s;
}

.qa-assistant__history-item:hover .qa-assistant__history-item-btn {
    opacity: 1;
}

.qa-assistant__history-item-btn:hover {
    color: var(--qa-primary);
}

.app-sidebar__footer {
    padding: 16px;
    border-top: 1px solid var(--qa-separator);
    background: white;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: #f0f2f5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: #999;
}

.logout-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #f5f5f5;
    color: var(--qa-primary);
}


/* 主内容区 */
.app-main {
    flex: 1;
    background: white;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    position: relative;
}

/* 消息列表区域 */
.qa-assistant__messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 120px; /* 为底部输入框留出空间 */
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 首页状态 */
.qa-assistant__home {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 20px;
    transition: opacity 0.3s ease;
}

.qa-assistant__home--hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

.qa-assistant__home-welcome {
    text-align: center;
}

.qa-assistant__home-welcome-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.qa-assistant__home-welcome-subtitle {
    font-size: 16px;
    color: #666;
}

.qa-assistant__input-bar--home {
    width: 100%;
    max-width: 600px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    display: flex;
    align-items: flex-end;
    gap: 10px;
    transition: all 0.2s;
}

.qa-assistant__input-bar--home:focus-within {
    border-color: var(--qa-primary);
    box-shadow: 0 4px 16px rgba(211, 47, 47, 0.1);
}

.qa-assistant__home-suggestions {
    width: 100%;
    max-width: 600px;
}

.qa-assistant__preset-questions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
}

.qa-assistant__preset-item {
    background: transparent;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-align: left;
    width: 100%;
}

.qa-assistant__preset-item:hover {
    background: #f5f7fa;
    transform: translateX(4px);
}

/* 底部输入框容器 */
.qa-assistant__input-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
    z-index: 100;
    transition: all 0.3s ease;
}

/* 如果是首页状态，隐藏底部输入框 */
#homeState:not(.qa-assistant__home--hidden) ~ .qa-assistant__input-container {
    display: none;
}

.qa-assistant__input-wrapper {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.qa-assistant__input-area {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.qa-assistant__input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    max-height: 150px;
    background: transparent;
    padding: 8px 0;
}

.qa-assistant__attach-btn {
    padding: 8px;
    color: #666;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.qa-assistant__attach-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.qa-assistant__file-input {
    display: none;
}

.qa-assistant__send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--qa-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qa-assistant__send-btn:hover:not([disabled]) {
    background: #B71C1C;
}

.qa-assistant__send-btn[disabled] {
    background: #e0e0e0;
    cursor: not-allowed;
}

/* -------------------------------------------------------------------------- */
/*                                翻译助手面板                                  */
/* -------------------------------------------------------------------------- */
.qa-assistant__welcome-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.translate-panel {
    background: white;
    border: 1px solid #e0e7ff; /* soft lavender outline */
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.translate-header-text {
    font-size: 15px;
    color: #666;
    margin-bottom: 10px;
}

.translate-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* 翻译胶囊按钮 */
.translate-mode-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.2s;
}

.translate-mode-pill.active {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #4f46e5;
}

.translate-icon-shield {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 4px;
    color: white;
    font-size: 10px;
}

/* 语言选择器组 */
.lang-selector-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.lang-pill:hover {
    border-color: #bdbdbd;
}

.lang-pill i {
    font-size: 10px;
    color: #999;
}

.lang-swap-icon {
    color: #999;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
}

.lang-swap-icon:hover {
    color: #4f46e5;
}

/* 功能按钮 */
.feature-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: #f9fafb;
    border: 1px solid #f3f4f6;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: #4b5563;
    transition: all 0.2s;
}

.feature-pill:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

/* 发送按钮 */
.translate-send-btn {
    margin-left: auto; /* Push to right */
    width: 40px;
    height: 40px;
    background: #9ca3af;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.translate-send-btn:hover {
    background: #6b7280;
}

/* 响应式适配翻译面板 */
@media (max-width: 768px) {
    .translate-toolbar {
        gap: 8px;
    }
    
    .feature-pill span {
        display: none; /* 移动端只显示图标 */
    }
    
    .feature-pill {
        padding: 6px 10px;
    }
}


.qa-assistant__message {
    display: flex;
    gap: 12px;
    animation: messageIn 0.3s ease forwards;
}

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

.qa-assistant__message--user {
    flex-direction: row-reverse;
}

.qa-assistant__message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.qa-assistant__message--user .qa-assistant__message-avatar {
    background: linear-gradient(135deg, #FF5252 0%, #D32F2F 100%);
    color: white;
}

.qa-assistant__message--ai .qa-assistant__message-avatar {
    background: white;
    border: 1px solid #e0e0e0;
    color: var(--qa-primary);
}

.qa-assistant__message-content {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.qa-assistant__message-text {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 14px;
    word-break: break-word;
}

.qa-assistant__message--user .qa-assistant__message-text {
    background: linear-gradient(135deg, #FF5252 0%, #D32F2F 100%);
    color: white;
    border-top-right-radius: 2px;
}

.qa-assistant__message--ai .qa-assistant__message-text {
    background: white;
    border: 1px solid #e0e0e0;
    color: #333;
    border-top-left-radius: 2px;
}

.qa-assistant__message-source {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-left: 3px solid var(--qa-primary);
    font-size: 12px;
    color: #666;
    border-radius: 4px;
}

.qa-assistant__message-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.qa-assistant__message-content:hover .qa-assistant__message-actions {
    opacity: 1;
}

.qa-assistant__action-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 12px;
    padding: 4px;
    transition: all 0.2s;
}

.qa-assistant__action-btn:hover {
    color: var(--qa-primary);
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
}

.qa-assistant__message-time {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

/* 建议问题样式（在聊天流中） */
.qa-assistant__suggestion-questions {
    margin-left: 48px; /* 对齐AI消息内容 */
}

.qa-assistant__suggestion-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.qa-assistant__suggestion-item {
    background: white;
    border: 1px solid #e0e0e0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    width: fit-content;
    transition: all 0.2s;
}

.qa-assistant__suggestion-item:hover {
    border-color: var(--qa-primary);
    color: var(--qa-primary);
    background: #FFEBEE;
}

/* 加载动画 */
.qa-assistant__loading {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
    font-size: 13px;
}

.qa-assistant__loading-dot {
    width: 6px;
    height: 6px;
    background: var(--qa-primary);
    border-radius: 50%;
    animation: loading 1.4s infinite ease-in-out both;
}

.qa-assistant__loading-dot:nth-child(1) { animation-delay: -0.32s; }
.qa-assistant__loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes loading {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 翻译功能区 */
.qa-assistant__translation-features {
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.qa-assistant__language-switcher {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #666;
}

.qa-assistant__language-switch-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s;
}

.qa-assistant__language-switch-btn:hover {
    border-color: var(--qa-primary);
    color: var(--qa-primary);
}

/* 响应式适配 */
@media (max-width: 768px) {
    .app-sidebar {
        display: none; /* 移动端暂时隐藏侧边栏，后续可加汉堡菜单 */
    }
    
    .login-card {
        max-width: 90%;
        padding: 30px 20px;
    }

    .qa-assistant__input-container {
        width: 100%;
        bottom: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }
    
    .qa-assistant__messages {
        padding-bottom: 100px;
    }
}
