/*
Template Name: 微信极简风
Thumbnail: 07.jpg
*/
:root {
    /* 微信经典色系 */
    --primary: #07c160;      
    --primary-dark: #06ad56; 
    --user-bubble: #95ec69;  
    --text-main: #191919;    
    --text-light: #b2b2b2;   
    --bg-base: #ededed;      
    --bg-panel: #ffffff;     
    --border-color: #e5e5e5; 
    --pc-bg: #d4d4d4;        /* PC端大背景色 */
    --app-height: 100dvh;
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

/* 核心修复：严禁把 html 设为 flex 容器 */
html {
    margin: 0; 
    padding: 0;
    height: var(--app-height);
    background-color: var(--pc-bg);
}

body {
    margin: 0; 
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text-main);
    overflow: hidden;
    background-color: var(--pc-bg);
    display: flex;             /* 仅在 body 使用 flex 让 app 居中 */
    justify-content: center;
    align-items: center;
}

/* 去除所有光效与浮动背景 */
body::before, html::before,
body::after, html::after {
    display: none;
}

#app {
    display: flex;
    height: 100%;
    width: 100%;
    position: relative;
    z-index: 1;
    background-color: var(--bg-base);
    overflow: hidden; /* 防止内部下拉菜单溢出破坏圆角 */
}

/* ================= 登录界面 ================= */
.login-overlay {
    position: fixed; 
    inset: 0; 
    z-index: 10000;
    background: #f5f5f5; 
    display: flex; 
    justify-content: center; 
    align-items: center;
}

.login-card {
    background: #ffffff;
    padding: 40px 35px;
    border-radius: 4px; 
    width: 90%; 
    max-width: 320px; 
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    animation: fadeIn 0.3s ease forwards;
    position: relative;
}

.login-card::before { 
    display: none; 
}

.login-card h2 {
    margin: 0 0 10px 0; 
    color: var(--text-main); 
    font-weight: 500; 
    font-size: 1.3rem;
}

.login-card p {
    color: var(--text-light); 
    font-size: 0.9rem; 
    margin-bottom: 30px;
}

.login-card input {
    width: 100%; 
    padding: 10px 0; 
    background: transparent; 
    border: none;
    border-bottom: 1px solid var(--border-color); 
    border-radius: 0;
    color: var(--text-main); 
    outline: none; 
    transition: 0.2s ease;
    font-size: 1rem; 
    text-align: center; 
    margin-bottom: 24px;
}

.login-card input:focus { 
    border-bottom-color: var(--primary); 
}

.login-card button {
    width: 100%; 
    padding: 12px; 
    border-radius: 4px; 
    border: none;
    background: var(--primary); 
    color: #ffffff; 
    font-weight: 500;
    font-size: 1rem; 
    cursor: pointer; 
    transition: 0.2s ease;
}

.login-card button:hover { 
    background: var(--primary-dark); 
}

.login-error { 
    color: #fa5151; 
    font-size: 0.85rem; 
    margin-bottom: 15px; 
}

/* ================= 侧边栏 (顶部下拉) ================= */
#sidebar {
    position: absolute; 
    top: 0; 
    left: 0; 
    right: 0; 
    z-index: 50;
    width: 100%;
    height: auto;
    max-height: 65vh; /* 防止按钮过多占满全屏，保留下方点击关闭区域 */
    background: #f7f7f7; 
    border-bottom: 1px solid var(--border-color);
    display: flex; 
    flex-direction: column;
    transform: translateY(-100%); /* 从正上方隐藏 */
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: none;
    overflow-y: auto;
}

#sidebar::before { 
    display: none; 
}

#sidebar.open {
    transform: translateY(0); /* 向下滑出 */
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.sidebar-header { 
    padding: 20px 16px; 
    flex-shrink: 0; 
}

.sidebar-btn[style] {
    width: 100%; 
    padding: 12px 14px; 
    margin-bottom: 4px; 
    border-radius: 4px;
    background: transparent !important; 
    border: none !important;
    color: var(--text-main) !important; 
    font-size: 0.95rem;
    display: flex; 
    align-items: center; 
    justify-content: flex-start; 
    gap: 10px;
    cursor: pointer; 
    text-decoration: none; 
    transition: background 0.2s ease;
}

.sidebar-btn[style]:hover { 
    background: #e5e5e5 !important; 
}

.sidebar-btn[style*="fef2f2"] { 
    color: #fa5151 !important; 
}

.sidebar-btn[style*="fef2f2"]:hover { 
    background: #e2e2e2 !important; 
}

.super-card {
    background: transparent !important; 
    border: none; 
    padding: 16px;
    border-radius: 0; 
    color: var(--text-main); 
    text-align: left; 
    box-shadow: none;
}

.super-card::before { 
    display: none; 
}

.super-card h3 {
    color: var(--text-light); 
    margin: 0 0 6px 0; 
    font-size: 0.85rem; 
    font-weight: normal;
}

.sidebar-footer { 
    margin-top: auto; 
    padding: 16px; 
    border-top: 1px solid var(--border-color); 
}

/* ================= 主聊天区 ================= */
#main {
    position: absolute; 
    inset: 0;
    display: flex; 
    flex-direction: column; 
    align-items: center;
    background: var(--bg-base); 
    z-index: 10;
    width: 100%; 
    left: 0; /* 强行铺满，不留侧边栏空间 */
}

#chat-history {
    width: 100%; 
    max-width: 800px; 
    padding: 20px 20px 100px;
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 20px; 
    scroll-behavior: smooth; 
    position: relative;
}

#chat-history::before { 
    display: none; 
}

#chat-history::-webkit-scrollbar { 
    width: 6px; 
}

#chat-history::-webkit-scrollbar-thumb { 
    background: #c3c3c3; 
    border-radius: 6px; 
}

#chat-history::-webkit-scrollbar-track { 
    background: transparent; 
}

.ai-avatar-sidebar {
    width: 56px; 
    height: 56px; 
    border-radius: 6px; 
    margin: 0 auto 12px; 
    display: block; 
    object-fit: cover; 
    background: #fff;
}

.ai-avatar-chat {
    width: 40px; 
    height: 40px; 
    border-radius: 6px; 
    margin-right: 12px; 
    align-self: flex-start; 
    object-fit: cover; 
    flex-shrink: 0; 
    background: #fff;
}

.msg-row { 
    display: flex; 
    width: 100%; 
    animation: fadeIn 0.2s ease forwards; 
}

.msg-row.user { 
    justify-content: flex-end; 
}

.msg-row.ai { 
    justify-content: flex-start; 
}

.msg-wrap { 
    display: flex; 
    flex-direction: column; 
    max-width: 70%; 
    min-width: 0; 
}

.bubble {
    width: fit-content; 
    max-width: 100%; 
    padding: 10px 14px; 
    font-size: 1rem; 
    line-height: 1.6; 
    word-wrap: break-word; 
    position: relative;
}

.msg-row.user .bubble { 
    background: var(--user-bubble); 
    color: var(--text-main); 
    border-radius: 8px; 
}

.msg-row.ai .bubble { 
    background: #ffffff; 
    color: var(--text-main); 
    border-radius: 8px; 
}

.msg-row.ai .bubble::before, 
.msg-row.user .bubble::before { 
    display: none; 
}

.bubble pre { 
    background: #f7f7f7; 
    color: var(--text-main); 
    padding: 10px; 
    border-radius: 4px; 
    margin: 6px 0; 
    border: 1px solid #e5e5e5; 
    overflow-x: auto; 
    font-size: 0.9rem; 
}

.bubble code { 
    font-family: Consolas, monospace; 
    background: rgba(0,0,0,0.05); 
    padding: 2px 4px; 
    border-radius: 4px; 
    color: #fa5151; 
}

.msg-row.user .bubble code { 
    background: rgba(255,255,255,0.4); 
    color: #d13030; 
}

.bubble p { 
    margin: 0 0 6px 0; 
}

.bubble p:last-child { 
    margin: 0; 
}

.bubble img { 
    max-width: min(100%, 240px); 
    max-height: 300px; 
    object-fit: contain; 
    border-radius: 4px; 
    margin-top: 6px; 
}

.msg-status { 
    font-size: 0.75rem; 
    margin-top: 4px; 
    color: var(--text-light); 
    padding: 0 2px; 
}

.msg-row.user .msg-status { 
    text-align: right; 
}

.msg-actions { 
    display: flex; 
    gap: 12px; 
    margin-top: 4px; 
    padding: 0 2px; 
    font-size: 0.8rem; 
    opacity: 0; 
    transition: 0.2s; 
}

.msg-row:hover .msg-actions { 
    opacity: 1; 
}

.action-btn { 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 4px; 
    color: var(--text-light); 
}

.action-btn:hover { 
    color: var(--primary); 
}

/* ================= 底部输入区域 ================= */
.input-trigger-bar {
    position: absolute; 
    bottom: 0; 
    left: 0; 
    width: 100%;
    padding: 10px 20px 20px 20px; 
    background: #f5f5f5; 
    border-top: 1px solid var(--border-color);
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 10px; 
    z-index: 100;
}

.input-trigger-bar::before { 
    display: none; 
}

.bottom-icon-btn {
    background: transparent; 
    border: none; 
    width: 36px; 
    height: 36px; 
    border-radius: 4px;
    color: #666; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    transition: 0.2s;
}

.bottom-icon-btn::before { 
    display: none; 
}

.bottom-icon-btn:hover { 
    color: var(--text-main); 
    background: #e2e2e2; 
}

.fake-input-btn {
    flex: 1; 
    background: #ffffff; 
    border: none; 
    border-radius: 4px; 
    padding: 10px 14px;
    color: var(--text-light); 
    font-size: 1rem; 
    cursor: text; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}

/* ================= 遮罩与弹窗 ================= */
#overlay {
    position: absolute; 
    inset: 0; 
    background: rgba(0, 0, 0, 0.4); 
    z-index: 40; 
    display: none;
}

#overlay.show { 
    display: block; 
    animation: fadeIn 0.2s; 
}

.modal-wrap {
    position: fixed; 
    inset: 0; 
    background: rgba(0, 0, 0, 0.5); 
    z-index: 1000;
    display: none; 
    align-items: center; 
    justify-content: center;
}

.modal-card {
    background: #ffffff; 
    border: none; 
    width: 90%; 
    max-width: 400px; 
    padding: 24px; 
    border-radius: 8px; 
    display: flex; 
    flex-direction: column; 
    gap: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1); 
    animation: fadeIn 0.2s ease; 
    position: relative;
}

.modal-card::before { 
    display: none; 
}

#modalInput {
    width: 100%; 
    background: #f7f7f7; 
    border: none; 
    border-radius: 4px; 
    padding: 12px;
    font-size: 1rem; 
    line-height: 1.5; 
    color: var(--text-main); 
    min-height: 120px; 
    outline: none; 
    resize: none;
}

#modalInput:focus { 
    background: #ffffff; 
    border: 1px solid var(--primary); 
}

#realSendBtn[style], 
.modal-card button[onclick="closeInputPanel()"][style] {
    border-radius: 4px !important; 
    padding: 10px 24px !important; 
    font-size: 1rem !important; 
    transition: 0.2s ease !important;
}

.modal-card button[onclick="closeInputPanel()"][style] { 
    background: #f2f2f2 !important; 
    color: var(--text-main) !important; 
    border: none !important; 
}

.modal-card button[onclick="closeInputPanel()"][style]:hover { 
    background: #e5e5e5 !important; 
}

#realSendBtn[style] { 
    background: var(--primary) !important; 
    color: #ffffff !important; 
    border: none !important; 
}

#realSendBtn[style]:hover { 
    background: var(--primary-dark) !important; 
}

#uploadImgBtn[style] { 
    background: transparent !important; 
    color: var(--text-light) !important; 
    transition: 0.2s !important; 
}

#uploadImgBtn[style]:hover { 
    background: #f5f5f5 !important; 
    color: var(--text-main) !important; 
    border-radius: 4px; 
}

.toast {
    position: fixed; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    background: rgba(17, 17, 17, 0.8); 
    color: #ffffff; 
    padding: 12px 24px; 
    border-radius: 4px;
    font-size: 0.95rem; 
    opacity: 0; 
    pointer-events: none; 
    transition: 0.2s ease; 
    z-index: 2000;
}

.toast.show { 
    opacity: 1; 
}

.cursor-blink {
    display: inline-block; 
    width: 2px; 
    height: 16px; 
    background: var(--primary);
    animation: blink 1s infinite; 
    vertical-align: middle; 
    margin-left: 2px;
}

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

@keyframes blink { 
    0%, 100% { opacity: 1; } 
    50% { opacity: 0; } 
}

/* ================= 响应式调整：PC端居中弹窗逻辑 ================= */
@media (min-width: 768px) {
    #app {
        max-width: 800px;       /* 限制最大宽度 */
        height: 85vh;           /* 不再占满全屏高度 */
        border-radius: 8px;     /* PC端呈现独立视窗圆角 */
        box-shadow: 0 10px 40px rgba(0,0,0,0.15); /* 窗口投影立体感 */
    }
    
    /* 解决PC端弹窗定位问题，限制在 #app 内部 */
    .login-overlay, .modal-wrap {
        position: absolute; 
    }
}

@media (max-width: 767px) {
    .input-trigger-bar { 
        padding: 8px 12px 12px 12px; 
    }
    .login-card { 
        padding: 30px 20px; 
        border: none; 
        box-shadow: none; 
        width: 100%; 
    }
}