/* 现代化白色主题 - 更新版 */
:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --success-color: #10b981;
    --info-color: #3b82f6;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --light-color: #f8fafc;
    --dark-color: #1e293b;
    --gray-color: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8fafc;
    color: var(--dark-color);
    min-height: 100vh;
    line-height: 1.5;
}

/* 加载动画 */
.loader {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: white;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    transition: transform var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
    transform: translateX(0); /* 默认显示 */
}

.sidebar-header {
    padding: 24px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-menu {
    padding: 20px 0;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--dark-color);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    font-weight: 500;
    gap: 12px;
    position: relative;
    cursor: pointer;
    user-select: none;
}

.menu-item:hover {
    background-color: rgba(67, 97, 238, 0.05);
    border-left-color: var(--primary-color);
    color: var(--primary-color);
}

.menu-item.active {
    background-color: rgba(67, 97, 238, 0.1);
    border-left-color: var(--primary-color);
    color: var(--primary-color);
}

.menu-item.has-submenu::after {
    content: '›';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
    transition: transform 0.3s ease;
    font-size: 1.2rem;
    color: var(--gray-color);
}

.menu-item.has-submenu.active::after {
    transform: translateY(-50%) rotate(-90deg);
}

.sub-menu {
    padding-left: 40px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sub-menu.show {
    max-height: 500px;
}

/* 主内容区 */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 24px;
    transition: margin-left var(--transition-speed) ease;
    min-height: 100vh;
}

/* 导航栏 */
.navbar {
    background: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dark-color);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* 移动端侧边栏切换按钮 */
.mobile-toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--dark-color);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.mobile-toggle-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* 统计卡片网格布局 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* 统计卡片 */
.stats-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.stats-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.stats-card:nth-child(2)::before {
    background: linear-gradient(90deg, var(--success-color), #059669);
}

.stats-card:nth-child(3)::before {
    background: linear-gradient(90deg, var(--info-color), #2563eb);
}

.stats-card:nth-child(4)::before {
    background: linear-gradient(90deg, var(--warning-color), #d97706);
}

.stats-card:nth-child(5)::before {
    background: linear-gradient(90deg, #8b5cf6, #7c3aed);
}

.stats-card:nth-child(6)::before {
    background: linear-gradient(90deg, var(--danger-color), #dc2626);
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.stats-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: rgba(67, 97, 238, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.5rem;
}

.stats-number {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 4px;
    line-height: 1;
}

.stats-label {
    color: var(--gray-color);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 8px;
}

.trend-up {
    color: var(--success-color);
}

.trend-down {
    color: var(--danger-color);
}

/* 卡片布局 */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
    font-weight: 600;
    font-size: 1.125rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 24px;
}

/* 表格美化 */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background-color: #f8fafc;
    font-weight: 600;
    padding: 14px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    color: var(--dark-color);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--dark-color);
}

.table tr:hover {
    background-color: rgba(67, 97, 238, 0.02);
}

/* 表单美化 */
.form-group {
    margin-bottom: 20px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    background: white;
    color: var(--dark-color);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark-color);
    font-size: 0.875rem;
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--dark-color);
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    background: white;
    width: 90%;
    max-width: 600px;
    margin: 50px auto;
    border-radius: 12px;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 响应式设计 - 移动端样式 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
        width: 280px;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px auto;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-number {
        font-size: 2rem;
    }
    
    /* 移动端侧边栏遮罩 */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        animation: fadeIn 0.3s ease;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* 移动端菜单项样式 */
    .menu-item {
        padding: 14px 20px;
    }
    
    .menu-item.has-submenu {
        padding-right: 50px;
    }
    
    .menu-item.has-submenu::after {
        right: 20px;
        font-size: 1.5rem;
        color: var(--gray-color);
    }
    
    .sub-menu {
        padding-left: 30px;
        background-color: rgba(0, 0, 0, 0.02);
    }
    
    .sub-menu .menu-item {
        padding: 12px 20px;
        font-size: 0.9rem;
        color: var(--gray-color);
        border-left: 2px solid transparent;
    }
    
    .sub-menu .menu-item.active {
        border-left-color: var(--primary-color);
    }
    
    /* 移动端导航栏 */
    .navbar {
        padding: 12px 16px;
    }
    
    .navbar-title {
        font-size: 1.25rem;
    }
    
    .mobile-toggle-btn {
        display: block;
    }
    
    /* 卡片调整 */
    .card-header, .card-body {
        padding: 15px 20px;
    }
    
    /* 表格调整 */
    .table th, .table td {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
}

/* 侧边栏动画 */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

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

/* 工具类 */
.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.text-gray { color: var(--gray-color); }

.bg-light { background-color: var(--light-color); }
.bg-primary-light { background-color: rgba(67, 97, 238, 0.1); }

.rounded { border-radius: 8px; }
.rounded-lg { border-radius: 12px; }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* 登录页面 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fb 0%, #c3cfe2 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

/* 分隔线 */
.divider {
    height: 1px;
    background: var(--border-color);
    margin: 24px 0;
    border: none;
}

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

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* 徽章 */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

/* 进度条 */
.progress {
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

/* 在现有样式文件的末尾添加以下内容 */

/* 修复模态框过长问题 */
.modal-content {
    position: relative;
    background: white;
    width: 90%;
    max-width: 700px;
    max-height: 85vh; /* 限制最大高度 */
    margin: 50px auto;
    border-radius: 12px;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

/* 模态框头部固定 */
.modal-content .card-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
}

/* 模态框内容可滚动 */
.modal-content .card-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    max-height: calc(85vh - 80px); /* 减去头部高度 */
}

/* 添加平滑滚动 */
.modal-content .card-body::-webkit-scrollbar {
    width: 8px;
}

.modal-content .card-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-content .card-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.modal-content .card-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 10px auto;
    }
    
    .modal-content .card-body {
        max-height: calc(90vh - 70px);
        padding: 15px;
    }
    
    .modal-content .card-header {
        padding: 15px 20px;
    }
}

/* 修复表单在模态框中的显示 */
.modal-content .form-group {
    margin-bottom: 15px;
}

.modal-content .form-control {
    padding: 10px 14px;
    font-size: 14px;
}

.modal-content .row {
    margin-left: -8px;
    margin-right: -8px;
}

.modal-content .col-md-6 {
    padding-left: 8px;
    padding-right: 8px;
}

/* 修复代码编辑器高度 */
.CodeMirror {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    height: 400px;
    min-height: 300px;
    max-height: 500px;
    resize: vertical;
}

.cm-s-dracula.CodeMirror {
    background: #282a36;
    color: #f8f8f2;
}

/* 修复表格在模态框中的显示 */
.modal-content .table {
    margin-bottom: 0;
    font-size: 14px;
}

.modal-content .table th,
.modal-content .table td {
    padding: 10px 12px;
}

/* 修复按钮组间距 */
.modal-content .btn {
    margin-right: 5px;
    margin-bottom: 5px;
}

/* 修复警告框在模态框中 */
.modal-content .alert {
    margin-top: 15px;
    margin-bottom: 15px;
    padding: 12px 16px;
    font-size: 14px;
}

/* 修复文本区域 */
.modal-content textarea.form-control {
    min-height: 100px;
    max-height: 300px;
    resize: vertical;
}

/* 修复输入组 */
.modal-content .input-group {
    flex-wrap: nowrap;
}

.modal-content .input-group .form-control {
    flex: 1;
}

/* 修复复选和单选按钮 */
.modal-content .form-check {
    margin-bottom: 8px;
    padding-left: 25px;
}

.modal-content .form-check-input {
    margin-left: -25px;
    margin-top: 0.3em;
}

/* 修复标签 */
.modal-content .form-label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 5px;
}

/* 修复小文本 */
.modal-content .form-text {
    font-size: 12px;
}

/* 修复加载器在模态框中 */
.modal-content .loader {
    width: 20px;
    height: 20px;
    border-width: 3px;
}

/* 修复按钮加载状态 */
.modal-content .btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* 修复模态框动画 */
@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(-20px); opacity: 0; }
}

.modal.closing .modal-content {
    animation: slideOut 0.3s ease;
}

/* 修复模态框关闭按钮 */
.modal-content .card-header button {
    color: var(--gray-color);
    transition: color 0.3s ease;
}

.modal-content .card-header button:hover {
    color: var(--danger-color);
}

/* 修复模态框中的代码块 */
.modal-content code {
    background-color: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
}

/* 修复模态框中的预览区域 */
.modal-content pre {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    overflow-x: auto;
    max-height: 200px;
    margin: 10px 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px;
    transition: width 0.3s ease;
}
/* 移动端侧边栏增强 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 280px;
        box-shadow: 2px 0 15px rgba(0,0,0,0.1);
        z-index: 1050;
    }
    
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 2px 0 15px rgba(0,0,0,0.2);
    }
    
    /* 侧边栏打开时的遮罩层 */
    .sidebar.show::before {
        content: '';
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 280px;
        background: rgba(0,0,0,0.5);
        z-index: 1049;
        animation: fadeIn 0.3s ease;
    }
    
    /* 侧边栏关闭按钮 */
    .sidebar-close {
        display: none;
        position: absolute;
        top: 20px;
        right: 20px;
        background: none;
        border: none;
        font-size: 24px;
        color: white;
        cursor: pointer;
        z-index: 1;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background-color 0.3s ease;
    }
    
    .sidebar.show .sidebar-close {
        display: flex;
    }
    
    .sidebar-close:hover {
        background-color: rgba(255,255,255,0.1);
    }
    
    /* 确保侧边栏内容可滚动 */
    .sidebar-menu {
        overflow-y: auto;
        max-height: calc(100vh - 120px);
        padding-bottom: 20px;
    }
    
    /* 主内容区调整 */
    .main-content {
        transition: margin-left 0.3s ease;
        width: 100%;
    }
    
    /* 导航栏按钮调整 */
    #sidebarToggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        background: var(--primary-color);
        color: white;
        border: none;
        cursor: pointer;
        transition: background 0.3s ease;
    }
    
    #sidebarToggle:hover {
        background: var(--secondary-color);
    }
    
    /* 表格在移动端的适配 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 模态框在移动端的适配 */
    .modal-content {
        width: 95% !important;
        margin: 20px auto !important;
        max-height: 90vh !important;
    }
    
    .modal-content .card-body {
        max-height: calc(90vh - 80px);
        overflow-y: auto;
    }
    
    /* 统计卡片网格在移动端的适配 */
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* 侧边栏遮罩动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 侧边栏滑动动画 */
@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

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

/* 修复侧边栏在桌面端的显示 */
@media (min-width: 769px) {
    .sidebar {
        transform: translateX(0) !important;
        display: block !important;
    }
    
    .sidebar-close {
        display: none !important;
    }
}

/* 添加触摸友好的按钮样式 */
.btn {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* 移动端表单元素优化 */
@media (max-width: 768px) {
    .form-control {
        font-size: 16px; /* 防止iOS自动缩放 */
    }
    
    input, textarea, select {
        font-size: 16px !important; /* 防止iOS自动缩放 */
    }
    
    /* 增加触摸目标大小 */
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }
    
    .btn-sm {
        min-height: 36px;
        min-width: 36px;
        padding: 8px 16px;
    }
}