/* =====================================================
   1. 全局布局变量
===================================================== */

:root {
    --sidebar-width: 0px;
    --header-height: 65px;
    --sidebar-bg: var(--tblr-bg-surface);
}


/* =====================================================
   2. 基础设置
===================================================== */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    width: 100%;
}

body {
    overflow-x: hidden;
}


/* =====================================================
   3. 手机端布局
===================================================== */

/* 安全区域 */
.safe-top {
    height: env(safe-area-inset-top, 0px);
    background: var(--tblr-bg-surface);
}

/* 整体 */
.app-layout {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
}

/* 手机隐藏侧边栏 */
.side-nav {
    display: none;
}

/* 右侧主区域 */
.main-area {
    width: 100%;
    min-width: 0;
}

/* 顶部栏 */
.mobile-header {
    position: sticky;
    top: 0;
    z-index: 1050;

    width: 100%;
    min-height: var(--header-height);

    background: rgba(255,255,255,.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    border-bottom: 1px solid var(--tblr-border-color);
}

[data-bs-theme="dark"] .mobile-header {
    background: rgba(24,36,51,.9);
}

/* 页面主体 */
.page-wrapper {
    width: 100%;
    min-width: 0;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* 手机底部导航 */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;

    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);

    box-sizing: border-box;

    display: flex;
    align-items: center;

    background: rgba(255,255,255,.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    border-top: 1px solid var(--tblr-border-color);

    z-index: 1030;
}

[data-bs-theme="dark"] .bottom-nav {
    background: rgba(24,36,51,.92);
}

.bottom-nav .nav-item {
    flex: 1;
    min-width: 0;
    height: 60px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    text-decoration: none;
    color: var(--tblr-secondary);

    font-size: 12px;
}

.bottom-nav .nav-item.active {
    color: var(--tblr-primary);
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-nav .nav-icon {
    margin-bottom: 2px;
}

.nav-title {
    white-space: nowrap;
}


/* =====================================================
   4. 平板及以上：左侧导航 + 右侧工作区
===================================================== */

@media (min-width: 768px) {

    :root {
        --sidebar-width: 76px;
    }

    body {
        padding-bottom: 0;
    }

    .safe-top {
        display: none;
    }

    /* 整体左右布局 */
    .app-layout {
        display: flex;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
    }

    /* 隐藏手机底部导航 */
    .bottom-nav {
        display: none;
    }

    /* 左侧固定导航 */
    .side-nav {
        display: flex;
        flex-direction: column;

        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;

        width: var(--sidebar-width);
        height: 100vh;
        height: 100dvh;

        overflow-y: auto;
        overflow-x: hidden;

        background: var(--sidebar-bg);
        border-right: 1px solid var(--tblr-border-color);

        z-index: 1060;
    }

    /* 侧边栏 LOGO */
    .side-brand {
        height: 80px;
        min-height: 80px;

        display: flex;
        align-items: center;
        justify-content: center;

        flex-shrink: 0;
    }

    .side-brand .avatar {
        flex-shrink: 0;
    }

    /* 侧边栏菜单 */
    .side-menu {
        display: flex;
        flex-direction: column;
        align-items: stretch;

        width: 100%;
        gap: 5px;

        padding: 8px;
    }

    .side-menu .nav-item {
        width: 100%;
        min-height: 76px;
        padding: 8px 2px;

        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        gap: 5px;

        color: var(--tblr-secondary);
        text-decoration: none;

        font-size: 12px;
        border-radius: 12px;

        transition: background .15s ease, color .15s ease;
    }

    .side-menu .nav-item.active {
        color: var(--tblr-primary);
        background: var(--tblr-bg-surface-secondary);
    }

    .side-menu .nav-icon svg {
        width: 24px;
        height: 24px;
    }

    .side-menu .nav-title {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* 平板、电脑隐藏顶部 Header
    .mobile-header {
        display: none !important;
    } */

    /* 右侧工作区 */
    .main-area {
        width: calc(100% - var(--sidebar-width));
        min-width: 0;
        margin-left: var(--sidebar-width);
    }

    /* Header 属于右侧工作区 */
    .mobile-header {
        width: 100%;
    }

    /* 页面内容 */
    .page-wrapper {
        width: 100%;
        min-width: 0;
        padding-bottom: 20px;
    }

}


/* =====================================================
   5. 电脑：加宽侧边栏
===================================================== */

@media (min-width: 1200px) {

    :root {
        --sidebar-width: 140px;
    }

    .side-brand {
        height: 90px;
        min-height: 90px;
    }

    .side-menu {
        padding: 10px;
        gap: 5px;
    }

    .side-menu .nav-item {
        min-height: 85px;
        padding: 10px 5px;
    }

    .side-menu .nav-icon svg {
        width: 26px;
        height: 26px;
    }

}


/* =====================================================
   6. 超小屏幕处理
===================================================== */

@media (max-width: 360px) {

    .bottom-nav .nav-item {
        font-size: 11px;
    }

    .bottom-nav .nav-icon svg {
        width: 21px;
        height: 21px;
    }

}