/* ==========================================
   二次元蓝色主题 - 后台管理面板样式
   优化版：减少选择器嵌套、合并重复规则、优化性能
   ========================================== */

/* CSS 变量 - 减少重复值 */
:root {
    --theme-primary: #667eea;
    --theme-secondary: #764ba2;
    --theme-primary-light: rgba(102, 126, 234, 0.1);
    --theme-glass-bg: rgba(255, 255, 255, 0.9);
    --theme-glass-border: rgba(255, 255, 255, 0.8);
    --theme-border: rgba(148, 163, 184, 0.25);
    --theme-text: #2d3748;
    --theme-shadow: rgba(31, 38, 135, 0.1);
    --theme-border-radius: 12px;
    --theme-border-radius-lg: 16px;
}

/* ==========================================
   全局基础样式
   ========================================== */
body {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff 25%, #f0f4ff 50%, #e8f0fe 75%, #eef2ff);
    background-attachment: fixed;
    color: var(--theme-text);
}

/* 内容区域背景透明 */
#content-wrapper,
#content,
.container-fluid {
    background: transparent;
    color: var(--theme-text);
}

/* ==========================================
   侧边栏 - 二次元蓝色风格
   ========================================== */
.bg-gradient-primary {
    background: linear-gradient(180deg, #2d5a9e, #3d4e9e 50%, #4a3f8c);
    box-shadow: 4px 0 20px rgba(61, 78, 158, 0.35);
}

/* 侧边栏文字 - 统一白色 */
.sidebar-dark .nav-item .nav-link,
.sidebar-dark .nav-item .nav-link span,
.sidebar-dark .collapse-header,
.sidebar-dark .collapse-item,
.sidebar-brand-text,
.sidebar-brand {
    color: #fff;
}

.sidebar-dark .nav-item .nav-link {
    border-radius: 0 var(--theme-border-radius) var(--theme-border-radius) 0;
    margin-right: 12px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.sidebar-dark .nav-item .nav-link i {
    color: rgba(255, 255, 255, 0.95);
}

/* 侧边栏悬停/活跃效果 */
.sidebar-dark .nav-item .nav-link:hover,
.sidebar-dark .nav-item .nav-link:focus,
.sidebar-dark .nav-item .nav-link:active {
    background: rgba(255, 255, 255, 0.2);
    border-left: 3px solid #c4b5fd;
}

.sidebar-dark .nav-item .nav-link:hover i,
.sidebar-dark .nav-item.active .nav-link i {
    color: #fff;
}

.sidebar-dark .nav-item.active .nav-link {
    background: rgba(255, 255, 255, 0.25);
    border-left: 3px solid #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* 侧边栏品牌区域 */
.sidebar-brand {
    background: rgba(255, 255, 255, 0.15);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.sidebar-brand-text {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.sidebar-dark hr.sidebar-divider {
    border-top-color: rgba(255, 255, 255, 0.2);
}

/* ==========================================
   卡片样式 - 毛玻璃效果
   ========================================== */
.card {
    position: relative;
    overflow: hidden;
    background: var(--theme-glass-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--theme-glass-border);
    border-radius: var(--theme-border-radius-lg);
    box-shadow: 0 8px 32px var(--theme-shadow);
    will-change: transform;
}

.card-header {
    background: rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid var(--theme-border);
    border-radius: var(--theme-border-radius-lg) var(--theme-border-radius-lg) 0 0;
    padding: 1rem 1.5rem;
}

.card-header h6 {
    color: var(--theme-text);
    font-weight: 700;
}

/* 统计卡片 - 彩色渐变 */
.card.bg-primary,
.card.bg-success,
.card.bg-danger,
.card.bg-purple {
    border: none;
}

.card.bg-primary {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    box-shadow: 0 8px 25px rgba(79, 172, 254, 0.3);
}

.card.bg-success {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    box-shadow: 0 8px 25px rgba(67, 233, 123, 0.3);
}

.card.bg-danger {
    background: linear-gradient(135deg, #fa709a, #fee140);
    box-shadow: 0 8px 25px rgba(250, 112, 154, 0.3);
}

.card.bg-purple {
    background: linear-gradient(135deg, #a18cd1, #fbc2eb);
    box-shadow: 0 8px 25px rgba(161, 140, 209, 0.3);
}

.card.bg-primary .text-white,
.card.bg-success .text-white,
.card.bg-danger .text-white,
.card.bg-purple .text-white {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ==========================================
   按钮 - 二次元风格
   ========================================== */
.btn-primary,
.btn-info,
.btn-success,
.btn-danger {
    border: none;
    border-radius: var(--theme-border-radius);
}

.btn-primary {
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-secondary));
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-info {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    box-shadow: 0 4px 15px rgba(67, 233, 123, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #fa709a, #fee140);
    box-shadow: 0 4px 15px rgba(250, 112, 154, 0.3);
}

/* 标签按钮 */
.btn-outline-primary,
.btn-outline-info {
    background: transparent;
    border: 2px solid rgba(102, 126, 234, 0.3);
    color: var(--theme-primary);
    border-radius: 24px;
    font-weight: 600;
}

.btn-outline-primary:hover,
.btn-outline-info:hover {
    background: var(--theme-primary-light);
    border-color: #a78bfa;
}

.btn-outline-primary.active,
.btn-outline-info.active {
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-secondary));
    border-color: transparent;
    color: #fff;
}

/* ==========================================
   表格 - 清新风格
   ========================================== */
.table {
    background: rgba(255, 255, 255, 0.85);
    border-radius: var(--theme-border-radius);
    overflow: hidden;
}

.table thead th {
    background: rgba(148, 163, 184, 0.15);
    border-bottom: 2px solid var(--theme-border);
    color: var(--theme-text);
    font-weight: 700;
}

.table tbody tr:hover {
    background: rgba(94, 114, 228, 0.08);
}

/* ==========================================
   表单 - 圆角风格
   ========================================== */
.form-control {
    background: var(--theme-glass-bg);
    border: 2px solid var(--theme-border);
    border-radius: var(--theme-border-radius);
    color: var(--theme-text);
}

.form-control:focus {
    background: linear-gradient(135deg, #fff, #f8f7ff);
    border-color: #7c3aed;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

/* 搜索框特殊样式 */
.form-control[type="search"],
input[placeholder*="搜索"],
input[placeholder*="检索"] {
    background: linear-gradient(135deg, #fff, #f8f7ff);
    border: 2px solid rgba(102, 126, 234, 0.2);
    box-shadow: inset 0 2px 4px rgba(102, 126, 234, 0.05);
}

/* ==========================================
   导航栏 & 下拉菜单 - 毛玻璃效果
   ========================================== */
.navbar,
.dropdown-menu {
    background: var(--theme-glass-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--theme-glass-border);
    box-shadow: 0 4px 20px rgba(31, 38, 135, 0.08);
}

.dropdown-menu {
    border-radius: var(--theme-border-radius);
    box-shadow: 0 8px 32px var(--theme-shadow);
}

/* Keep topbar account/search dropdowns above dashboard cards. */
.topbar,
#nav.topbar {
    position: relative;
    z-index: 1100;
    overflow: visible;
}

.topbar .navbar-nav,
.topbar .nav-item,
.topbar .dropdown {
    overflow: visible;
}

.topbar .dropdown-menu {
    z-index: 1200;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--theme-primary-light);
    color: var(--theme-primary);
    border-radius: 8px;
}

/* ==========================================
   模态框 - 毛玻璃效果
   ========================================== */
.modal-content {
    background: var(--theme-glass-bg);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(31, 38, 135, 0.15);
}

/* ==========================================
   装饰元素 - 简约风格
   ========================================== */
h1, h2, h3, h4, h5, h6 {
    position: relative;
}

.text-primary {
    color: #5e72e4;
}

/* 徽章样式 */
.badge-primary {
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-secondary));
}

.badge-success {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
}

.badge-danger {
    background: linear-gradient(135deg, #fa709a, #fee140);
}

/* 状态标签 */
.badge-success,
.text-success {
    background: linear-gradient(135deg, rgba(67, 233, 123, 0.15), rgba(56, 249, 215, 0.15));
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
}

.badge-danger,
.text-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(245, 158, 11, 0.15));
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
}

/* 侧边栏图标不套标签样式 */
.sidebar-dark .nav-item .nav-link i.text-danger {
    background: transparent;
    border: none;
    padding: 0;
    border-radius: 0;
    font-weight: normal;
}

/* 进度条 */
.progress {
    background: rgba(148, 163, 184, 0.15);
    border-radius: 10px;
}

.progress-bar {
    background: linear-gradient(90deg, var(--theme-primary), var(--theme-secondary));
    border-radius: 10px;
}

/* Request ranking bars stay static and fill from left to right. */
#progress .progress {
    overflow: hidden;
}

#progress .progress-bar {
    background-image: none !important;
    animation: none !important;
    transition: none !important;
}

/* 分页 */
.page-item.active .page-link {
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-secondary));
    border-color: transparent;
    border-radius: 8px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.page-link {
    border-radius: 8px;
    margin: 0 2px;
    border: none;
    color: #5e72e4;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.8);
}

.page-link:hover {
    background: rgba(102, 126, 234, 0.15);
    color: var(--theme-primary);
}

/* 警告框 */
.alert {
    border-radius: var(--theme-border-radius);
    border: none;
}

.alert-primary {
    background: var(--theme-primary-light);
    color: #5e72e4;
}

.alert-success {
    background: linear-gradient(135deg, rgba(67, 233, 123, 0.1), rgba(56, 249, 215, 0.1));
    color: #27ae60;
}

.alert-danger {
    background: linear-gradient(135deg, rgba(250, 112, 154, 0.1), rgba(254, 225, 64, 0.1));
    color: #e74c3c;
}

/* 折叠面板 */
.collapse-inner {
    background: rgba(30, 40, 90, 0.55);
    border-radius: var(--theme-border-radius);
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.collapse-item {
    border-radius: 8px;
    padding: 10px 14px;
    margin: 3px 0;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.collapse-item:hover,
.collapse-item.active {
    background: rgba(255, 255, 255, 0.2);
}

.collapse-item.active {
    font-weight: 600;
}

.collapse-item i {
    margin-right: 8px;
}

.collapse-item:hover i,
.collapse-item.active i {
    color: #c4b5fd;
}

.collapse-header {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 14px 4px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.collapse-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin: 8px 12px;
}

/* 页面标题区域 */
h6.m-0.text-primary,
h6.text-primary {
    display: inline-block;
    padding-bottom: 8px;
}

h6.m-0.text-primary::after,
h6.text-primary::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--theme-primary), #a78bfa, transparent);
    border-radius: 2px;
}

/* 图标容器 */
.img-avatar,
.img-avatar-48 {
    background: var(--theme-primary-light);
    border: 2px solid rgba(102, 126, 234, 0.2);
}

/* 图表区域 */
.chart-area,
.chart-pie {
    position: relative;
}

/* 加载动画 */
.fa-spinner {
    color: #a78bfa;
}

/* ==========================================
   页脚
   ========================================== */
footer {
    background: transparent;
}

footer .container {
    background: rgba(255, 255, 255, 0.7);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-radius: var(--theme-border-radius) var(--theme-border-radius) 0 0;
    padding: 1rem;
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    letter-spacing: 0.5px;
}

footer a {
    color: var(--theme-primary);
    text-decoration: none;
}

footer a:hover {
    color: var(--theme-secondary);
}

/* ==========================================
   交互优化
   ========================================== */
/* 禁止接口请求排名文字被选中 */
#progress h4,
#progress span,
#progress a,
#progress .progress,
#progress .progress-bar {
    user-select: none;
    cursor: default;
}

/* 隐藏回到顶部浮动按钮 */
.scroll-to-top {
    display: none;
}

/* 隐藏浮动光点装饰 */
#content-wrapper::before,
#content-wrapper::after {
    display: none;
}

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

::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #a78bfa, var(--theme-primary));
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #8b5cf6, #5e72e4);
}

/* ==========================================
   响应式优化
   ========================================== */
@media (max-width: 768px) {
    .card {
        border-radius: var(--theme-border-radius);
    }
    
    .sidebar-dark .nav-item .nav-link {
        border-radius: 0 8px 8px 0;
    }
    
    #content::before,
    #content::after {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .sidebar-dark .nav-item .nav-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 0.5rem;
        text-align: center;
        border-radius: 8px;
        width: auto;
    }

    .sidebar-dark .nav-item .nav-link i {
        margin: 0 0 4px 0;
    }

    .sidebar-dark .nav-item .nav-link span {
        margin: 0;
    }
}

@media (min-width: 768px) {
    .sidebar.toggled .nav-item .nav-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        margin: 6px auto;
        padding: 0.5rem;
        text-align: center;
        border-radius: 8px;
        width: calc(100% - 12px);
    }

    .sidebar.toggled .nav-item .nav-link i {
        margin: 0 0 4px 0;
    }

    .sidebar.toggled .nav-item .nav-link span {
        margin: 0;
    }
}

/* 仪表盘统计卡片数字右对齐 */
.card .card-body .float-right .h4 {
    text-align: right;
}

/* 仪表盘统计卡片标题文字加大 */
.card .card-body .float-right .text-xs {
    font-size: 0.8rem !important;
}

/* ==========================================
   手机端弹窗防导航栏遮挡
   ========================================== */
@media (max-width: 991px) {
    /* 弹窗容器加顶部内边距，把内容推到导航栏下方 */
    .modal {
        padding-top: 90px !important;
    }
    /* 取消 modal-dialog-centered 垂直居中 */
    .modal-dialog.modal-dialog-centered {
        align-items: flex-start !important;
        margin-top: 0 !important;
    }
}
