/**
 * 全局搜索样式
 * @version 1.0.0
 */

/* 搜索遮罩层 */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-overlay.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    opacity: 1;
}

/* 搜索容器 */
.search-container {
    width: 90%;
    max-width: 700px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 搜索头部 */
.search-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: #6b7280;
    font-size: 1.25rem;
}

.search-input {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 3rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #3470ff;
    box-shadow: 0 0 0 3px rgba(52, 112, 255, 0.1);
}

.search-clear {
    position: absolute;
    right: 1rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    border: none;
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.3s;
}

.search-clear:hover {
    background: #d1d5db;
    transform: scale(1.1);
}

.search-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: none;
    border-radius: 10px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
}

.search-close:hover {
    background: #e5e7eb;
    color: #111827;
}

/* 搜索主体 */
.search-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.search-body::-webkit-scrollbar {
    width: 8px;
}

.search-body::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.search-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.search-body::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 搜索结果 */
.search-section {
    margin-bottom: 1.5rem;
}

.search-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
}

.search-section-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.search-result-item:hover {
    background: #f9fafb;
    transform: translateX(4px);
}

.search-item-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
}

.search-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-item-content {
    flex: 1;
    min-width: 0;
}

.search-item-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.25rem 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-item-desc {
    font-size: 0.8125rem;
    color: #6b7280;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-item-price {
    display: inline-block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #3470ff;
}

.search-item-action {
    flex-shrink: 0;
    color: #9ca3af;
    transition: all 0.2s;
}

.search-result-item:hover .search-item-action {
    color: #3470ff;
    transform: translateX(4px);
}

/* 高亮搜索词 */
mark {
    background: #fef3c7;
    color: #92400e;
    padding: 0 0.125rem;
    border-radius: 2px;
}

/* 加载状态 */
.search-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #6b7280;
}

.search-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f4f6;
    border-top-color: #3470ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 空结果 */
.search-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: #6b7280;
}

.search-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.search-empty p {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 500;
    color: #111827;
}

.search-empty small {
    font-size: 0.875rem;
}

/* 错误状态 */
.search-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: #ef4444;
}

.search-error i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* 搜索历史 */
.search-history {
    padding: 0.5rem;
}

.search-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.search-history-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    margin: 0;
}

.search-history-header button {
    background: none;
    border: none;
    color: #3470ff;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.search-history-header button:hover {
    background: #eff6ff;
}

.search-history-items {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.search-history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.search-history-item:hover {
    background: #f9fafb;
}

.search-history-item i {
    color: #9ca3af;
    font-size: 0.875rem;
}

.search-history-item span {
    color: #374151;
    font-size: 0.9375rem;
}

/* 搜索底部 */
.search-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 16px 16px;
}

.search-tips {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
    color: #6b7280;
}

.search-tips kbd {
    padding: 0.125rem 0.375rem;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 深色模式 */
.dark .search-container {
    background: #1f2937;
}

.dark .search-header {
    border-bottom-color: #374151;
}

.dark .search-input {
    background: #111827;
    border-color: #374151;
    color: #f9fafb;
}

.dark .search-input:focus {
    border-color: #3470ff;
}

.dark .search-close {
    background: #374151;
    color: #9ca3af;
}

.dark .search-close:hover {
    background: #4b5563;
    color: #f9fafb;
}

.dark .search-result-item:hover {
    background: #111827;
}

.dark .search-item-title {
    color: #f9fafb;
}

.dark .search-item-desc {
    color: #9ca3af;
}

.dark .search-footer {
    background: #111827;
    border-top-color: #374151;
}

.dark .search-tips kbd {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

/* 响应式 */
@media (max-width: 768px) {
    .search-overlay.active {
        padding-top: 5vh;
    }
    
    .search-container {
        width: 95%;
        max-height: 85vh;
    }
    
    .search-header {
        padding: 1rem;
    }
    
    .search-input {
        font-size: 0.9375rem;
    }
    
    .search-result-item {
        padding: 0.75rem;
    }
    
    .search-item-image {
        width: 50px;
        height: 50px;
    }
    
    .search-tips {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

