html {
    font-size: 15px;
}

body {
    padding-top: 3.5rem;
    /* Mobile header height */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    color: var(--text-primary);
}

/* Desktop: No top padding as header is gone */
@media (min-width: 768px) {
    body {
        padding-top: 0;
    }
}

/* 确保整个页面高度至少与视口一样高 */
html,
body {
    height: 100%;
    overflow: hidden;
}

/* 侧边栏和主内容区域的容器 */
.content-part.container-fluid,
.content-part>.row {
    height: 100%;
}

.content-part>.row {
    position: relative;
}

/* 设置主内容区域的最小高度，并启用flexbox以便内部内容可以滚动 */
.content-part>.row>main {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: absolute;
    right: 0;
    top: 0;
    /* Ensure it starts from top on desktop */
}

/* 让主内容的内部滚动，而不是整个页面 */
#main-content {
    overflow: hidden;
    /* Changed from overflow-y: auto to hidden. Pages scroll themselves. */
    flex: 1;
    position: relative;
    width: calc(100vw - var(--sidebar-width));
}

/* Page Stack Container: Each page manages its own scrolling and stacking */
.page-stack-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--white);
    /* #f8f8f8 default bg */
    z-index: 1;
    /* Default base z-index */
}

.loading-overlay {
    position: absolute;
    /* 相对于 main-content 定位 */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 1000;
}

.loading-overlay .loading-text {
    font-size: 1.2rem;
    color: #333;
}

.loading-overlay .dots {
    display: inline-block;
    position: relative;
    width: 1.2rem;
    overflow: hidden;
}

.loading-overlay .dots::after {
    content: '...';
    position: absolute;
    left: -0.6rem;
    /* Start the animation from the left */
    animation: dotSteps 1.5s infinite;
}

@keyframes dotSteps {

    0%,
    20% {
        transform: translateX(0);
    }

    40%,
    60% {
        transform: translateX(100%);
    }

    80%,
    100% {
        transform: translateX(200%);
    }
}

/* Removed .navbar styles as it is replaced/removed */

.mobile-header {
    z-index: 1030;
}

/* 侧边栏容器 */
#sidebar {
    height: 100vh;
    /* Full height on desktop */
    width: var(--sidebar-width);
    color: var(--text-primary);
    z-index: 10;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
    /* bg-light */
}

/* Sidebar Wrapper to handle layout inside sidebar */
.sidebar-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-sticky {
    display: flex;
    flex-direction: column;
    /* height is handled by flex-grow in wrapper */
}

/* sidebar-main：顶部菜单部分，允许滚动 */
.sidebar-main {
    flex-grow: 1;
    /* 使顶部菜单部分占据可用空间 */
    /* overflow-y: auto;  Handled by .sidebar-sticky parent if needed, or itself */
}

/* 侧边栏分类标题 */
.sidebar-category {
    font-weight: bold;
    font-size: 0.8rem;
    /* Adjusted font size */
    color: #333;
    padding: 0.75rem 1.3rem 0.5rem 1rem;
    text-transform: uppercase;
}

/* 侧边栏分类标记 */
.sidebar-category+.nav-item {
    border-top: 1px solid #ddd;
}

/* 菜单项样式 */
.nav-item {
    margin-bottom: 0rem;
    /* Space between items */
}

.nav-link {
    padding: 0.3rem 1.8rem;
    border-radius: 0.35rem;
    color: #000;
    position: relative;
    display: flex;
    align-items: center;
}

/* 鼠标悬浮时的样式 */
.nav-link:hover {
    background-color: #e9ecef;
    /* Bootstrap gray-200 */
    color: #000;
    text-decoration: none;
}

/* 选中时的样式 */
.nav-link.active {
    background-color: #e2e6ea;
    /* Bootstrap gray-300 */
    font-weight: 500;
}

.nav-link>.fa,
.nav-link>.fas,
.nav-link>.far,
.nav-link>.fab {
    width: 1.5rem;
    text-align: center;
    margin-right: 0.5rem;
}

/* Sidebar Profile Area */
.sidebar-profile {
    background-color: #f8f9fa;
    position: relative;
    /* For dropup positioning */
}

.user-profile-btn {
    display: flex;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 0.5rem;
    color: #333;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s;
}

.user-profile-btn:hover {
    background-color: #e9ecef;
    text-decoration: none;
}

.user-profile-btn img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 0.75rem;
}

.user-profile-info {
    flex-grow: 1;
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.user-role {
    font-size: 0.75rem;
    color: #6c757d;
    display: block;
}

/* Dropup Menu Customization */
.sidebar-profile .dropdown-menu {
    bottom: 100% !important;
    top: auto !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    transform: translateY(-0.5rem) !important;
    width: calc(100% - 1rem);
    border-radius: 0.5rem;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, .1);
    padding: 0.5rem 0;
    min-width: unset;
    /* Override bootstrap default */
}

.sidebar-profile .dropdown-item {
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.sidebar-profile .dropdown-item i {
    width: 1.2rem;
    margin-right: 0.5rem;
    text-align: center;
}

.sidebar-profile .dropdown-item:hover {
    background-color: #f8f9fa;
}

/* Avatar Badge (Red Dot) */
.avatar-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background-color: #dc3545;
    /* Bootstrap danger color */
    border-radius: 50%;
    border: 2px solid #f8f9fa;
    /* Border matching background */
    display: none;
    /* Hidden by default */
}

.user-avatar-wrapper {
    position: relative;
    display: inline-block;
}


/* 设置 Badge 的位置 */
.nav-link .notification-badge {
    margin-left: auto;
    /* Push to right */
    font-size: 0.75rem;
    padding: 0.25em 0.6em;
    border-radius: 10rem;
    background-color: #dc3545;
    color: white;
}

.sidebar-profile .dropdown-item .notification-badge {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 0.2em 0.5em;
    background-color: #dc3545;
    color: white;
    border-radius: 10px;
}


/* Query Highlight */
.query-highlight {
    background-color: yellow;
}

.scroll-top-button {
    position: fixed;
    bottom: 3rem;
    right: 3rem;
    display: none;
    z-index: 9999;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background-color: #007bff;
    color: #fff;
    border: none;
    outline: none;
    opacity: 0.7;
}

.scroll-top-button:hover {
    opacity: 0.95;
    background-color: #007bff;
}

/* 自定义导航栏样式 */
@media (max-width: 768px) {
    .content-part>.row>main {
        width: 100%;
        top: 3.5rem;
        /* Start after mobile header */
        height: calc(100% - 3.5rem);
    }

    #main-content {
        width: 100%;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 9;
        display: none;
    }

    #sidebar.show+.sidebar-overlay {
        display: block;
    }

    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        position: fixed;
        /* Fixed on mobile */
        top: 3.5rem;
        /* Below mobile header */
        height: calc(100vh - 3.5rem);
        border-right: 1px solid #dee2e6;
    }

    #sidebar.show {
        transform: translateX(0);
    }
}

.page-title {
    line-height: normal;
    margin: 0;
}

.page-back-btn {
    color: var(--text-primary);
}

.page-back-btn:hover {
    color: var(--text-primary);
}

/* ---------------------------------------------------------
   UI Standards - Page Header & Layout
   --------------------------------------------------------- */

/* Page Container - Standards */
.page-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--white);
    /* Default white bg */
}

/* Sticky Header Wrapper */
.page-header-wrapper {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--white);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

/* Mobile: Unstick header if requested */
@media (max-width: 768px) {
    .page-header-wrapper {
        position: relative;
        padding: 1rem;
    }
}

/* Page Header Content */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Title Standards */
.page-title {
    font-size: 1.25rem;
    /* h4 size approx */
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-weight: normal;
}

.page-titles {
    display: flex;
    flex-direction: column;
}

/* Back Button Standard */
.btn-page-back {
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.btn-page-back:hover {
    color: var(--text-primary);
    background-color: var(--gray-100);
    border-color: var(--border-medium);
}

/* ---------------------------------------------------------
   UI Standards - Search Filter Section
   --------------------------------------------------------- */

.search-filter-container {
    padding: 1rem 1.5rem 0 1.5rem;
    /* No bottom padding, elements usually have margin-bottom */
    background-color: var(--white);
    /* border-bottom: 1px dashed var(--border-light); Optional separator */
}

/* Search Form Row */
.search-form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    /* Align bottom for labels + inputs */
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-form-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
    flex: 0 1 auto;
}

/* Use Bootstrap's .col- classes if grid layout is preferred, 
   but flex gap is cleaner for variable widths */

.search-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.search-input {
    height: 2.25rem;
    /* Compact height */
    font-size: 0.9rem;
    border-radius: 0.4rem;
    border: 1px solid var(--border-light);
    padding: 0.3rem 0.75rem;
    transition: border-color 0.2s;
    background-color: var(--white);
}

.search-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(255, 159, 10, 0.1);
}

/* Standard Function Button (Reference: btn-function) */
.btn-search-action {
    height: 2.25rem;
    padding: 0 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Page Body Content */
.page-body {
    flex: 1;
    padding: 1.5rem;
    overflow-x: hidden;
    /* Prevent horizontal scroll on body */
}

@media (max-width: 768px) {
    .page-body {
        padding: 1rem;
    }

    .search-filter-container {
        padding: 1rem 1rem 0 1rem;
    }

    .search-form-group {
        width: 100%;
        /* Full width on mobile */
    }

    .search-form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-search-action {
        width: 100%;
    }
}