/**
 * 公共布局样式
 */

:root {
    --sidebar-width: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f5f7fa;
    overflow-x: hidden;
    /* 确保 body 不会挡住 fixed 元素 */
}

/* 顶部导航栏 */
.top-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: 60px;
    background: #fff;
    border-bottom: 1px solid #e4e7ed;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    transition: left 0.3s;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-toggle {
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #e4e7ed;
}

.menu-toggle:hover {
    background: #f5f7fa;
}

.menu-toggle svg {
    color: #606266;
}

#breadcrumbText {
    font-size: 15px;
    color: #303133;
    font-weight: 500;
}

.fullscreen-btn {
    cursor: pointer;
    padding: 8px;
    color: #606266;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background 0.3s;
}

.user-info:hover {
    background: #f5f7fa;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e4e7ed;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #606266;
}

.user-name {
    font-size: 14px;
    color: #303133;
}

/* 左侧导航栏（与首页一致：固定字号与字体，不受各业务页 body 样式影响） */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid #e4e7ed;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
    box-shadow: 2px 0 8px rgba(0,0,0,0.06);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

/* 侧边栏Logo区域 */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid #e4e7ed;
    background: #fff;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ecf5ff;
    border-radius: 8px;
    overflow: hidden;
    padding: 4px;
}

.sidebar-logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.sidebar-logo-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.sidebar-logo-text {
    font-size: 20px;
    font-weight: bold;
    color: #1f2937;
    line-height: 1.2;
}

.sidebar-logo-sub {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    line-height: 1.25;
    white-space: normal;
}

.nav-menu {
    padding: 10px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.3s;
    gap: 12px;
    text-decoration: none;
    font-size: 15px;
    font-weight: 400;
    position: relative;
}

.nav-item:hover {
    background: #f5f7fa;
    color: #409eff;
}

.nav-item.active {
    background: #ecf5ff;
    color: #409eff;
    font-weight: 600;
}

.nav-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.nav-text {
    font-size: 15px;
    flex: 1;
    font-weight: inherit;
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.35;
}

.nav-arrow {
    width: 18px;
    height: 18px;
    transition: transform 0.3s;
    color: #9ca3af;
}

/* 子菜单分组标题：视觉与未选中的 .nav-item 一致（不加粗），避免与 .nav-item.active 混淆 */
.menu-group-title {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #4b5563;
    font-size: 15px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
    gap: 12px;
    position: relative;
    text-transform: none;
    letter-spacing: normal;
}
.menu-group-title .menu-group-label {
    font-size: 15px;
    flex: 1;
    font-weight: 400;
    color: inherit;
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.35;
}
.menu-group-title:hover {
    background: #f5f7fa;
    color: #409eff;
}
.menu-group-title:hover .menu-group-label {
    color: inherit;
}
.menu-group-title .nav-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.submenu.expanded {
    max-height: 500px;
}

.submenu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px 12px 54px;
    color: #606266;
    cursor: pointer;
    transition: all 0.3s;
    gap: 10px;
    text-decoration: none;
    font-size: 14px;
    position: relative;
}

.submenu-item:hover {
    background: #f5f7fa;
    color: #409eff;
}

.submenu-item.active {
    background: #ecf5ff;
    color: #409eff;
    font-weight: 600;
}

.submenu-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1.2;
}

.submenu-text {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.35;
}

/* 主内容区 */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: 60px;
    padding: 20px;
    transition: margin-left 0.3s;
    min-height: calc(100vh - 60px);
    background: #f5f7fa;
    width: calc(100% - var(--sidebar-width));
}

.main-content.expanded {
    margin-left: 0;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}
