/* 搜索功能样式 */

/* 搜索框容器 */
.search-container {
    position: relative;
    flex: 1;
    max-width: 500px;
    margin: 0 20px;
}

/* 搜索输入框包装 */
.search-input-wrapper {
    position: relative;
    width: 100%;
}

/* 搜索图标 */
.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
    z-index: 2;
}

/* 搜索输入框 */
.search-input {
    width: 100%;
    padding: 12px 40px 12px 45px;
    border: none;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* 清除按钮 */
.search-clear-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 16px;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 2;
}

.search-clear-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* 移动端搜索输入框 - 防止iOS Safari自动缩放 */
@media (max-width: 768px) {
    .search-input,
    #mobileRecipeSearchInput {
        font-size: 16px; /* 防止iOS Safari在输入时自动放大页面 */
    }
}

/* 搜索建议下拉菜单 */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    margin-top: 8px;
    z-index: 1000;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

/* 建议列表 */
.suggestions-list {
    padding: 8px 0;
}

/* 建议项 */
.suggestion-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.suggestion-item:hover {
    background-color: #f8f9fa;
}

/* 建议图标 */
.suggestion-icon {
    color: #6c757d;
    margin-right: 12px;
    font-size: 14px;
}

/* 建议文本 */
.suggestion-text {
    flex: 1;
    font-size: 16px;
    color: #212529;
}

.suggestion-text strong {
    color: #ff6b35;
    font-weight: 600;
}

/* 建议分类 */
.suggestion-category {
    font-size: 12px;
    color: #6c757d;
    background: #e9ecef;
    padding: 4px 8px;
    border-radius: 12px;
    margin-left: 10px;
}

/* 搜索结果容器 */
.search-results {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 2000;
    transform: translateX(100%);
    transition: transform 0.4s ease;
    overflow-y: auto;
}

.search-results.active {
    transform: translateX(0);
}

/* 搜索结果头部 */
.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-results-header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

/* 关闭按钮 */
.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #f8f9fa;
    color: #333;
}

/* 搜索结果数量 */
.search-results-count {
    padding: 20px;
    font-size: 16px;
    color: #6c757d;
    border-bottom: 1px solid #e9ecef;
}

/* 结果网格 */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* 结果卡片 */
.result-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #e9ecef;
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* 结果图片 */
.result-image {
    position: relative;
    padding-top: 60%; /* 5:3 宽高比 */
    overflow: hidden;
}

.result-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.result-card:hover .result-image img {
    transform: scale(1.05);
}

/* 结果内容 */
.result-content {
    padding: 20px;
}

/* 结果标题 */
.result-title {
    margin: 0 0 10px 0;
    font-size: 18px;
    color: #333;
    font-weight: 600;
}

/* 结果分类 */
.result-category {
    display: inline-block;
    font-size: 12px;
    color: #ff6b35;
    background: rgba(255, 107, 53, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 15px;
}

/* 结果链接 */
.result-link {
    display: inline-block;
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.result-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

/* 无结果 */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.no-results i {
    color: #e9ecef;
    margin-bottom: 20px;
}

.no-results h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 20px;
}

.no-results p {
    margin: 0;
    font-size: 16px;
}

/* 加载状态 */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.loading i {
    color: #ff6b35;
    margin-bottom: 20px;
}

.loading p {
    margin: 0;
    font-size: 16px;
}

/* 搜索覆盖层 */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}

.search-active .search-overlay {
    opacity: 1;
    visibility: visible;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .search-container {
        margin: 0 10px;
        max-width: none;
    }
    
    .search-input {
        padding: 10px 35px 10px 40px;
        font-size: 14px;
    }
    
    .search-icon,
    .search-clear-btn {
        font-size: 14px;
    }
    
    .search-icon {
        left: 12px;
    }
    
    .search-clear-btn {
        right: 12px;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px;
    }
    
    .result-content {
        padding: 15px;
    }
    
    .search-results-header h2 {
        font-size: 20px;
    }
    
    /* 在移动端显示移动端搜索框 */
    .mobile-search-container {
        display: block;
    }
    
    /* 防止移动端浏览器在输入时自动放大页面 */
    #mobileRecipeSearchInput {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .search-container {
        margin: 0 5px;
    }
    
    .suggestion-item {
        padding: 10px 15px;
    }
    
    .suggestion-text {
        font-size: 14px;
    }
    
    /* 在小屏幕设备上保持字体大小以防止缩放 */
    .search-input,
    #mobileRecipeSearchInput {
        font-size: 16px;
    }
}

/* 在PC端隐藏移动端搜索框 - 使用媒体查询确保正确优先级 */
@media (min-width: 769px) {
    .mobile-search-container {
        display: none;
    }
}
