/* ===== SEARCH MODAL STYLES ===== */

.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

.search-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.search-modal-content {
    position: relative;
    width: 90%;
    max-width: 1550px;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
    animation: searchModalSlideIn 0.3s ease-out;
    padding: 0 24px;
}

@keyframes searchModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.search-modal-header {
    padding: 0;
    border-bottom: none;
    background: transparent;
}

.search-modal-input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.search-modal-input-container:focus-within {
    /* 焦点时保持一致的外观，不改变背景和样式 */
}

/* 已移除焦点时的视觉变化 */

.search-modal-icon {
    position: absolute;
    left: 16px;
    color: var(--secondary-color);
    z-index: 1;
}

.search-modal-input {
    flex: 1;
    width: 100%;
    min-width: 0;
    padding: 16px 16px 16px 50px;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 16px;
    outline: none;
}

.search-modal-input::placeholder {
    color: rgba(0, 0, 0, 0.3); /* 浅色主题下更淡的灰色 */
}

/* 暗色主题下的placeholder颜色 */
[data-theme="dark"] .search-modal-input::placeholder {
    color: rgba(255, 255, 255, 0.4); /* 暗色主题下更淡的白色 */
}

.search-modal-close {
    background: transparent;
    border: none;
    padding: 16px;
    cursor: pointer;
    color: var(--secondary-color);
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-modal-close:hover {
    color: var(--text-color);
}

/* Loading状态的关闭按钮 */
.search-modal-close.loading {
    pointer-events: none; /* 禁用点击 */
}

.search-modal-close.loading svg {
    display: none; /* 隐藏X图标 */
}

/* Loading动画 */
.search-loading-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.search-modal-close.loading .search-loading-spinner {
    display: block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.search-modal-body {
    max-height: 60vh;
    overflow-y: auto;
    min-height: 0; /* 移除最小高度，让模态框可以收缩 */
    display: none; /* 默认隐藏搜索结果区域 */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-top: 8px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* 当有搜索内容时显示搜索结果区域 */
.search-modal-body.show-results {
    display: block;
    min-height: auto; /* 让高度根据内容自动调整 */
}

.search-results {
    padding: 16px;
    width: 100%; /* 确保占满宽度 */
    display: flex;
    flex-direction: column;
}

/* 当搜索结果为空时，居中显示 */
.search-results.empty-results {
    justify-content: center; /* 内容垂直居中 */
    align-items: center; /* 水平居中 */
    min-height: 260px; /* 空结果时设置最小高度用于居中 */
}

/* 当有搜索结果时，从顶部开始显示 */
.search-results.has-results {
    justify-content: flex-start;
    min-height: auto; /* 有结果时不需要最小高度 */
}

/* Search Results Footer */
.search-results-footer {
    padding: 16px;
    border-top: none;
    background: transparent;
    text-align: center;
}

.search-match-count {
    font-size: 0.9rem;
    color: var(--secondary-color);
    font-weight: 500;
}

.search-placeholder {
    text-align: center;
    padding: 40px 16px;
}

.search-placeholder-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.search-placeholder h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}

.search-placeholder p {
    color: var(--secondary-color);
    line-height: 1.6;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.search-result-item:hover {
    background: var(--border-color);
}

.search-result-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    margin-right: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-color);
}

.search-result-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-result-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-color);
    color: var(--secondary-color);
    font-size: 16px;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 4px 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-description {
    font-size: 14px;
    color: var(--secondary-color);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-no-results {
    text-align: center;
    padding: 40px 16px;
    color: var(--secondary-color);
}

.search-no-results-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.search-no-results h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}

.search-no-results p {
    color: var(--secondary-color);
    line-height: 1.6;
    margin: 0;
}

/* 暗色主题样式 */
[data-theme="dark"] .search-modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .search-modal-content {
    background: transparent;
    border: none;
    box-shadow: none;
}

[data-theme="dark"] .search-modal-header {
    border-bottom: none;
}

[data-theme="dark"] .search-modal-input-container {
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .search-modal-input-container:focus-within {
    /* 暗色主题下焦点时也保持一致的外观 */
}

[data-theme="dark"] .search-modal-body {
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .search-results-footer {
    border-top: none;
}

[data-theme="dark"] .search-result-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ===== 搜索模态框的完整暗色主题 ===== */

[data-theme="dark"] .search-result-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .search-result-item .tool-name {
    color: var(--text-color);
}

[data-theme="dark"] .search-result-item .tool-description {
    color: var(--secondary-color);
}

[data-theme="dark"] .search-no-results {
    color: var(--secondary-color);
}

[data-theme="dark"] .search-loading {
    color: var(--secondary-color);
}

[data-theme="dark"] .search-modal-input {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .search-close-btn {
    color: var(--secondary-color);
}

[data-theme="dark"] .search-close-btn:hover {
    color: var(--text-color);
    background: var(--hover-bg);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .search-modal {
        padding-top: 5vh;
    }
    
    .search-modal-content {
        width: 95%;
        max-height: 85vh;
        padding: 0 16px;
    }
    
    .search-modal-header {
        padding: 0;
    }
    
    .search-modal-input {
        font-size: 16px;
        padding: 12px 12px 12px 40px;
    }
    
    .search-results {
        padding: 12px;
    }
    
    .search-placeholder {
        padding: 30px 12px;
    }
}

@media (max-width: 480px) {
    .search-modal {
        padding-top: 2vh;
    }
    
    .search-modal-content {
        width: 100%;
        padding: 0 12px;
        margin: 0;
    }
    
    .search-result-icon {
        width: 36px;
        height: 36px;
    }
    
    .search-result-name {
        font-size: 15px;
    }
    
    .search-result-description {
        font-size: 13px;
    }
} 