/* 布局样式 */

/* 全局样式 */
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* 应用容器 */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* 主要内容区域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* 页面容器 */
.page-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* 防止flex item超出容器 */
}

/* 页面头部统一样式 */
.page-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    padding: var(--spacing-lg) var(--spacing-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.page-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: var(--spacing-xs) 0 0 0;
}

.page-actions {
    display: flex;
    gap: var(--spacing);
    align-items: center;
}

/* 页面内容区域 */
.page-content {
    flex: 1;
    padding: var(--spacing-xl);
    overflow-y: auto;
    min-height: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .page-header {
        padding: var(--spacing) var(--spacing-lg);
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing);
    }

    .page-title {
        font-size: 1.5rem;
    }

    .page-content {
        padding: var(--spacing-lg);
    }
}

@media (max-width: 576px) {
    .page-header {
        padding: var(--spacing-sm) var(--spacing);
    }

    .page-content {
        padding: var(--spacing);
    }
}

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-dark);
    color: var(--text-white);
    transition: all 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-fixed);
    overflow-x: hidden;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* 移动端侧边栏遮罩 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-fixed) - 1);
}

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

.sidebar-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: var(--spacing);
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-white);
    text-decoration: none;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-logo span {
    display: none;
}

.sidebar-nav {
    padding: var(--spacing) 0;
    list-style: none;
    margin: 0;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    padding: 0.875rem var(--spacing-lg);
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    white-space: nowrap;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    margin: 0 var(--spacing-sm);
    font-weight: 500;
}

.sidebar-nav-item:hover {
    color: var(--text-white);
    background: rgba(255,255,255,0.1);
    transform: translateX(4px);
}

.sidebar-nav-item.active {
    color: var(--text-white);
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-light);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.sidebar-nav-item i {
    width: 20px;
    margin-right: var(--spacing);
    text-align: center;
}

.sidebar.collapsed .sidebar-nav-item span {
    display: none;
}

.sidebar.collapsed .sidebar-nav-item i {
    margin-right: 0;
}

.sidebar-toggle {
    position: absolute;
    right: -15px;
    top: var(--spacing-xl);
    background: var(--primary-color);
    color: var(--text-white);
    border: 2px solid var(--bg-secondary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--primary-dark);
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* 顶部导航栏 */
.navbar {
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
    padding: 0 var(--spacing-lg);
    height: var(--navbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing);
    list-style: none;
    margin: 0;
    padding: 0;
}

.navbar-nav .nav-item {
    position: relative;
}

.navbar-nav .nav-link {
    color: var(--text-secondary);
    padding: 0.5rem var(--spacing);
    border-radius: var(--border-radius);
    text-decoration: none;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.navbar-nav .nav-link:hover {
    color: var(--primary-color);
    background: var(--bg-secondary);
}

.navbar-nav .nav-link.active {
    color: var(--primary-color);
    background: rgba(0,123,255,0.1);
}

/* 用户菜单 */
.user-menu {
    position: relative;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--text-white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 500;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    min-width: 200px;
    padding: var(--spacing-sm) 0;
    margin-top: var(--spacing-sm);
    display: none;
    z-index: var(--z-dropdown);
}

.user-dropdown.show {
    display: block;
}

.user-dropdown-item {
    display: block;
    padding: 0.5rem var(--spacing);
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.user-dropdown-item:hover {
    background: var(--bg-secondary);
}

.user-dropdown-divider {
    border-top: 1px solid var(--border-light);
    margin: var(--spacing-sm) 0;
}

/* 页面内容 */
.page-content {
    flex: 1;
    padding: var(--spacing-lg);
    overflow-y: auto;
}

/* 页面头部 */
.page-header {
    margin-bottom: var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing);
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.page-subtitle {
    font-size: var(--font-size);
    color: var(--text-muted);
    margin: var(--spacing-sm) 0 0 0;
}

.page-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

/* 面包屑导航 */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: var(--spacing);
}

.breadcrumb-item {
    color: var(--text-muted);
}

.breadcrumb-item a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--primary-color);
}

.breadcrumb-item.active {
    color: var(--text-primary);
}

/* 网格系统增强 */
.row {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
}

.row > [class*="col"] {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* 间距工具类 */
.gap-0 { gap: 0; }
.gap-1 { gap: var(--spacing-xs); }
.gap-2 { gap: var(--spacing-sm); }
.gap-3 { gap: var(--spacing); }
.gap-4 { gap: var(--spacing-lg); }
.gap-5 { gap: var(--spacing-xl); }

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

.loading-content {
    background: var(--bg-primary);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

/* 响应式布局 */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content {
        margin-left: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 var(--spacing);
    }

    .page-content {
        padding: var(--spacing);
    }

    .row {
        margin-left: -0.25rem;
        margin-right: -0.25rem;
    }

    .row > [class*="col"] {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }

    .page-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 576px) {
    .page-title {
        font-size: 1.5rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }

    .btn {
        padding: 0.375rem 0.75rem;
        font-size: var(--font-size-sm);
    }
}

/* 打印样式 */
@media print {
    .sidebar,
    .navbar,
    .page-actions,
    .btn,
    .modal {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .page-content {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}