/*
 * 首页网格布局样式 - 优化版
 * 统一使用CSS Grid，移除重复的媒体查询
 * Version: 2.0.0
 */

/* ===== 基础网格容器样式 ===== */
.sites-list {
    margin: 0;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
    background: transparent;
}

.latest-sites-container,
.category-tabs-container {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: transparent;
    border-radius: 8px;
    position: relative;
    z-index: 1;
}

/* ===== 统一网格布局 - 使用CSS Grid ===== */
.sites-list .row,
.latest-sites-container .row,
.category-tabs-container .row,
.taxonomy-favorites .row,
.fav-content .row,
.fav-content-with-parent .row,
.sub-category-contents .row,
.tab-content .row,
.row:has(.xe-card) {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin: 0;
    grid-auto-flow: row dense;
    align-items: start;
    justify-items: stretch;
}

/* 移除Bootstrap的列样式影响 */
.sites-list .row [class*="col-"],
.latest-sites-container .row [class*="col-"],
.category-tabs-container .row [class*="col-"],
.taxonomy-favorites .row [class*="col-"],
.fav-content .row [class*="col-"],
.fav-content-with-parent .row [class*="col-"] {
    flex: unset !important;
    max-width: unset !important;
    width: unset !important;
    padding: unset !important;
    margin: unset !important;
    float: unset !important;
    position: relative !important;
    display: block !important;
}

/* ===== 网站卡片样式 ===== */
.xe-card {
    position: relative;
    height: 70px;
    margin: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    overflow: hidden;
    width: 100%;
    display: block;
}

.xe-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 2;
}

/* 卡片内容容器 */
.xe-widget.xe-conversations {
    position: absolute;
    background: transparent;
    margin: 0;
    padding: 10px;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
    z-index: 1; /* 确保链接在最上层 */
    cursor: pointer; /* 显示手型光标 */
}

/* 卡片内容布局 */
.xe-widget.xe-conversations .xe-comment-entry {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    flex-direction: row;
}

/* 网站图标样式 */
.xe-user-img {
    float: none;
    display: block;
    background: #f8f9fa;
    margin-right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid #e9ecef;
}

.xe-user-img img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* 网站信息样式 */
.xe-comment {
    flex: 1;
    margin-left: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.xe-user-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    font-size: 16px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.xe-comment p {
    margin: 0;
    color: #6c757d;
    font-size: 14px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== 分类标题样式 ===== */
.parent-category-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 1rem 0;
    padding: 0;
    display: flex;
    align-items: center;
}

.parent-category-title i {
    font-size: 1.5rem;
    margin-right: 12px;
    color: #a27dff;
}

/* ===== 响应式布局 - 统一管理 ===== */

/* 大屏幕 - 3列 */
@media (max-width: 1200px) {
    .sites-list .row,
    .latest-sites-container .row,
    .category-tabs-container .row,
    .taxonomy-favorites .row,
    .fav-content .row,
    .fav-content-with-parent .row,
    .sub-category-contents .row,
    .tab-content .row,
    .row:has(.xe-card) {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
    }
}

/* 平板端 - 2列 */
@media (max-width: 992px) {
    .sites-list .row,
    .latest-sites-container .row,
    .category-tabs-container .row,
    .taxonomy-favorites .row,
    .fav-content .row,
    .fav-content-with-parent .row,
    .sub-category-contents .row,
    .tab-content .row,
    .row:has(.xe-card) {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px;
    }
}

/* 移动端横屏 - 2列 */
@media (max-width: 768px) {
    .sites-list {
        padding: 15px;
    }
    
    .latest-sites-container,
    .category-tabs-container {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .sites-list .row,
    .latest-sites-container .row,
    .category-tabs-container .row,
    .taxonomy-favorites .row,
    .fav-content .row,
    .fav-content-with-parent .row,
    .sub-category-contents .row,
    .tab-content .row,
    .row:has(.xe-card) {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px;
    }
    
    .xe-card {
        height: 65px;
    }
    
    .xe-widget.xe-conversations {
        padding: 8px;
    }
    
    .xe-user-img {
        width: 32px;
        height: 32px;
        margin-right: 8px;
    }
    
    .xe-user-name {
        font-size: 15px;
        margin-bottom: 3px;
    }
    
    .xe-comment p {
        font-size: 13px;
    }
    
    .parent-category-title {
        font-size: 16px;
    }
    
    .parent-category-title i {
        font-size: 1.3rem;
        margin-right: 10px;
    }
}

/* 手机端竖屏 - 2列 */
@media (max-width: 480px) {
    .sites-list {
        padding: 10px;
    }
    
    .latest-sites-container,
    .category-tabs-container {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .sites-list .row,
    .latest-sites-container .row,
    .category-tabs-container .row,
    .taxonomy-favorites .row,
    .fav-content .row,
    .fav-content-with-parent .row,
    .sub-category-contents .row,
    .tab-content .row,
    .row:has(.xe-card) {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }
    
    .xe-card {
        height: 60px;
    }
    
    .xe-widget.xe-conversations {
        padding: 6px;
    }
    
    .xe-user-img {
        width: 28px;
        height: 28px;
        margin-right: 6px;
    }
    
    .xe-user-name {
        font-size: 14px;
        margin-bottom: 2px;
    }
    
    .xe-comment p {
        font-size: 12px;
    }
    
    .parent-category-title {
        font-size: 15px;
    }
}

/* 超小屏幕 - 单列（可选） */
@media (max-width: 360px) {
    .sites-list .row,
    .latest-sites-container .row,
    .category-tabs-container .row,
    .taxonomy-favorites .row,
    .fav-content .row,
    .fav-content-with-parent .row,
    .sub-category-contents .row,
    .tab-content .row,
    .row:has(.xe-card) {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
}

/* ===== 子分类标签样式 ===== */
.sub-category-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    margin: 2rem 0;
    padding: 0;
    border: none;
    background: #f8f9fa;
    border-radius: 25px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sub-tab {
    display: inline-block;
    padding: 10px 18px;
    background: transparent;
    color: #6c757d;
    text-decoration: none;
    border-radius: 0;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    user-select: none;
    white-space: nowrap;
    flex: 0 0 auto;
    text-align: center;
    position: relative;
    min-width: fit-content;
}

.sub-tab:hover {
    background: #f3f0ff;
    color: #a27dff;
}

.sub-tab.active {
    background: #a27dff;
    color: #fff;
}

/* 更多标签样式 */
.more-tabs {
    display: inline-block;
    padding: 10px 18px;
    background: transparent;
    color: #a27dff;
    text-decoration: none;
    border-radius: 0;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    flex: 0 0 auto;
    white-space: nowrap;
    position: relative;
    min-width: fit-content;
    border-left: 1px solid #dee2e6;
}

.more-tabs:hover {
    background: #a27dff;
    color: #fff;
}

/* ===== 分类标题和链接在一行显示 ===== */
.category-header-with-link {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 1rem;
    flex-wrap: nowrap !important;
    gap: 10px;
}

.category-header-with-link .parent-category-title {
    flex: 1 1 auto !important;
    margin: 0 !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.more-tabs-inline {
    flex: 0 0 auto !important;
    display: inline-block;
    padding: 6px 12px;
    background: #f8f9fa;
    color: #a27dff;
    text-decoration: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
    white-space: nowrap;
}

.more-tabs-inline:hover {
    background: #a27dff;
    color: #fff;
    border-color: #a27dff;
    text-decoration: none;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .category-header-with-link {
        gap: 8px !important;
    }
    
    .category-header-with-link .parent-category-title {
        font-size: 16px !important;
    }
    
    .more-tabs-inline {
        padding: 5px 10px !important;
        font-size: 13px !important;
        border-radius: 15px !important;
    }
}

@media (max-width: 480px) {
    .category-header-with-link {
        gap: 6px !important;
    }
    
    .category-header-with-link .parent-category-title {
        font-size: 15px !important;
    }
    
    .more-tabs-inline {
        padding: 4px 8px !important;
        font-size: 12px !important;
        border-radius: 12px !important;
    }
}

/* ===== 清理和优化 ===== */
* {
    box-sizing: border-box;
}

/* 防止文本溢出 */
.overflowClip_1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

/* 确保没有重叠的样式 */
.latest-sites-container,
.category-tabs-container,
.xe-card,
.xe-widget,
.xe-user-img,
.xe-comment {
    position: relative;
    z-index: auto;
}