/*!
 * Responsive refinements for YiSha admin shell.
 * 增强版：与 mobile.css 配合实现 PC/H5 双端适配
 */
#page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#page-wrapper > .row {
    flex-shrink: 0;
}

#content-main {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow: auto;
    padding-bottom: 15px;
}

#content-main .YiSha_iframe {
    border: 0;
    width: 100%;
    min-height: 100%;
}

@media (max-width: 1200px) {
    #content-main .YiSha_iframe {
        min-height: calc(100vh - 150px);
    }
}

/* ---------- 平板及以下适配（768px - 1024px） ---------- */
@media (max-width: 1024px) {
    body {
        overflow-x: hidden;
    }

    .navbar-static-side {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -240px;
        width: 220px;
        z-index: 1050;
        transition: left 0.3s ease;
        overflow: visible;
        -webkit-overflow-scrolling: touch;
    }

    body:not(.mini-navbar) .navbar-static-side {
        left: 0;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
    }

    /* 平板端侧边栏内部容器允许子菜单溢出 */
    .navbar-static-side .sidebar-collapse,
    .navbar-static-side .slimScrollDiv,
    .navbar-static-side .nav {
        overflow: visible !important;
    }

    .navbar-static-side .slimScrollDiv {
        height: auto !important;
        position: static !important;
        overflow: visible !important;
    }

    .navbar-static-side #side-menu {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }

    .navbar-static-side .sidebar-collapse {
        height: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        position: relative !important;
    }

    /* 平板端子菜单也使用静态展开 */
    .navbar-static-side .nav-second-level,
    .navbar-static-side .nav-third-level {
        position: static !important;
        left: auto !important;
        top: auto !important;
        min-width: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    #page-wrapper {
        margin: 0 !important;
        padding: 0 10px 15px;
    }

    body.mini-navbar #page-wrapper {
        margin: 0 !important;
    }

    .nav-close {
        display: block;
    }

    .navbar-right {
        float: none !important;
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    .navbar-top-links li {
        display: inline-flex;
        align-items: center;
    }

    .navbar-top-links li a {
        min-height: 44px;
        padding: 0 10px;
        font-size: 13px;
        color: #fff;
    }

    .welcome-message {
        display: flex !important;
        flex-wrap: nowrap;
        justify-content: flex-end;
        align-items: center;
        gap: 4px;
    }

    .welcome-message > li {
        flex: 0 0 auto;
    }

    .content-tabs {
        margin-top: 5px;
    }

    .navbar-top-links.welcome-message {
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    .navbar-top-links.welcome-message .user-menu {
        margin-left: 0;
    }

    /* 用户头像菜单适配 */
    .user-menu .dropdown-toggle {
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
    }

    .user-menu .hidden-xs {
        display: inline !important;
        color: #fff !important;
        font-size: 13px !important;
    }

    .user-image {
        width: 30px !important;
        height: 30px !important;
        border-radius: 50% !important;
        border: 2px solid rgba(255, 255, 255, 0.5) !important;
    }

    .user-menu .dropdown-menu {
        right: 0 !important;
        left: auto !important;
        width: 160px !important;
        background: #fff !important;
        border-radius: 0 0 6px 6px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
        display: none !important;
    }

    /* 点击展开下拉菜单 */
    .user-menu.open .dropdown-menu {
        display: block !important;
    }

    .user-menu .dropdown-menu li a {
        color: #333 !important;
        padding: 10px 16px !important;
        font-size: 14px !important;
    }

    .user-menu .dropdown-menu li a:hover {
        background: #f5f5f5 !important;
    }
}

/* ---------- 手机端核心适配（<= 768px） ---------- */
@media (max-width: 768px) {
    /* 左侧导航栏：改为抽屉式，默认隐藏在左侧屏幕外 */
    body.login ~ * .navbar-static-side,
    .navbar-static-side {
        position: fixed !important;
        left: -260px !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 250px !important;
        z-index: 2002 !important;
        display: block !important;
        transition: left 0.3s ease;
        overflow: visible !important;
    }

    /* 抽屉打开状态 */
    .navbar-static-side.mobile-drawer-open {
        left: 0 !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }

    /* 顶部导航栏固定 */
    .navbar-static-top {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1040;
        background: #3c8dbc !important;
        min-height: 50px !important;
        display: flex !important;
        align-items: center !important;
        padding: 0 12px !important;
    }

    .navbar-minimalize {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #fff !important;
        font-size: 20px;
        padding: 0 12px !important;
        height: 50px !important;
        margin: 0 !important;
    }

    .navbar-minimalize:hover {
        color: rgba(255, 255, 255, 0.85) !important;
    }

    /* 页签栏在移动端隐藏（减少空间占用） */
    .content-tabs {
        display: none !important;
    }

    /* 主内容区域为全宽，顶部留出导航栏空间 */
    #page-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
        margin-top: 50px; /* navbar高度 */
    }

    /* 关闭按钮隐藏（使用汉堡菜单替代） */
    .nav-close {
        display: none !important;
    }

    /* 修复：768px以下 hidden-xs 元素统一隐藏（与Bootstrap 3一致） */
    .hidden-xs {
        display: none !important;
    }

    /* 侧边栏内部容器：允许下拉子菜单溢出显示 */
    .navbar-static-side .sidebar-collapse,
    .navbar-static-side .slimScrollDiv,
    .navbar-static-side .nav {
        overflow: visible !important;
    }

    /* 侧边栏滚动容器高度自适应 */
    .navbar-static-side .slimScrollDiv {
        height: auto !important;
        position: static !important;
        overflow: visible !important;
    }

    /* 确保 #side-menu 始终可见（slimScroll 可能设置 height:0） */
    .navbar-static-side #side-menu {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }

    .navbar-static-side .sidebar-collapse {
        height: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        position: relative !important;
    }

    /* 侧边栏下拉子菜单在移动端：使用静态定位展开，而非绝对定位浮出 */
    .navbar-static-side .nav-second-level,
    .navbar-static-side .nav-third-level {
        position: static !important;
        left: auto !important;
        top: auto !important;
        min-width: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    /* mini-navbar状态下移动端也显示文本标签 */
    body.mini-navbar .navbar-static-side .nav-label,
    body.mini-navbar .navbar-static-side .nav li a span {
        display: inline !important;
    }

    body.mini-navbar .navbar-static-side .profile-element {
        display: block !important;
    }

    body.mini-navbar .navbar-static-side {
        width: 250px !important;
    }

    /* 工具栏例外：需要显示操作按钮 */
    #toolbar.hidden-xs {
        display: flex !important;
    }
}

/* ---------- 小屏手机（<= 576px） ---------- */
@media (max-width: 576px) {
    #fullScreen {
        display: none !important;
    }

    .welcome-message {
        justify-content: flex-end;
        gap: 4px;
    }

    .welcome-message .user-menu {
        width: auto;
    }

    .welcome-message .user-menu .dropdown-toggle {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    #content-main .YiSha_iframe {
        min-height: calc(100vh - 110px);
    }

    .navbar-top-links li a {
        padding: 0 6px;
        font-size: 12px;
    }

    /* 用户头像更紧凑 */
    .user-image {
        width: 28px !important;
        height: 28px !important;
    }

    /* 用户名在小屏保留显示 */
    .user-menu .hidden-xs {
        display: inline !important;
        font-size: 12px !important;
    }

    /* 隐藏桌面端辅助元素（但保留用户名） */
    .hidden-xs:not(.user-menu .hidden-xs):not(#toolbar) {
        display: none !important;
    }
}
