/* 搜索结果样式 */

 body.search{
    padding-top: 100px;
 }

 body.search .page-header{
    margin-bottom: 40px;
 }
body.search .search-results {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

body.search .search-result-post,
body.search .search-result-product {
    background: var(--card-bg, #fff);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color, #e5e7eb);
}

body.search .result-type {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

body.search .post-type {
    background: #dbeafe;
    color: #1e40af;
}

body.search .product-type {
    background: #dcfce7;
    color: #166534;
}

body.search .search-result-post .entry-title,
body.search .search-result-product .entry-title {
    margin: 8px 0 16px;
    font-size: 1.5rem;
}

body.search .search-result-post .entry-title a,
body.search .search-result-product .entry-title a {
    color: var(--text-color);
    text-decoration: none;
}

body.search .search-result-post .entry-title a:hover,
body.search .search-result-product .entry-title a:hover {
    color: var(--primary-color, #0073aa);
}

body.search .product-category {
    color: var(--text-muted, #6b7280);
    font-size: 14px;
    margin-left: 8px;
}

/* 产品网格布局 */
body.search .product-search-section,
body.search .post-search-section {
    margin-bottom: 40px;
}

    body.search .product-search-section:last-child,
    body.search .post-search-section:last-child {
        margin-bottom: 0;
    }

body.search .product-search-section .results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

body.search .product-search-section .results-header .search-section-title {
    font-size: 1.5rem;
    margin: 0;
    display: flex;
    align-items: baseline;
    gap: 12px;
    text-align: center;
    position: relative;
    color: var(--primary-color);
}

body.search .product-search-section .results-count {
    font-size: 0.9rem;
    color: var(--text-muted, #6b7280);
    font-weight: 500;
}

body.search .product-search-section .view-more {
    color: var(--text-muted, #6b7280);
    text-decoration: none;
    font-size: 0.95rem;
}

body.search .posts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

/* 默认网格布局 - 大屏幕 */
body.search .product-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* 大屏幕6列 */
    gap: 16px; /* 减少间距，适合新的紧凑设计 */
    align-items: start;
}

body.search .product-preview-item {
    position: relative;
    text-align: center;
    background-color: #f8f8f8;
    border-radius: 8px;
    padding: 0;
    width: 100%;
    aspect-ratio: 1 / 1; /* 正方形布局 */
    transition: background-color 0.2s ease;
}

[data-theme="dark"] body.search .product-preview-item {
    background-color: #2a2a2a;
}

[data-theme="dark"] body.search .product-preview-item:hover {
    background-color: #333333;
}

body.search .product-preview-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 16px;
    box-sizing: border-box;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease;
}

body.search .product-preview-link:hover {
    transform: translateY(-4px);
}

body.search .product-preview-image {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    background-color: #f8f8f8;
}

[data-theme="dark"] body.search .product-preview-image {
    background-color: #2a2a2a;
}

body.search .product-preview-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s ease;
    background-color: transparent;
    display: block;
}

body.search .product-preview-link:hover .product-preview-image img {
    transform: scale(1.05);
}

body.search .product-preview-name {
    font-size: 14px;
    font-weight: 400;
    color: #1a1a1a;
    line-height: 1.4;
    margin-top: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
}

[data-theme="dark"] body.search .product-preview-name {
    color: #ffffff;
}

/* 搜索页面的产品卡片标题样式 - 与首页保持一致 */
body.search .product-card .product-title {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: #1a1a1a;
    font-weight: 500;
}

[data-theme="dark"] body.search .product-card .product-title {
    color: #ffffff;
}

/* 搜索页面产品卡片链接样式 - 移除下划线 */
body.search .product-card a,
body.search .product-card a:hover,
body.search .product-card a:focus,
body.search .product-card a:active {
    text-decoration: none;
}

/* 搜索页面产品图片暗色主题适配 */
[data-theme="dark"] body.search .product-image {
    background-color: #1a1a1a;
}

/* 无搜索结果样式 */
body.search .no-results {
    text-align: center;
    padding: 40px 20px;
    background: var(--card-bg, #fff);
    border-radius: 12px;
    border: 1px solid var(--border-color, #e5e7eb);
}

body.search .no-results p {
    font-size: 1.1rem;
    color: var(--text-muted, #6b7280);
    margin-bottom: 20px;
}


/* 响应式设计 */
@media (max-width: 1600px) {
    body.search .product-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 14px; /* 进一步减少间距 */
    }
}

@media (max-width: 1200px) {
    body.search .product-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
}

@media (max-width: 900px) {
    body.search .product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
}

@media (max-width: 768px) {
    body.search .search-result-post,
    body.search .search-result-product {
        padding: 16px;
    }

    body.search .search-results {
        gap: 20px; /* 减少间距 */
    }

    body.search .product-search-section,
    body.search .post-search-section {
        margin-bottom: 24px; /* 减少间距 */
    }

    body.search .product-search-section .results-header {
        margin-bottom: 16px; /* 减少间距 */
    }



    body.search .product-grid {
        gap: 12px; /* 减少间距 */
    }

    body.search .product-preview-link {
        padding: 12px; /* 调整内边距 */
    }
}

@media (max-width: 480px) {
    body.search .product-grid {
        grid-template-columns: 1fr;
        gap: 12px; /* 减少间距 */
    }

    body.search .search-results {
        gap: 16px; /* 减少间距 */
    }

    body.search .product-search-section {
        margin-bottom: 20px; /* 减少间距 */
    }

    body.search .product-preview-link {
        padding: 12px; /* 保持紧凑布局 */
    }

    body.search .product-preview-name {
        font-size: 13px; /* 小屏幕上稍微缩小字体 */
        margin-top: 6px;
    }
}

/* 搜索自动完成样式 */
.ui-autocomplete {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 9999;
    padding: 4px 0;
    margin-top: 10px;
    
}

[data-theme="dark"] .ui-autocomplete {
    background: var(--card-bg, #1f2937);
    border-color: var(--border-color, #374151);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ui-autocomplete .ui-menu-item {
    padding: 0;
    border: none;
}

.ui-autocomplete .ui-menu-item:hover,
.ui-autocomplete .ui-menu-item.ui-state-focus {
    background: var(--hover-bg, #f3f4f6);
}

[data-theme="dark"] .ui-autocomplete .ui-menu-item:hover,
[data-theme="dark"] .ui-autocomplete .ui-menu-item.ui-state-focus {
    background: var(--hover-bg, #374151);
}

.autocomplete-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

.autocomplete-item:hover {
    background: transparent; /* Let parent handle hover */
}

.autocomplete-label {
    font-weight: 500;
    color: var(--text-color, #111827);
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

[data-theme="dark"] .autocomplete-label {
    color: var(--text-color, #f9fafb);
}

.autocomplete-category {
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    background: var(--badge-bg, #f3f4f6);
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: capitalize;
    margin-left: 8px;
    flex-shrink: 0;
}

[data-theme="dark"] .autocomplete-category {
    background: var(--badge-bg, #374151);
    color: var(--text-muted, #9ca3af);
}

/* 搜索表单样式增强 */
.search-field {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-field:focus {
    border-color: var(--primary-color, #0073aa);
    box-shadow: 0 0 0 2px rgba(0, 113, 170, 0.1);
}

/* 响应式自动完成 */
@media (max-width: 768px) {
    .ui-autocomplete {
        max-height: 250px;
        border-radius: 6px;
        width: calc(100vw - 24px) !important;
        max-width: 280px;
    }

    .autocomplete-item {
        padding: 10px 12px;
    }

    .autocomplete-label {
        font-size: 13px;
    }

    .autocomplete-category {
        font-size: 11px;
        padding: 1px 4px;
    }
}

@media (max-width: 576px) {
    .ui-autocomplete {
        width: calc(100vw - 16px) !important;
        max-width: none;
    }
}

/* Moved from 14-responsive.css: search-related responsive rules */
@media (max-width: 988px) {
    .header-search {
        display: flex;
        align-items: center;
        margin-right: 0;
    }

    .search-toggle {
        width: 36px;
        height: 36px;
        padding: 0;
    }

    .search-dropdown {
        min-width: 280px;
        max-width: calc(100vw - 32px);
        right: 0;
        left: auto;
    }

    .search-field {
        font-size: 16px; /* 防止iOS缩放 */
    }
}

@media (max-width: 768px) {
    /* 移动端搜索下拉框进一步优化 */
    .search-dropdown {
        min-width: 250px;
        max-width: calc(100vw - 24px);
        right: -8px;
        left: auto;
        top: calc(100% + 4px);
    }

    .search-form {
        gap: 8px;
    }

    .search-field {
        flex: 1;
        min-width: 0;
        padding: 10px 12px;
    }

    .search-submit {
        padding: 10px 12px;
        flex-shrink: 0;
    }
}

@media (max-width: 576px) {
    /* 小屏幕搜索框优化 */
    .search-dropdown {
        min-width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        right: -12px;
        padding: 8px;
    }

    .search-field {
        padding: 12px;
        font-size: 16px;
    }

    .search-submit {
        padding: 12px;
        min-width: 44px;
    }
}

/* Final mobile-fit rules: ensure dropdown never overflows viewport and aligns with search field */
@media (max-width: 768px) {
    .search-dropdown {
        left: 8px !important;
        right: 8px !important;
        position: fixed !important;
        top: calc(var(--header-height) + 8px) !important;
        z-index: 1100 !important;
        min-width: auto !important;
        width: calc(100vw - 16px) !important;
        max-width: none !important;
        box-sizing: border-box !important;
        padding: 8px !important;
    }

    .search-dropdown .search-form {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* jQuery UI menu inside dropdown should fill its container */
    .search-dropdown .ui-autocomplete {
        width: 100% !important;
        max-width: none !important;
        left: 0 !important;
        right: 0 !important;
        box-sizing: border-box !important;
    }
}

@media (max-width: 576px) {
    .search-dropdown {
        left: 8px !important;
        right: 8px !important;
        width: calc(100vw - 16px) !important;
        padding: 8px !important;
    }

    .search-dropdown .search-form,
    .search-dropdown .ui-autocomplete {
        width: 100% !important;
    }
}

/* Ensure autocomplete dropdown matches the search-dropdown container on mobile */
.search-dropdown .ui-autocomplete,
.search-dropdown .ui-autocomplete .ui-menu {
    width: 100% !important;
    max-width: none !important;
    left: 0 !important;
    right: 0 !important;
    box-sizing: border-box !important;
}

.search-dropdown {
    box-sizing: border-box;
}