/*
 * Bootstrap Override Styles
 * 用于覆盖Bootstrap默认样式，解决与主题样式的冲突
 * Version: 1.0.0
 */

/* ===== 全局覆盖 ===== */
/* 重置Bootstrap的box-sizing对主题元素的影响 */
.page-container *,
.sidebar-menu *,
.main-content * {
    box-sizing: border-box !important;
}

/* 覆盖Bootstrap的body样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    font-size: 16px !important;
    line-height: 1.6 !important;
    color: #333 !important;
    background-color: #f9f9f9 !important;
}

/* ===== 容器覆盖 ===== */
/* 防止Bootstrap容器影响主题布局 */
.page-container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

.main-content {
    padding: 0 !important;
}

/* Bootstrap容器在主题内的特定处理 */
.main-content .container,
.main-content .container-fluid {
    padding-left: 15px;
    padding-right: 15px;
}

/* ===== 导航覆盖 ===== */
/* 防止Bootstrap nav类影响侧边栏 */
.sidebar-menu ul,
.sidebar-menu li {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.sidebar-menu a {
    text-decoration: none !important;
    color: inherit !important;
}

.sidebar-menu .nav {
    display: block !important;
    flex-wrap: nowrap !important;
}

/* ===== 按钮覆盖 ===== */
/* 保持主题按钮样式不受Bootstrap影响 */
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-warning,
.btn-info {
    border-radius: 4px !important;
    font-weight: 500 !important;
    transition: all 0.3s ease !important;
}

/* ===== 表单覆盖 ===== */
/* 统一表单元素样式 */
.form-control {
    border-radius: 4px !important;
    border: 1px solid #e4ecf3 !important;
    font-size: 14px !important;
    padding: 8px 12px !important;
}

.form-control:focus {
    border-color: #4285f4 !important;
    box-shadow: 0 0 0 0.2rem rgba(66, 133, 244, 0.25) !important;
}

/* ===== 卡片覆盖 ===== */
/* 网站卡片样式保护 - 移除会阻止其他样式生效的!important */
.xe-widget,
.site-card,
.url-card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.xe-widget:hover,
.site-card:hover,
.url-card:hover {
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

/* 允许homepage-grid.css中的xe-card样式生效 */
.xe-card {
    /* 不设置任何样式，让homepage-grid.css控制 */
}

/* ===== 网格系统覆盖 ===== */
/* 确保Bootstrap网格不破坏主题布局 */
.row {
    margin-left: -10px !important;
    margin-right: -10px !important;
}

.col, [class*="col-"] {
    padding-left: 10px !important;
    padding-right: 10px !important;
}

/* ===== 文本样式覆盖 ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600 !important;
    line-height: 1.2 !important;
    color: #333 !important;
}

p {
    margin-bottom: 1rem !important;
    color: #555 !important;
}

a {
    color: #1a1a1a !important;
    transition: color 0.3s ease !important;
}

a:hover {
    color: #000 !important;
    text-decoration: none !important;
}

/* ===== 工具类覆盖 ===== */
/* 防止Bootstrap工具类影响主题元素 */
.sidebar-menu .d-none,
.sidebar-menu .d-block {
    display: inherit !important;
}

/* ===== 响应式覆盖 ===== */
@media (max-width: 768px) {
    /* 移动端特定覆盖 */
    .container,
    .container-sm {
        max-width: 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* 防止Bootstrap响应式类破坏移动端布局 */
    .sidebar-menu {
        width: 250px !important;
    }
    
    .sidebar-menu.mobile-open {
        transform: translateX(0) !important;
    }
}

/* ===== Modal覆盖 ===== */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5) !important;
}

.modal-content {
    border-radius: 8px !important;
    border: none !important;
}

/* ===== Table覆盖 ===== */
.table {
    color: #333 !important;
}

.table thead th {
    border-bottom: 2px solid #e4ecf3 !important;
    font-weight: 600 !important;
}

/* ===== Alert覆盖 ===== */
.alert {
    border-radius: 4px !important;
    border: none !important;
}

/* ===== Badge覆盖 ===== */
.badge {
    font-weight: 500 !important;
    padding: 4px 8px !important;
}

/* ===== 特定组件保护 ===== */
/* 保护主题核心组件不受Bootstrap影响 */
.sidebar-menu,
.sidebar-menu * {
    font-size: inherit !important;
    line-height: inherit !important;
}

.hero-section,
.hero-section * {
    margin: 0 !important;
    padding: 0 !important;
}

.category-tabs,
.category-tabs * {
    list-style: none !important;
}

/* ===== Z-index层级管理 ===== */
.sidebar-menu {
    z-index: 1000 !important;
}

.mobile-menu-toggle {
    z-index: 1001 !important;
}

.modal {
    z-index: 1050 !important;
}

.modal-backdrop {
    z-index: 1040 !important;
}

/* ===== 清除浮动 ===== */
.clearfix::after {
    content: "";
    display: table;
    clear: both;
}