/* Admin Panel Global Styles - 修复侧边栏布局问题 */

/* 重置默认样式 */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* 侧边栏样式 */
.sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 250px !important;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
    background-color: #ffffff !important;
    border-right: 1px solid #dee2e6 !important;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

/* 侧边栏折叠状态 */
.sidebar.collapsed {
    transform: translateX(-200px);
}

/* 侧边栏边缘折叠按钮 */
.sidebar-collapse-btn {
    position: absolute;
    top: 50%;
    right: -15px;
    width: 30px;
    height: 30px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transform: translateY(-50%);
    transition: all 0.3s ease;
}

.sidebar-collapse-btn:hover {
    background: #0056b3;
    transform: translateY(-50%) scale(1.1);
}

.sidebar.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

/* 展开按钮样式（当侧边栏折叠时显示） */
#expandButton {
    position: fixed;
    top: 50%;
    left: 15px;
    width: 40px;
    height: 40px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1002;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transform: translateY(-50%);
    transition: all 0.3s ease;
}

#expandButton:hover {
    background: #0056b3;
    transform: translateY(-50%) scale(1.1);
}

/* 主内容区域 - 为所有管理页面设置正确的边距 */
.admin-main-content,
.voucher-main-content,
.main-content {
    margin-left: 250px !important;
    padding: 20px;
    min-height: 100vh;
    width: calc(100vw - 250px) !important;
    overflow-x: auto;
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* 侧边栏折叠时的主内容区域 */
.sidebar.collapsed ~ .main-content,
.sidebar.collapsed ~ .admin-main-content,
.sidebar.collapsed ~ .voucher-main-content {
    margin-left: 50px !important;
    width: calc(100vw - 50px) !important;
}

/* 特殊情况：d-flex 布局的修复 */
.d-flex .sidebar + main,
.d-flex .sidebar + .main-content,
.d-flex .sidebar + .admin-main-content {
    margin-left: 250px !important;
    width: calc(100vw - 250px) !important;
    flex: none !important;
}

/* 确保容器不会被侧边栏遮挡 */
.container-fluid {
    padding-left: 15px;
    padding-right: 15px;
    max-width: 100%;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .admin-main-content,
    .voucher-main-content,
    .main-content,
    .d-flex .sidebar + main,
    .d-flex .sidebar + .main-content,
    .d-flex .sidebar + .admin-main-content {
        margin-left: 0 !important;
        width: 100vw !important;
    }
}

/* 覆盖Bootstrap的flex样式 */
.d-flex {
    display: block !important;
}

/* 修复文字对比度问题 */
.text-muted {
    color: #495057 !important; /* 深灰色替代浅灰色 */
}

.text-secondary {
    color: #495057 !important; /* 深灰色替代浅灰色 */
}

/* 公司颜色标识 */
.company-shenze {
    background-color: #0d6efd !important; /* 申泽蓝色 */
    color: white !important;
}

.company-caiyunjuan {
    background-color: #dc3545 !important; /* 彩云卷红色 */
    color: white !important;
}

.border-company-shenze {
    border-color: #0d6efd !important;
}

.border-company-caiyunjuan {
    border-color: #dc3545 !important;
}

.text-company-shenze {
    color: #0d6efd !important;
}

.text-company-caiyunjuan {
    color: #dc3545 !important;
}

/* 确保所有表格内容有足够对比度 */
.table td, .table th {
    color: #212529 !important; /* 深色文字 */
}

.table-striped > tbody > tr:nth-of-type(odd) > td,
.table-striped > tbody > tr:nth-of-type(odd) > th {
    background-color: rgba(0,0,0,.02) !important;
    color: #212529 !important;
}

/* 卡片内容对比度修复 */
.card-text {
    color: #495057 !important;
}

.small {
    color: #495057 !important;
}

/* 修复统计卡片中的文字对比度 */
.card-body .text-muted,
.card-body .text-secondary {
    color: #495057 !important;
}

/* 修复表格中选中行的对比度 */
.table-hover tbody tr:hover td,
.table-hover tbody tr:hover th {
    background-color: rgba(0,0,0,.075) !important;
    color: #212529 !important;
}

/* 修复按钮和徽章的对比度 */
.badge {
    color: white !important;
}

.btn {
    color: white !important;
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-danger,
.btn-outline-warning,
.btn-outline-info {
    color: #212529 !important;
}

.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-success:hover,
.btn-outline-danger:hover,
.btn-outline-warning:hover,
.btn-outline-info:hover {
    color: white !important;
}

/* 修复表格行选中时的对比度 */
tbody tr:hover,
tbody tr:focus {
    background-color: rgba(0,0,0,.075) !important;
    color: #212529 !important;
}

/* 修复空状态文字 */
.text-muted {
    color: #495057 !important;
}

/* 修复按钮和链接的对比度 */
a, a:visited {
    color: #0d6efd !important;
}

a:hover, a:focus {
    color: #0a58ca !important;
}

/* 修复表单控件的对比度 */
.form-control, .form-select {
    color: #212529 !important;
    background-color: #fff !important;
    border: 1px solid #ced4da !important;
}

.form-control:focus, .form-select:focus {
    color: #212529 !important;
    background-color: #fff !important;
    border-color: #86b7fe !important;
}

.form-control::placeholder {
    color: #6c757d !important;
}

/* 修复筛选区域的标签和按钮 */
.form-label {
    color: #212529 !important;
    font-weight: 500 !important;
}

/* 修复outline按钮的对比度 */
.btn-outline-primary {
    color: #0d6efd !important;
    border-color: #0d6efd !important;
    background-color: transparent !important;
}

.btn-outline-secondary {
    color: #6c757d !important;
    border-color: #6c757d !important;
    background-color: transparent !important;
}

.btn-outline-primary:hover {
    color: #fff !important;
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

.btn-outline-secondary:hover {
    color: #fff !important;
    background-color: #6c757d !important;
    border-color: #6c757d !important;
}

/* 修复卡片标题和内容的对比度 */
.card-header {
    color: #212529 !important;
}

.card-body {
    color: #212529 !important;
}

/* 修复列表项的对比度 */
li, ul, ol {
    color: #212529 !important;
}

/* 修复所有文本的基础对比度 */
body, p, span, div {
    color: #212529 !important;
}

/* 特别修复白色背景上的浅色文字 */
.bg-light, .bg-white {
    color: #212529 !important;
}

.bg-light *, .bg-white * {
    color: #212529 !important;
}

/* 白色主题样式 */
body {
    background-color: #ffffff !important;
    color: #212529 !important;
}

/* 侧边栏白色主题 */
.sidebar {
    background-color: #ffffff !important;
    border-right: 1px solid #dee2e6 !important;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.sidebar .nav-link {
    color: #495057 !important;
    border-radius: 6px;
    margin: 2px 0;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background-color: #f8f9fa !important;
    color: #0d6efd !important;
}

.sidebar .nav-link i {
    color: #6c757d !important;
}

.sidebar .nav-link:hover i,
.sidebar .nav-link.active i {
    color: #0d6efd !important;
}

/* 顶部导航栏白色主题 */
.navbar {
    background-color: #ffffff !important;
    border-bottom: 1px solid #dee2e6 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar .navbar-brand {
    color: #212529 !important;
}

.navbar .nav-link {
    color: #495057 !important;
}

.navbar .nav-link:hover {
    color: #0d6efd !important;
}

/* 卡片白色主题 */
.card {
    background-color: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.card-header {
    background-color: #f8f9fa !important;
    border-bottom: 1px solid #dee2e6 !important;
    color: #212529 !important;
}

/* 主内容区域白色主题 */
.main-content {
    background-color: #ffffff !important;
    min-height: 100vh;
}

/* 修复深色主题遗留问题 */
.bg-dark, .navbar-dark, .sidebar-dark {
    background-color: #ffffff !important;
    color: #212529 !important;
}

.text-white {
    color: #212529 !important;
}

/* 侧边栏链接样式 */
.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar li {
    margin: 0;
}

.sidebar a {
    display: block;
    padding: 12px 20px;
    color: #495057 !important;
    text-decoration: none;
    border-radius: 6px;
    margin: 2px 8px;
    transition: all 0.3s ease;
}

.sidebar a:hover,
.sidebar a.active {
    background-color: #f8f9fa !important;
    color: #0d6efd !important;
    text-decoration: none;
}

.sidebar a i {
    color: #6c757d !important;
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.sidebar a:hover i,
.sidebar a.active i {
    color: #0d6efd !important;
}

.sidebar-header {
    padding: 20px;
    background-color: #f8f9fa !important;
    border-bottom: 1px solid #dee2e6 !important;
}

.sidebar-header h4 {
    color: #212529 !important;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

/* 确保表格和卡片正确显示 */
.table-responsive {
    margin-left: 0;
    width: 100%;
}

.card {
    width: 100%;
    margin-bottom: 20px;
}

/* 修复按钮和表单元素 */
.btn-group,
.form-control,
.input-group {
    max-width: 100%;
}