/* AnRui Bio - Product List Page Styles */

/* 整体页面固定,不滚动 */
body.products-page {
    padding-top: 70px;
    overflow: hidden; /* 禁止整体页面滚动 */
    height: 100vh; /* 固定视口高度 */
}

/* 主容器 - 使用flexbox布局 */
.products-main-container {
    height: calc(100vh - 70px); /* 减去顶部导航栏高度 */
    overflow: hidden; /* 禁止容器滚动 */
    display: flex;
    flex-direction: column;
}

.products-main-container > .row {
    flex: 1;
    overflow: hidden;
    margin: 0;
}

/* 左侧列和右侧列的基本设置 */
.sidebar-column,
.products-column {
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 区域1: 左侧分类侧边栏 - 内部滚动 */
.category-sidebar {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1.5rem;
    height: 100%; /* 填满左侧列 */
    overflow-y: auto; /* 内部滚动 */
    /* 自定义滚动条样式 */
    scrollbar-width: thin;
    scrollbar-color: #667eea #f8f9fa;
}

.category-sidebar::-webkit-scrollbar {
    width: 6px;
}

.category-sidebar::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 3px;
}

.category-sidebar::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
    transition: background 0.3s ease;
}

.category-sidebar::-webkit-scrollbar-thumb:hover {
    background: #5a6fd8;
}

/* 鼠标悬停时的自动滚动区域 */
.category-sidebar:hover {
    scroll-behavior: smooth;
}

/* 改善category-sidebar的相对定位 */

.sidebar-header {
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 1rem;
}

.sidebar-header h5 {
    color: #667eea;
    margin-bottom: 0;
}

.category-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    color: #495057;
    transition: all 0.3s ease;
    font-weight: 500;
    /* 增加内边距以适应更长的分类名称 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    /* 允许flex项目收缩 */
}

.category-item span {
    /* 确保分类名称有足够空间显示 */
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.category-item:hover {
    background: #e3f2fd;
    border-color: #667eea;
    color: #667eea;
    transform: translateX(5px);
}

.category-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    transform: translateX(5px);
}

.category-item.active .badge {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white;
}

.category-item i {
    font-size: 1.1rem;
    opacity: 0.8;
    flex-shrink: 0;
}

.category-item.active i {
    opacity: 1;
}


/* 区域2: 右上固定区域 (标题 + 搜索框) - 不滚动 */
.fixed-header-container {
    flex-shrink: 0; /* 不允许收缩 */
    background: white;
    z-index: 10;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
}

/* Header Box */
.header-box {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
    border: 1px solid #f0f0f0;
    padding: 1rem 1.25rem;
    margin-bottom: 0;
}

@media (max-width: 767.98px) {
    .header-box {
        padding: 1rem 0.5rem;
        border-radius: 0.5rem;
    }
}

/* 区域3: 右下产品列表区域 - 内部滚动 */
.products-content-area {
    flex: 1; /* 填充剩余空间 */
    overflow-y: auto; /* 内部滚动 */
    padding: 1rem;
    
    /* 美化滚动条 */
    scrollbar-width: thin;
    scrollbar-color: #667eea #f8f9fa;
}

.products-content-area::-webkit-scrollbar {
    width: 8px;
}

.products-content-area::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.products-content-area::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.products-content-area::-webkit-scrollbar-thumb:hover {
    background: #5a6fd8;
}

/* Page Header - 减少内边距 */
.page-header {
    padding: 0.5rem 0; /* 从1rem减少到0.5rem */
    margin-bottom: 0.75rem; /* 从1rem减少到0.75rem */
}

.header-left .page-title {
    color: #667eea;
    font-weight: 700;
    margin-bottom: 0;
}

.header-right {
    flex-wrap: wrap;
    gap: 1rem;
}

.product-count-badge {
    background: #17a2b8;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Search Section - 减少间距 */
.search-section {
    margin-bottom: 0.75rem; /* 从1rem减少到0.75rem */
}

.search-input-group {
    max-width: 500px;
}

.search-input-group .input-group-text {
    background: #f8f9fa;
    border-right: none;
    color: #667eea;
}

.search-input-group .form-control {
    border-left: none;
    padding-left: 0;
}

.search-input-group .form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Product Grid */
.products-grid {
    margin-bottom: 3rem;
}

.product-item {
    margin-bottom: 1.5rem;
}

.product-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    transition: all 0.3s ease;
    height: 100%;
    overflow: hidden;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* Clickable product card link styling */
.product-item a {
    color: inherit;
    text-decoration: none !important;
}

.product-item a:hover {
    color: inherit;
}

.product-item a:hover .product-title {
    color: #5a6fd8;
}

.product-card .card-body {
    padding: 1.5rem;
}

.product-title {
    color: #667eea;
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    line-height: 1.4;
}

.product-title i {
    margin-right: 0.5rem;
    color: #28a745;
}

/* Product Information Badges */
.product-info {
    margin-bottom: 1rem;
}

.product-badge {
    display: inline-block;
    margin-bottom: 0.5rem;
}

.product-badge .badge {
    font-size: 0.75rem;
    padding: 0.4rem 0.7rem;
    margin-right: 0.5rem;
}

.product-code {
    font-family: 'Courier New', monospace;
    background: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #495057;
}

/* No Info State */
.no-info {
    color: #6c757d;
    font-style: italic;
    font-size: 0.9rem;
}

.no-info i {
    margin-right: 0.5rem;
}

/* Card Footer */
.product-card .card-footer {
    background: transparent;
    border-top: 1px solid #f1f3f4;
    padding: 1rem 1.5rem;
}

.view-details-btn {
    font-size: 0.875rem;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.view-details-btn:hover {
    transform: translateX(2px);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #6c757d;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: #495057;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 1.1rem;
    max-width: 400px;
    margin: 0 auto;
}

/* Loading State */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

/* Product Categories Filter (for future use) */
.category-filter {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.category-btn {
    margin: 0.25rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
}

/* Responsive Design - 移动端布局 */
@media (max-width: 768px) {
    body.products-page {
        padding-top: 60px;
        overflow: hidden;
    }

    .products-main-container {
        height: calc(100vh - 60px);
        overflow: hidden;
        padding: 0;
    }

    /* Row作为flex容器 */
    .products-main-container > .row {
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        margin: 0;
    }

    /* Products Column - 第一个显示 */
    .products-column {
        order: 1;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0;
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
    }

    /* 区域2: 搜索模块 - 固定在顶部 */
    .fixed-header-container {
        flex-shrink: 0; /* 固定,不收缩 */
        padding: 0.75rem 0.5rem;
        margin-bottom: 0;
        border-bottom: 2px solid #e9ecef;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
        background: white;
        z-index: 10;
    }

    .header-box {
        padding: 0.75rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    }

    /* 产品列表区域 - 可滚动 */
    .products-content-area {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 0;
    }

    /* 区域3: 分类列表 - 第二个显示 */
    .sidebar-column {
        order: 2;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0;
        flex-shrink: 0;
    }

    .category-sidebar {
        height: auto;
        max-height: none;
        overflow: visible;
        margin: 0.75rem 0.5rem;
        border-radius: 8px;
        padding: 0.75rem;
        background: #f8f9fa;
    }

    /* 产品网格 */
    .products-grid {
        margin: 0;
        padding: 0.5rem;
    }

    .products-grid > [class*='col-'] {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0.25rem;
    }

    .product-card .card-body {
        padding: 0.875rem;
    }

    .product-title {
        font-size: 0.95rem;
        line-height: 1.3;
    }

    .product-count-badge {
        font-size: 0.75rem;
        padding: 0.35rem 0.7rem;
    }

    .search-section {
        margin-bottom: 0.5rem;
    }

    .search-input-group {
        max-width: 100%;
    }

    .search-input-group .form-control {
        font-size: 0.9rem;
    }

    /* 分类项移动端优化 */
    .category-item {
        padding: 0.65rem !important;
        font-size: 0.85rem;
        margin-bottom: 0.4rem !important;
    }

    .category-item i {
        font-size: 0.95rem;
    }

    .category-item .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    /* 当分类折叠时,减少sidebar的外边距,避免空白 */
    .category-sidebar:has(.category-list:not(.show)) {
        margin: 0.25rem 0.5rem !important; /* 折叠时减小所有边距 */
        padding: 0.5rem 0.75rem !important; /* 减小内边距 */
    }
}

@media (max-width: 576px) {
    body.products-page {
        padding-top: 60px;
        height: 100vh;
        overflow: hidden;
    }

    .products-main-container {
        height: calc(100vh - 60px);
    }

    /* 区域1: 分类侧边栏 - 更小的高度 */
    .category-sidebar {
        max-height: 140px; /* 小屏幕进一步限制 */
        padding: 0.5rem;
    }

    /* 区域3和2: 搜索和产品列表 */
    .fixed-header-container {
        padding: 0.5rem;
    }

    .header-box {
        padding: 0.5rem;
    }

    .products-content-area {
        padding: 0.35rem;
    }

    .product-item {
        margin-bottom: 0.75rem;
        padding: 0.2rem;
    }

    .product-card .card-body {
        padding: 0.65rem;
    }

    .product-title {
        font-size: 0.9rem;
    }

    .empty-state {
        padding: 1.5rem 0.75rem;
    }

    .empty-state-icon {
        font-size: 2.5rem;
    }

    .category-item {
        padding: 0.5rem !important;
        font-size: 0.8rem;
    }

    .category-item i {
        font-size: 0.9rem;
    }
}

/* Animation for search results */
.product-item.hidden {
    display: none;
}

.product-item.visible {
    display: block;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.side-badge {
    max-width: 50px;
}