/* ===== 主界面 ===== */
.main-container {
    display: none;
    flex-direction: column;
    height: 100vh;
    background: #ffffff;
    max-width: 100%;
    margin: 0 auto;
}

.main-container.show {
    display: flex;
}

/* ===== 顶栏 - 和宏观页面完全一致 ===== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    height: 56px;
    flex-shrink: 0;
    width: 100%;
    z-index: 10;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.top-bar-left .brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-bar-left .brand .logo {
    font-size: 20px;
}

.top-bar-left .brand .title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
}

.top-bar-left .brand .status {
    font-size: 11px;
    color: #52c41a;
    padding: 2px 10px;
    background: rgba(82, 196, 26, 0.1);
    border-radius: 12px;
}

/* ===== 导航按钮 - 和宏观一致 ===== */
.top-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 20px;
}

.top-nav .nav-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    height: 34px;
}

.top-nav .nav-btn:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.top-nav .nav-btn.active {
    background: #eff6ff;
    color: #3b82f6;
}

/* ===== 右侧用户操作区 - 和宏观一致 ===== */
.user-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.user-actions .history-btn-top {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-actions .history-btn-top:hover {
    background: #f3f4f6;
}

.user-actions #userDisplay {
    font-size: 14px;
    color: #1f2937;
    font-weight: 500;
    white-space: nowrap;
}

.user-actions .setting-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-actions .setting-btn:hover {
    background: #f3f4f6;
}

.user-actions .logout-btn {
    padding: 6px 14px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #4b5563;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    height: 34px;
}

.user-actions .logout-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ===== 聊天区域 ===== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 24px;
    min-height: 0;
    background: #ffffff;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

/* ===== 聊天头部 ===== */
.chat-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 10px 0;
    gap: 8px;
    flex-shrink: 0;
}

.agent-selector {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f8f9fa;
    padding: 3px 8px 3px 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.agent-selector label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
}

.agent-selector select {
    background: transparent;
    border: none;
    padding: 3px 0;
    font-size: 12px;
    color: #1f2937;
    cursor: pointer;
    outline: none;
    min-width: 80px;
    max-width: 120px;
}

.chat-header-actions {
    display: flex;
    gap: 4px;
}

.chat-header-actions button {
    padding: 4px 8px;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-header-actions .history-btn:hover {
    background: #dbeafe;
    border-color: #3b82f6;
}

.chat-header-actions .clear-btn:hover {
    background: #fee2e2;
    border-color: #ef4444;
}

/* ===== 消息区域 ===== */
.messages {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    background: #ffffff;
}

/* ===== 消息样式 ===== */
.message {
    padding: 14px 22px;
    border-radius: 10px;
    max-width: 92%;
    width: auto;
    word-break: break-word;
}

.message.system {
    background: transparent;
    box-shadow: none;
    text-align: center;
    max-width: 100%;
    padding: 4px 0;
}

.message.user {
    background: #e8f0fe;
    align-self: flex-end;
    max-width: 80%;
    border-radius: 12px 12px 4px 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.message.agent {
    background: transparent;
    align-self: flex-start;
    max-width: 92%;
    border-radius: 12px;
    box-shadow: none;
    padding: 14px 0;
}

.message .msg-content {
    font-size: 14px;
    line-height: 1.8;
    color: #1f2937;
    word-break: break-word;
}

/* ===== Markdown 内容样式 ===== */
.message .msg-content h1,
.message .msg-content h2,
.message .msg-content h3,
.message .msg-content h4 {
    margin: 12px 0 6px 0;
    color: #0f172a;
}

.message .msg-content h1 { font-size: 20px; }
.message .msg-content h2 { font-size: 17px; }
.message .msg-content h3 { font-size: 15px; }

.message .msg-content p {
    margin: 4px 0;
}

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

.message .msg-content li {
    margin: 2px 0;
}

.message .msg-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 10px 14px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
    margin: 6px 0;
}

.message .msg-content code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.message .msg-content pre code {
    background: transparent;
    padding: 0;
    color: #e2e8f0;
}

.message .msg-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 6px 0;
    font-size: 13px;
}

.message .msg-content th,
.message .msg-content td {
    border: 1px solid #e5e7eb;
    padding: 4px 8px;
    text-align: left;
}

.message .msg-content th {
    background: #f1f5f9;
    font-weight: 600;
}

/* ===== 输入区域 - 发送按钮在框内 ===== */
.input-area {
    padding: 12px 0;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    background: #ffffff;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0;
    background: #f5f7fa;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    transition: border-color 0.2s;
    padding: 3px;
}

.input-wrapper:focus-within {
    border-color: #3b82f6;
    background: #ffffff;
}

.input-wrapper textarea {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    background: transparent;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.5;
    outline: none;
}

.input-wrapper textarea::placeholder {
    color: #9ca3af;
    font-size: 13px;
}

.input-wrapper button {
    padding: 0 20px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    min-height: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px;
}

.input-wrapper button:hover {
    background: #2563eb;
}

.input-wrapper button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* ===== 滚动条 ===== */
.messages::-webkit-scrollbar {
    width: 4px;
}

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

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

.messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .top-bar {
        padding: 0 16px;
        height: 50px;
    }
    
    .top-bar-left .brand .title {
        font-size: 14px;
    }
    
    .top-nav .nav-btn {
        padding: 4px 10px;
        font-size: 13px;
        height: 30px;
    }
    
    .chat-area {
        padding: 0 16px;
        max-width: 100%;
    }
    
    .message {
        max-width: 95%;
        padding: 12px 16px;
    }
    
    .message.agent {
        max-width: 95%;
        padding: 12px 0;
    }
    
    .message.user {
        max-width: 88%;
    }
}

@media (max-width: 480px) {
    .top-bar {
        padding: 0 12px;
        height: 46px;
        flex-wrap: wrap;
    }
    
    .top-bar-left .brand .title {
        font-size: 13px;
    }
    
    .top-bar-left .brand .status {
        font-size: 9px;
        padding: 1px 6px;
    }
    
    .top-nav {
        margin-left: 8px;
        gap: 2px;
    }
    
    .top-nav .nav-btn {
        padding: 3px 8px;
        font-size: 12px;
        height: 26px;
    }
    
    .user-actions {
        gap: 6px;
    }
    
    .user-actions #userDisplay {
        font-size: 12px;
    }
    
    .user-actions .logout-btn {
        padding: 4px 10px;
        font-size: 12px;
        height: 28px;
    }
    
    .user-actions .setting-btn {
        font-size: 14px;
        height: 28px;
        padding: 2px 6px;
    }
    
    .user-actions .history-btn-top {
        font-size: 15px;
        height: 28px;
        padding: 2px 6px;
    }
    
    .chat-area {
        padding: 0 12px;
    }
    
    .message {
        max-width: 98%;
        padding: 10px 14px;
    }
    
    .message.user {
        max-width: 92%;
    }
    
    .message.agent {
        max-width: 98%;
        padding: 10px 0;
    }
    
    .message .msg-content {
        font-size: 13px;
    }
    
    .chat-header {
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-end;
    }
    
    .agent-selector select {
        min-width: 60px;
        font-size: 11px;
        max-width: 90px;
    }
    
    .input-wrapper textarea {
        font-size: 13px;
        padding: 8px 12px;
        min-height: 38px;
    }
    
    .input-wrapper button {
        padding: 0 14px;
        font-size: 13px;
        min-height: 34px;
        height: 34px;
    }
}


/* ===== 修改密码独立页面 ===== */
.change-password-page {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 1000;
    flex-direction: column;
    height: 100vh;
}

.change-password-page.show {
    display: flex;
}

/* 修改密码页面顶栏 */
.change-password-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    width: 100%;
    height: 56px;
}

.change-password-top-bar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
}

.change-password-top-bar .brand .logo {
    font-size: 20px;
}

.change-password-top-bar .brand .status {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 12px;
    background: rgba(82, 196, 26, 0.1);
    color: #52c41a;
}

.change-password-top-bar .user-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.change-password-top-bar .user-actions span {
    font-size: 14px;
    color: #1f2937;
    font-weight: 500;
}

.change-password-top-bar .user-actions button {
    padding: 6px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f3f4f6;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #4b5563;
    transition: all 0.2s;
    height: 34px;
}

.change-password-top-bar .user-actions button:hover {
    background: #e2e8f0;
}

/* 修改密码内容 */
.change-password-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.change-password-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    border: 1px solid #e5e7eb;
}

.change-password-header {
    text-align: center;
    margin-bottom: 28px;
}

.change-password-header .lock-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 8px;
}

.change-password-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
}

.change-password-header p {
    color: #6b7280;
    font-size: 14px;
    margin-top: 4px;
}

.change-password-body .input-group {
    margin-bottom: 16px;
}

.change-password-body .input-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.change-password-body .input-group input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.2s;
    background: #f9fafb;
}

.change-password-body .input-group input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #fff;
}

.change-password-body .submit-btn {
    width: 100%;
    padding: 14px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 4px;
}

.change-password-body .submit-btn:hover {
    background: #2563eb;
}

.change-password-body .error-msg {
    text-align: center;
    font-size: 14px;
    margin-top: 12px;
    min-height: 24px;
    color: #ef4444;
}

/* ===== 新登录样式（箭头在框内） ===== */

/* 登录输入框容器 */
.input-with-btn {
    display: flex;
    align-items: center;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #ffffff;
    overflow: hidden;
}

.input-with-btn:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-with-btn input {
    flex: 1;
    padding: 14px 16px;
    border: none;
    border-radius: 12px 0 0 12px;
    font-size: 15px;
    background: transparent;
    outline: none;
    min-height: 52px;
}

.input-with-btn input::placeholder {
    color: #9ca3af;
}

.input-with-btn input:focus {
    outline: none;
}

/* 箭头按钮 */
.next-btn {
    padding: 0 16px;
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    color: #9ca3af;
    border-radius: 0 12px 12px 0;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.next-btn:hover {
    color: #3b82f6;
    transform: translateX(2px);
}

.next-btn.active {
    color: #3b82f6;
}

/* 验证码按钮 */
.code-btn {
    padding: 0 16px;
    background: transparent;
    border: none;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
    color: #3b82f6;
    white-space: nowrap;
    transition: all 0.2s;
    border-radius: 0 12px 12px 0;
    min-height: 52px;
}

.code-btn:hover:not(:disabled) {
    color: #2563eb;
}

.code-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 状态提示 */
.status-msg {
    text-align: center;
    font-size: 14px;
    margin-top: 14px;
    min-height: 24px;
    color: #6b7280;
}

.status-msg.success {
    color: #16a34a;
}

.status-msg.error {
    color: #ef4444;
}

.status-msg.info {
    color: #3b82f6;
}

/* 动态区域动画 */
#dynamicArea {
    margin-top: 12px;
    animation: fadeIn 0.3s ease;
}

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

/* 密码输入框在动态区域内与主输入框保持一致 */
#dynamicArea .input-with-btn {
    margin-top: 4px;
}

#dynamicArea .submit-btn {
    width: 100%;
    padding: 12px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 12px;
}

#dynamicArea .submit-btn:hover {
    background: #2563eb;
}

/* ===== 页面左上角 Logo ===== */
.page-logo {
    position: fixed;
    top: 20px;
    left: 24px;
    z-index: 1000;
    background: transparent;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
}

.page-logo-img {
    height: 72px;
    width: auto;
    display: block;
}

.page-logo-text {
    font-size: 16px;
    font-weight: 700;
    color: #3b82f6;
    letter-spacing: 0.3px;
}