/* 
 * 统一的仪表盘样式 - 解决布局冲突问题
 * 创建时间：2025-01-15
 * 说明：合并并优化dashboard.css和dashboard-enhanced.css，解决样式冲突
 */

/* ===========================
   CSS变量定义（统一）
   =========================== */
:root {
    /* 主题色 - 统一使用一套 */
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-color: #2DCE89;
    --warning-color: #FB6340;
    --info-color: #11CDEF;
    --danger-color: #F5365C;
    --dark-color: #172B4D;
    
    /* 布局尺寸 - 固定值避免错位 */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    
    /* 中性色 */
    --gray-100: #f6f9fc;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #8898aa;
    --gray-700: #525f7f;
    --gray-800: #32325d;
    --gray-900: #212529;
    
    /* 背景色 */
    --bg-primary: #f5f7fa;
    --bg-white: #ffffff;
    
    /* 阴影 */
    --shadow-sm: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    --shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
    --shadow-lg: 0 1rem 3rem rgba(0,0,0,0.175);
    
    /* 过渡动画 */
    --transition-base: all 0.3s ease;
    --transition-fast: all 0.15s ease;
}

/* ===========================
   全局重置和基础样式
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--gray-800);
    height: 100%;
    overflow-x: hidden;
    position: relative;
}

/* ===========================
   主布局容器 - 使用Flexbox解决错位
   =========================== */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ===========================
   侧边栏样式
   =========================== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #2d3561 0%, #1a1f3a 100%);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1040; /* Bootstrap modal是1050，我们低一点 */
    transition: var(--transition-base);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

/* 侧边栏折叠状态 */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* 侧边栏头部 */
.sidebar-header {
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-header h3 {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    white-space: nowrap;
}

.sidebar-header h3 i {
    font-size: 24px;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-header h3 span {
    display: none;
}

/* 侧边栏导航 */
.sidebar-nav {
    padding: 20px 0;
    list-style: none;
    margin: 0;
}

.sidebar-nav li {
    margin-bottom: 5px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: var(--transition-base);
    position: relative;
    font-size: 15px;
    white-space: nowrap;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-nav li.active a {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-left: 3px solid var(--primary-color);
}

.sidebar-nav a i {
    width: 24px;
    margin-right: 12px;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 12px;
}

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

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

/* ===========================
   主内容区 - 修复margin问题
   =========================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition: var(--transition-base);
    display: flex;
    flex-direction: column;
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* ===========================
   顶部栏 - 统一类名
   =========================== */
.top-bar {
    background: var(--bg-white);
    padding: 0 30px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--gray-200);
}

.top-bar h4 {
    margin: 0;
    color: var(--dark-color);
    font-weight: 600;
    font-size: 20px;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--gray-700);
    cursor: pointer;
    transition: var(--transition-fast);
    padding: 8px;
    margin-right: 20px;
}

.sidebar-toggle:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

/* 用户信息区域 */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.user-avatar:hover {
    transform: scale(1.05);
}

/* ===========================
   仪表盘内容包装器
   =========================== */
.dashboard-wrapper {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

/* ===========================
   内容区块
   =========================== */
.content-section {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===========================
   统计卡片
   =========================== */
.stat-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
    height: 100%;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 15px;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 5px;
}

.stat-label {
    color: var(--gray-600);
    font-size: 14px;
    font-weight: 500;
}

/* 渐变背景类 */
.gradient-blue {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-green {
    background: linear-gradient(135deg, #2dce89 0%, #2dcecc 100%);
}

.gradient-orange {
    background: linear-gradient(135deg, #fb6340 0%, #fbb140 100%);
}

.gradient-purple {
    background: linear-gradient(135deg, #8965e0 0%, #bc65e0 100%);
}

/* ===========================
   数据表格
   =========================== */
.data-section {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--gray-200);
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark-color);
    margin: 0;
}

.table-responsive {
    overflow-x: auto;
    margin: 0 -10px;
    padding: 0 10px;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
}

.custom-table thead th {
    background: var(--gray-100);
    color: var(--gray-700);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    padding: 12px;
    border: none;
}

.custom-table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-800);
}

.custom-table tbody tr:hover {
    background: var(--gray-100);
}

/* ===========================
   响应式设计 - 统一断点
   =========================== */
@media (max-width: 1200px) {
    .dashboard-wrapper {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    /* 移动端侧边栏默认隐藏 */
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0,0,0,0.5);
    }
    
    /* 主内容区全宽 */
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .main-content.expanded {
        margin-left: 0;
        width: 100%;
    }
    
    /* 顶部栏调整 */
    .top-bar {
        padding: 0 15px;
    }
    
    .dashboard-wrapper {
        padding: 15px;
    }
    
    /* 统计卡片堆叠 */
    .stat-card {
        margin-bottom: 15px;
    }
    
    /* 表格滚动 */
    .table-responsive {
        margin: 0 -15px;
        padding: 0 15px;
    }
    
    /* 用户信息简化 */
    .user-info small {
        display: none;
    }
}

@media (max-width: 576px) {
    .top-bar h4 {
        font-size: 16px;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* ===========================
   工具类
   =========================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-600); }
.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }

.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }

.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-active,
.status-published {
    background: rgba(45, 206, 137, 0.1);
    color: var(--success-color);
}

.status-pending,
.status-draft {
    background: rgba(251, 99, 64, 0.1);
    color: var(--warning-color);
}

.status-completed {
    background: rgba(94, 114, 228, 0.1);
    color: var(--primary-color);
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* 加载动画 */
.skeleton-loader {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.skeleton-row {
    height: 20px;
    background: var(--gray-200);
    border-radius: 4px;
    margin-bottom: 10px;
}

/* 动画类 */
.fade-in {
    animation: fadeIn 0.5s ease;
}

.slide-in-left {
    animation: slideInLeft 0.3s ease;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* ===========================
   修复Bootstrap覆盖问题
   =========================== */
.btn {
    transition: var(--transition-fast);
}

.modal-backdrop {
    z-index: 1049;
}

.modal {
    z-index: 1050;
}

/* 确保内容不被遮挡 */
.content-section {
    position: relative;
    z-index: 1;
}