/* ============================================================
   search.css —— 搜索框
   搜索框本体、搜索引擎切换下拉、搜索历史、搜索建议。
   ============================================================ */

/* 外观变量：默认值对应初始样式，由 search.js 依据用户设置覆盖到 :root */
:root {
    --search-width: 600px;    /* 搜索框宽度 */
    --search-height: 48px;    /* 搜索框高度 */
    --search-radius: 24px;    /* 搜索框圆角 */
    --search-opacity: 0.72;   /* 搜索框背景不透明度（0~1） */
}

.search-container {
    position: relative;
    width: var(--search-width);
    max-width: 90%;
}

.search-box {
    width: 100%;
    height: var(--search-height);
    padding: 0 82px 0 92px;
    border-radius: var(--search-radius);
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-size: 0.95rem;
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue',
        'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB',
        'Noto Sans CJK SC', sans-serif;
    font-weight: 400;
    color: #2b2b2b;
    outline: none;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
    caret-color: #2b2b2b;
    transition: box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease, transform 0.25s var(--ease-out);
    background-color: rgba(255, 255, 255, var(--search-opacity));
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
}

/* 悬浮：轻微提亮 */
.search-container:hover .search-box {
    border-color: rgba(255, 255, 255, 0.55);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
}

/* 聚焦：中性描边 + 轻微阴影上浮（无品牌橙高亮） */
.search-box:focus {
    border-color: rgba(255, 255, 255, 0.6);
    background-color: rgba(255, 255, 255, calc(min(1, var(--search-opacity) + 0.2)));
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
    transform: translateY(-1px);
}

.search-box::placeholder {
    color: rgba(0, 0, 0, 0.5);
    opacity: 1;
}

.search-box::-webkit-input-placeholder {
    color: rgba(0, 0, 0, 0.5);
}

.search-box:-moz-placeholder {
    color: rgba(0, 0, 0, 0.5);
    opacity: 1;
}

.search-box::-moz-placeholder {
    color: rgba(0, 0, 0, 0.5);
    opacity: 1;
}

.search-box:-ms-input-placeholder {
    color: rgba(0, 0, 0, 0.5);
}

.search-icon {
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-icon {
    position: absolute;
    right: 48px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #909090;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.clear-icon.show {
    display: flex;
}

.clear-icon:hover {
    background: rgba(0, 0, 0, 0.07);
    color: #333;
}

.divider {
    position: absolute;
    left: 60px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 20px;
    border-radius: 1px;
    background-color: rgba(0, 0, 0, 0.14);
}

.voice-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.voice-icon:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #333;
    transform: translateY(-50%) scale(1.08);
}

.voice-icon.listening {
    color: #ff4d4f;
    animation: voice-pulse 1.2s ease-in-out infinite;
}

@keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0.4); }
    50%      { box-shadow: 0 0 0 6px rgba(255, 77, 79, 0); }
}

/* 设置中关闭“语音搜索”时隐藏语音按钮 */
.voice-icon.hide {
    display: none;
}

/* 设置中关闭“显示搜索框”时隐藏整个桌面搜索框（含下拉历史/建议） */
body.search-box-hidden .search-container {
    display: none !important;
}

.search-engine-container {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    padding: 4px 6px;
    border-radius: 12px;
    cursor: pointer;
    /* 搜索框 input 带 backdrop-filter 会生成堆叠上下文；引擎容器在 input 之前、
       且为 z-index:auto 时会被 input 的背景盖住（图标/分隔线/箭头全不可见）。
       给容器明确的 z-index，使其始终绘制在输入框之上（右侧语音图标因在 input 之后故本就可见）。 */
    z-index: 2;
    transition: background 0.15s ease;
}

.search-engine-container:hover {
    background: rgba(0, 0, 0, 0.05);
}

.dropdown-arrow {
    margin-left: 6px;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.search-engine-container.active .dropdown-arrow {
    transform: rotate(180deg);
}

.search-dropdown {
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
    padding: 6px;
    width: 100%;
    z-index: 1000;
    display: none;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    transform-origin: top center;
    animation: dropdown-in 0.18s var(--ease-out);
}

@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.search-dropdown.show {
    display: flex;
}

.dropdown-item {
    padding: 8px 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #444;
    border-radius: 10px;
    transition: background-color 0.18s ease, color 0.18s ease;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.dropdown-item:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: #333;
}

.dropdown-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dropdown-item-icon .icon {
    width: 18px;
    height: 18px;
    display: block;
}

/* 搜索历史下拉 */
.search-history {
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
    width: 100%;
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: top center;
    animation: dropdown-in 0.18s var(--ease-out);
}

.search-history.show {
    display: flex;
}

.search-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: 13px;
    color: #999;
    border-bottom: 1px solid #f0f0f0;
}

.search-history-clear {
    cursor: pointer;
    color: #999;
    padding: 2px 6px;
    border-radius: 6px;
    transition: color 0.2s ease, background 0.2s ease;
}

.search-history-clear:hover {
    color: #ff4d4f;
    background: rgba(255, 77, 79, 0.08);
}

.search-history-list {
    max-height: 280px;
    overflow-y: auto;
    padding: 4px 0;
}

.search-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 6px;
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background-color 0.15s ease;
}

.search-history-item:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

.search-history-item svg {
    flex-shrink: 0;
    opacity: 0.5;
}

.search-history-item .history-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-history-item .history-delete {
    opacity: 0;
    color: #bbb;
    transition: opacity 0.15s ease, color 0.15s ease;
    padding: 2px;
}

.search-history-item:hover .history-delete {
    opacity: 1;
}

.search-history-item .history-delete:hover {
    color: #ff4d4f;
}

.search-history-empty {
    padding: 24px 16px;
    text-align: center;
    font-size: 13px;
    color: #bbb;
}

/* 搜索建议 */
.search-suggestion-list {
    display: none;
    flex-direction: column;
    padding: 4px 0;
    max-height: 320px;
    overflow-y: auto;
}

.search-suggestion-list.show {
    display: flex;
}

.search-suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 6px;
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background-color 0.15s ease;
}

.search-suggestion-item:hover,
.search-suggestion-item.active {
    background-color: rgba(0, 0, 0, 0.06);
}

/* 键盘高亮时整行保持可见 */
.search-suggestion-item.active {
    box-shadow: inset 3px 0 0 rgba(0, 0, 0, 0.35);
}

.search-suggestion-item .suggestion-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-suggestion-item .suggestion-text b {
    color: #1a1a1a;
    font-weight: 600;
}
