/* 化则智核 · 布局 */

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 顶栏 */
#topbar {
    background: #1f1f22;
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-main);
    flex-shrink: 0;
    height: 52px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-left .brand {
    color: var(--accent);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
}

.topbar-left .brand-sub {
    color: #8899aa;
    font-size: 11px;
    letter-spacing: 2px;
}

.topbar-center {
    color: #8899aa;
    font-size: 12px;
}

.topbar-right .status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #8899aa;
    font-size: 12px;
}

.topbar-right .status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    display: inline-block;
}

.topbar-right .status.online .dot {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.topbar-right .status.offline .dot {
    background: var(--error);
}

/* 容器 */
.container {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* 侧栏 */
#sidebar {
    width: 200px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-main);
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.nav-item {
    padding: 11px 24px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.15s;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item:hover {
    background: var(--bg-panel-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-panel-hover);
    color: var(--accent);
    border-left-color: var(--accent);
}

.nav-item .nav-icon {
    font-size: 14px;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.nav-item .nav-label {
    flex: 1;
    min-width: 0;
}

#sidebar .spacer { flex: 1; }

#sidebar .footer {
    padding: 12px 24px;
    font-size: 11px;
    color: var(--text-weak);
    line-height: 1.8;
}

/* 侧栏分组 */
.nav-divider {
    height: 1px;
    background: var(--border-main);
    margin: 12px 24px;
}

.nav-group-title {
    padding: 8px 24px 4px;
    font-size: 10px;
    color: var(--text-weak);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-external {
    display: block;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 13px;
}

/* 主区 */
#main {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-main);
    min-width: 0;
}

/* 主区内的通用 padding */
.page {
    padding: 24px 32px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 2px;
}

/* ========== 移动端基础（V1.0.4） ========== */
@media (max-width: 768px) {
    #sidebar { width: 60px; }
    .nav-item {
        padding: 12px 0;
        text-align: center;
        font-size: 20px;
        justify-content: center;
        gap: 0;
    }
    .nav-item .nav-label { display: none; }
    .nav-item .nav-icon { display: inline; width: auto; }
    .nav-group-title { display: none; }
    .page { padding: 16px; }
}

/* ========== 移动端两屏切换（V1.0.5 · 2.9 最终版） ========== */
@media (max-width: 768px) {
    /* ---- 第一屏（主界面）：侧栏 + 会话列表 ---- */
    /* 详情区隐藏 */
    body.mobile-list-view .chat-main {
        display: none;
    }
    /* 会话列表占满剩余空间（侧栏仍占 60px） */
    body.mobile-list-view .conv-sidebar {
        flex: 1;
        width: auto;
        max-width: none;
        min-width: 0;
    }
    /* 侧栏保持 60px（由上面"移动端基础"段的 #sidebar 规则决定） */

    /* ---- 第二屏（详情）：全屏 ---- */
    /* 详情区显示，铺满 */
    body.mobile-show-detail .chat-main {
        display: flex;
        flex: 1;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    /* 隐藏"会话列表"和"侧栏" */
    body.mobile-show-detail .conv-sidebar {
        display: none;
    }
    body.mobile-show-detail #sidebar {
        display: none;
    }

    /* ---- 返回按钮 ---- */
    .chat-back-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border-radius: 6px;
        background: var(--bg-panel-hover, #26262a);
        color: var(--text-primary, #c8c8cc);
        border: 1px solid var(--border-main, #2c2c30);
        font-size: 16px;
        cursor: pointer;
        flex-shrink: 0;
        margin-right: 8px;
    }
    .chat-back-btn:hover {
        background: var(--border-hover, #3c3c42);
    }

    /* ---- 聊天标题省略 ---- */
    .chat-header {
        display: flex;
        align-items: center;
    }
    .chat-header h2 {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* ---- 消息区 / 输入区 移动端 padding ---- */
    .chat-layout .messages {
        padding: 16px;
    }
    .chat-layout .chat-input {
        padding: 12px 16px;
    }
    .chat-header {
        padding: 10px 16px;
    }
}

/* 桌面端：隐藏返回按钮 */
@media (min-width: 769px) {
    .chat-back-btn {
        display: none;
    }
}