/* ======== 全局重置 ======== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ======== 统一CSS变量 ======== */
:root {
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
    --transition-speed: 0.3s;
    --header-height: 56px;
    --footer-height: 80px;
    --main-content-padding: var(--header-height); /* 修复：简化计算 */
}

body {
    background-color: #f8f9fa;
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    padding-top: 0; /* 修改：移除顶部内边距 */
}

/* ======== Header样式 ======== */
/* 搜索框样式 */
.search-container {
    flex: 1;
    max-width: 450px;
}
.search-input {
    border-radius: 20px 0 0 20px !important;
    border: 1px solid #dee2e6;
    border-right: none;
    height: 40px;
    padding: 0 20px;
    background: #f8f9fa;
    transition: all 0.3s;
}
.search-input:focus {
    background: white;
    box-shadow: none;
    border-color: #4e73df;
}
.btn-search {
    border-radius: 0 20px 20px 0 !important;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-left: none;
    padding: 0 15px;
    color: #6c757d;
    transition: all 0.3s;
}
.btn-search:hover {
    background: #e9ecef;
    color: #4e73df;
}

/* 通知和消息图标 */
.header-icons .btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5a5c69;
    transition: all 0.3s;
    position: relative;
}
.header-icons .btn-icon:hover {
    background: #f0f4ff;
    color: #4e73df;
}
.bi-bell, .bi-chat-dots {
    font-size: 1.25rem;
}
.badge {
    font-size: 0.6rem;
    padding: 0.25em 0.4em;
}

/* 下拉菜单样式 */
.dropdown-menu {
    border-radius: 12px;
    border: 1px solid #eaeaea;
    min-width: 280px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    z-index: 1032; /* 确保下拉菜单在正确层级 */
}
.notification-dropdown, .message-dropdown {
    max-height: 400px;
    overflow-y: auto;
}

/* 通知中心样式 */
.notification-header, .message-header {
    padding: 15px;
    background: #f8f9fc;
    border-bottom: 1px solid #eaeaea;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notification-header h6, .message-header h6 {
    margin: 0;
    font-weight: 600;
}
.notification-header a, .message-header a {
    font-size: 0.8rem;
}
.notification-list, .message-list {
    padding: 5px 0;
}
.notification-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}
.notification-icon.bg-primary { background: #4e73df; }
.notification-icon.bg-warning { background: #f6c23e; }
.notification-icon.bg-info { background: #36b9cc; }
.notification-title {
    font-weight: 600;
    font-size: 0.95rem;
}
.notification-desc, .message-preview {
    font-size: 0.85rem;
    color: #6c757d;
    white-space: normal;
    line-height: 1.4;
}
.notification-time, .message-time {
    font-size: 0.75rem;
    color: #adb5bd;
    margin-top: 3px;
}
.notification-footer, .message-footer {
    padding: 10px;
    border-top: 1px solid #eaeaea;
    background: #f8f9fc;
}
.notification-footer a, .message-footer a {
    font-size: 0.9rem;
    color: #4e73df;
}

/* 消息中心样式 */
.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}
.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.message-title {
    font-weight: 600;
    font-size: 0.95rem;
}

/* 用户信息样式 */
.user-info {
    line-height: 1.3;
}
.staff-name {
    font-weight: 600 !important;
    color: #2c3e50 !important;
    font-size: 1.05rem;
    transition: color 0.3s ease;
}
.staff-role {
    font-size: 0.85rem;
    transition: color 0.3s ease;
}

/* 用户下拉菜单 */
.user-dropdown-header {
    padding: 15px;
    background: #f8f9fc;
    border-bottom: 1px solid #eaeaea;
}
.staff-email {
    font-size: 0.85rem;
}
.dropdown-item {
    padding: 0.6rem 1.25rem;
    border-radius: 6px;
    margin: 3px 8px;
    width: calc(100% - 16px);
    transition: all 0.2s;
    font-size: 0.95rem;
    position: relative; /* 为伪元素定位做准备 */
    overflow: hidden; /* 隐藏伪元素溢出 */
    padding-left: 1.5rem; /* 增加左侧内边距 */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); /* 更平滑的过渡 */
}
.dropdown-item:hover {
    background-color: rgba(78, 115, 223, 0.08); /* 更柔和的背景色 */
    color: #4e73df; /* 使用主题蓝色 */
    transform: translateX(0); /* 移除水平移动 */
    padding-left: 1.7rem; /* 悬停时增加左侧内边距 */
}
.dropdown-divider {
    margin: 0.4rem 0;
}

/* 添加悬停指示条 */
.dropdown-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background-color: transparent; /* 初始透明 */
    transition: background-color 0.3s ease;
    border-radius: 0 3px 3px 0;
}

.dropdown-item:hover::before {
    background-color: #4e73df; /* 悬停时显示蓝色指示条 */
}

/* 优化图标过渡效果 */
.dropdown-item i {
    transition: transform 0.3s ease;
}

.dropdown-item:hover i {
    transform: translateX(3px); /* 图标轻微右移 */
}

/* 头像容器 */
.avatar-container {
    position: relative;
    width: 40px;
    height: 40px;
    max-width: 100%; /* 新增：防止图片溢出 */
    max-height: 100%; /* 新增：防止图片溢出 */
    border-radius: 50%;
    overflow: hidden;
    transition: transform 0.3s ease;
    flex-shrink: 0; /* 新增：防止头像被压缩 */
    z-index: 1031; /* 确保头像在正确层级 */
}

/* 导航栏中的头像容器 */
#userDropdownContainer .avatar-container {
    width: 40px !important;
    height: 40px !important;
    flex-shrink: 0;
    z-index: 1031; /* 确保头像在正确层级 */
}
.user-avatar {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    transition: all 0.3s ease;
    border: 2px solid #e3e6f0;
}
.avatar-hover-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 110, 253, 0);
    border-radius: 50%;
    transition: background 0.3s ease;
    pointer-events: none;
}
#userDropdownContainer:hover .avatar-hover-effect {
    background: rgba(13, 110, 253, 0.1);
}
#userDropdownContainer:hover .user-avatar {
    transform: scale(1.08);
    border-color: rgba(13, 110, 253, 0.5);
}

/* 用户信息悬停效果 */
#userDropdownContainer .nav-link {
    transition: all 0.3s ease;
    border-radius: 30px;
    padding: 4px 10px;
    z-index: 1031; /* 确保用户信息在正确层级 */
}

#userDropdownContainer:hover .nav-link {
    background: linear-gradient(90deg, rgba(240, 244, 255, 0.8) 0%, rgba(240, 244, 255, 0.4) 100%);
    box-shadow: 0 4px 12px rgba(78, 115, 223, 0.15);
}

#userDropdownContainer:hover .staff-name {
    color: #4e73df !important;
    text-shadow: 0 0 5px rgba(78, 115, 223, 0.2);
}

#userDropdownContainer:hover .staff-role {
    color: #4e73df !important;
}

/* 移动端搜索框样式 */
.mobile-search-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    padding-top: 10px;
    padding-bottom: 10px;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.mobile-search-container .input-group {
    margin: 0 15px;
}

/* ======== 主内容区样式 ======== */
#main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--main-content-padding) 20px 20px 20px;
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
    transition: margin 0.3s ease;
    position: relative;
    z-index: 1035; /* 确保主内容区在正确层级 */
}
#main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* 头部定位 */
#header.navbar {
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    z-index: 1036; /* 调整z-index确保层级正确，高于sidebar */
    transition: left var(--transition-speed), width var(--transition-speed);
    background-color: #fff; /* 确保头部背景色 */
}

/* 侧边栏折叠时头部调整 */
#sidebar.collapsed ~ #header.navbar {
    left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* 修复：侧边栏定位 */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1035;
    background-color: #1a2330; /* 确保侧边栏背景色 */
}

/* ======== Footer样式 ======== */
#footer {
    /* 移除背景颜色 */
    border-top: 1px solid #eaeaea;
    padding: 20px 0;
    margin-top: auto;
    z-index: 1000;
    position: relative;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ======== 数据统计区域样式 ======== */
.stats-section {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    padding: 80px 0;
    margin: 60px 0;
    position: relative;
    overflow: hidden;
}

.stats-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.stats-section .container {
    position: relative;
    z-index: 2;
}

.stat-item {
    text-align: center;
    padding: 20px 15px;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    transition: none;
    border: none;
    backdrop-filter: none;
    margin: 0;
}

.stat-item:hover {
    transform: none;
    box-shadow: none;
    background: transparent;
}

.stat-number {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    color: white;
    line-height: 1;
    margin-bottom: 10px;
}

.stat-text {
    font-size: 1.3rem;
    font-weight: 400;
    opacity: 0.9;
}

.stat-figure {
    font-size: 3.5rem;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.stat-unit {
    font-size: 1.3rem;
    font-weight: 400;
    opacity: 0.9;
}

.stat-label {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
    letter-spacing: 0.5px;
    line-height: 1.3;
    margin-bottom: 0;
    text-transform: uppercase;
}

/* 响应式调整 */
@media (max-width: 1200px) {
    .stat-figure {
        font-size: 3rem;
    }
    
    .stat-text, .stat-unit {
        font-size: 1.1rem;
    }
}

@media (max-width: 992px) {
    .search-container {
        max-width: 300px;
    }
    
    .stats-section {
        padding: 60px 0;
        margin: 40px 0;
    }
    
    .stat-item {
        padding: 25px 15px;
        margin: 8px;
    }
    
    .stat-figure {
        font-size: 2.5rem;
    }
    
    .stat-text, .stat-unit {
        font-size: 1rem;
    }
    
    .stat-label {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .stats-section {
        padding: 40px 0;
        margin: 30px 0;
    }
    
    .stat-item {
        padding: 20px 10px;
        margin: 5px;
        border-radius: 10px;
    }
    
    .stat-figure {
        font-size: 2.2rem;
    }
    
    .stat-text, .stat-unit {
        font-size: 0.9rem;
    }
    
    .stat-label {
        font-size: 0.9rem;
        letter-spacing: 0.3px;
    }
}

@media (max-width: 576px) {
    .stats-section {
        padding: 30px 0;
        margin: 20px 0;
    }
    
    .stat-item {
        padding: 15px 8px;
        margin: 3px;
        border-radius: 8px;
    }
    
    .stat-figure {
        font-size: 1.8rem;
    }
    
    .stat-text, .stat-unit {
        font-size: 0.8rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .stat-number {
        gap: 4px;
        margin-bottom: 5px;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 56px; /* 移动端头部高度略小 */
    }
    .search-container {
        display: none;
    }
    .header-icons .me-3 {
        margin-right: 0.5rem !important;
    }
    .user-info {
        display: none !important;
    }
    .dropdown-toggle::after {
        display: none;
    }
    .language-dropdown {
        display: none;
    }
    
    /* 移动端内容区调整 */
    #main-content {
        margin-left: 0;
        width: 100%;
        min-height: calc(100vh - var(--header-height) - var(--footer-height));
        padding: var(--main-content-padding) 15px 15px 15px;
        z-index: 1035; /* 确保移动端主内容区在正确层级 */
    }
    
    #sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        z-index: 1040;
    }
    
    #sidebar.show {
        transform: translateX(0);
    }
    
    /* 移动端时头部全宽 */
    #header.navbar {
        left: 0 !important;
        width: 100% !important;
        z-index: 1041; /* 调整z-index确保层级正确，高于移动端sidebar */
    }

    /* 移动端用户区域悬停效果重置 */
    #userDropdownContainer .nav-link {
        padding: 0 !important;
        z-index: 1031; /* 确保移动端用户信息在正确层级 */
    }
    
    /* 移动端下拉菜单调整 */
    .dropdown-menu {
        z-index: 1032; /* 确保移动端下拉菜单在正确层级 */
    }
}