/* app/static/css/search_widget.css */

/* ================= 1. 搜索框外层容器与输入框 ================= */
.site-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    z-index: 100;
}

.nav-search-box {
    width: 320px;
    max-width: 35vw;
}

.home-search-box {
    width: 500px;
    max-width: 85vw;
    margin: 25px auto 0 auto;
}

.search-input-field {
    width: 100%;
    height: 38px;
    padding: 6px 14px 6px 36px;
    font-size: 0.9rem;
    color: #222;
    background: #f4f5f8 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%237a33ff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>') no-repeat 12px center;
    border: 1px solid #dcdfe6;
    border-radius: 20px;
    outline: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.search-input-field:focus {
    background-color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

/* 首页星空下的半透明搜索框 */
.home-bg .search-input-field {
    background-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(8px);
}

.home-bg .search-input-field::placeholder {
    color: rgba(255, 255, 255, 0.85);
}

.home-bg .search-input-field:focus {
    background-color: #ffffff;
    color: #111;
    border-color: #ffffff;
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.5);
}

/* ================= 2. 实时下拉预览菜单 (防溢出计算) ================= */
.search-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    min-width: 380px;
    max-height: min(480px, calc(100vh - 120px));
    overflow-y: auto;
    background: #ffffff !important;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.05);
    z-index: 2000;
    display: none;
    flex-direction: column;
    padding: 8px 0;
    text-align: left;
}

.home-search-box .search-dropdown-menu {
    max-height: min(300px, 35vh);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}

.search-dropdown-menu.active {
    display: flex;
}

.search-dropdown-menu::-webkit-scrollbar {
    width: 6px;
}
.search-dropdown-menu::-webkit-scrollbar-thumb {
    background: #dcdce2;
    border-radius: 3px;
}

.search-group-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary);
    padding: 8px 16px 4px 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #f4f4f6;
    margin-bottom: 4px;
}

.search-result-item {
    padding: 9px 16px;
    cursor: pointer;
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--text-regular) !important;
    transition: background-color 0.15s ease;
}

.search-result-item:hover {
    background-color: #f7f5fc;
}

.search-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.search-item-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-badge-tag {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1.4;
}

.search-item-snippet {
    font-size: 0.80rem;
    color: var(--text-muted);
    line-height: 1.45;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-dropdown-footer {
    padding: 10px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
    background: #faf8fe;
    text-align: center;
    border-top: 1px solid #eeeaf6;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-radius: 0 0 10px 10px;
    margin-top: 4px;
}

.search-dropdown-footer:hover {
    background-color: #f1ebfc;
}

.search-no-result {
    padding: 16px;
    text-align: center;
    color: var(--text-light);
    font-size: 0.88rem;
}