/* 全局搜索样式 */

/* ==================== 搜索容器 ==================== */

.global-search-container {
    position: relative;
    margin: 0 20px;
    flex: 0 0 auto;
}

.global-search-box {
    position: relative;
    display: flex;
    align-items: center;
    width: 240px;
    height: 38px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.global-search-box:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.global-search-box:focus-within {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
    width: 360px;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    transition: color 0.3s ease;
}

.global-search-box:focus-within .search-icon {
    color: var(--primary-color);
}

.global-search-input {
    flex: 1;
    height: 100%;
    padding: 0 100px 0 40px;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 14px;
}

.global-search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.global-search-box:focus-within .global-search-input {
    color: var(--text-primary);
}

.global-search-box:focus-within .global-search-input::placeholder {
    color: var(--text-tertiary);
}

.search-shortcut-hint {
    position: absolute;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.search-shortcut-hint kbd {
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    font-family: inherit;
    font-size: 10px;
}

.global-search-box:focus-within .search-shortcut-hint {
    opacity: 0;
    pointer-events: none;
}

/* ==================== 搜索结果面板 ==================== */

.global-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 500px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 1000;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-results-content {
    max-height: 500px;
    overflow-y: auto;
}

/* ==================== 搜索结果分类 ==================== */

.search-category {
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--border-color);
}

.search-category:last-child {
    border-bottom: none;
}

.search-category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.search-category-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ==================== 搜索结果项 ==================== */

.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-item:hover,
.search-item.active {
    background: var(--hover-color, rgba(79, 70, 229, 0.05));
}

.search-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.search-item-content {
    flex: 1;
    min-width: 0;
}

.search-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.search-item-title .highlight {
    color: var(--primary-color);
    font-weight: 600;
}

.search-item-description {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-badge {
    padding: 2px 8px;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.search-item-arrow {
    color: var(--text-tertiary);
    font-size: 12px;
    opacity: 0;
    transition: all 0.2s ease;
}

.search-item:hover .search-item-arrow {
    opacity: 1;
    transform: translateX(2px);
}

/* ==================== 空状态 ==================== */

.search-empty-state {
    padding: 40px 20px;
    text-align: center;
}

.search-empty-state i {
    font-size: 48px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.search-empty-state h4 {
    margin: 0 0 8px 0;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
}

.search-empty-state p {
    margin: 0;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* ==================== 搜索历史 ==================== */

.search-history {
    padding: 12px 16px;
}

.search-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.search-history-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.search-history-clear {
    padding: 0;
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 11px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.search-history-clear:hover {
    opacity: 0.8;
}

.search-history-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.search-history-item {
    padding: 6px 12px;
    background: var(--bg-secondary, #f3f4f6);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-history-item:hover {
    background: var(--hover-color, rgba(79, 70, 229, 0.05));
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ==================== 搜索提示 ==================== */

.search-tips {
    padding: 12px 16px;
    background: var(--bg-secondary, #f9fafb);
    border-top: 1px solid var(--border-color);
}

.search-tips-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.search-tips-text i {
    color: var(--primary-color);
}

/* ==================== 响应式设计 ==================== */

@media (min-width: 1600px) {
    .global-search-box {
        width: 280px;
    }

    .global-search-box:focus-within {
        width: 400px;
    }
}

@media (max-width: 1440px) {
    .global-search-box {
        width: 220px;
    }

    .global-search-box:focus-within {
        width: 340px;
    }
}

@media (max-width: 1280px) {
    .global-search-box {
        width: 200px;
    }

    .global-search-box:focus-within {
        width: 320px;
    }

    .search-shortcut-hint {
        display: none;
    }
}

@media (max-width: 1024px) {
    .global-search-container {
        margin: 0 12px;
    }

    .global-search-box {
        width: 180px;
    }

    .global-search-box:focus-within {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .global-search-container {
        display: none;
    }
}

/* ==================== 深色模式 ==================== */

@media (prefers-color-scheme: dark) {
    .global-search-results {
        background: rgba(30, 30, 30, 0.98);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .search-category {
        border-color: rgba(255, 255, 255, 0.1);
    }

    .search-item:hover,
    .search-item.active {
        background: rgba(255, 255, 255, 0.08);
    }

    .search-history-item {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .search-tips {
        background: rgba(255, 255, 255, 0.03);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* ==================== 键盘导航高亮 ==================== */

.search-item.keyboard-selected {
    background: var(--primary-color);
    color: white;
}

.search-item.keyboard-selected .search-item-title,
.search-item.keyboard-selected .search-item-description {
    color: white;
}

.search-item.keyboard-selected .search-item-icon {
    background: white;
    color: var(--primary-color);
}
