/*
 * HQS 搜索模态框样式
 * 容器：全站面板·天气组件同款（米白毛玻璃 + 暖金）
 * 前缀 hqs-，避免与其他组件冲突
 */

/* 动态主色由 PHP 通过 :root CSS变量注入 */
[hidden] { display: none !important; }

/* ---- 模态框容器（fixed 全屏覆盖） ---- */
.hqs-modal {
    position: fixed;
    inset: 0;
    z-index: 100002;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.hqs-modal.is-open {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.25s ease, visibility 0s;
}
.hqs-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(58, 46, 40, 0.45);
    backdrop-filter: blur(var(--glass-blur-sm));
    -webkit-backdrop-filter: blur(var(--glass-blur-sm));
}

/* ---- 对话框（米白毛玻璃卡片） ---- */
.hqs-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -46%) scale(0.97);
    width: 720px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: var(--glass-filter-lg);
    -webkit-backdrop-filter: var(--glass-filter-lg);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(58, 46, 40, 0.16);
    transition: transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.22s ease;
    overflow: hidden;
}
.hqs-modal.is-open .hqs-panel {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* ---- 头部（标题 + 关闭） ---- */
.hqs-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 18px 22px 14px;
    font-family: var(--hqs-serif);
    font-size: 15px;
    font-weight: 700;
    color: var(--hqs-ink);
    flex-shrink: 0;
}
.hqs-head > i { color: var(--hqs-gold); font-size: 15px; }
.hqs-close {
    flex-shrink: 0;
    /* 取代原 .hqs-head__spacer 空占位元素 */
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: rgba(58, 46, 40, 0.06);
    color: var(--hqs-ink-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.hqs-close:hover {
    background: var(--hqs-gold-mid);
    color: var(--hqs-gold);
    transform: rotate(90deg);
}

/* ---- 主体 ---- */
.hqs-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    padding: 0 22px 14px;
}

/* ---- 输入区 ---- */
.hqs-searchbar {
    display: flex;
    align-items: center;
    gap: 10px;
    /* 为内嵌图标提供绝对定位参照 */
    position: relative;
    padding: 13px 18px;
    border-radius: 18px;
    background: var(--hqs-glass);
    border: 1px solid var(--hqs-glass-border);
    flex-shrink: 0;
    transition: border-color var(--hqs-ease), box-shadow var(--hqs-ease);
}
.hqs-searchbar:focus-within {
    border-color: var(--hqs-accent-focus);
    box-shadow: 0 0 0 3px var(--hqs-accent-soft);
}
.hqs-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 15px;
    font-family: inherit;
    color: var(--hqs-ink);
    outline: none;
    padding-left: 0;
}
.hqs-input::placeholder { color: var(--hqs-ink-faint); }
.hqs-clear {
    flex-shrink: 0;
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(58, 46, 40, 0.06);
    color: var(--hqs-ink-muted);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background-color var(--hqs-ease), color var(--hqs-ease);
}
.hqs-clear:hover { background: var(--hqs-gold-mid); color: var(--hqs-gold); }
.hqs-shortcut { display: flex; gap: 3px; flex-shrink: 0; }
.hqs-shortcut kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    font-size: 11px;
    font-family: inherit;
    color: var(--hqs-ink-muted);
    background: var(--hqs-chip);
    border: 1px solid var(--hqs-hairline);
    border-radius: 6px;
}

/* ---- 过滤标签 ---- */
.hqs-filters {
    display: flex;
    gap: 8px;
    padding: 14px 0 10px;
    overflow-x: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.hqs-filters::-webkit-scrollbar { display: none; }
.hqs-filter {
    padding: 6px 15px;
    border: 1px solid transparent;
    background: var(--hqs-glass);
    color: var(--hqs-ink-muted);
    font-size: 13px;
    font-family: inherit;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--hqs-ease), color var(--hqs-ease), border-color var(--hqs-ease);
}
.hqs-filter:hover { background: var(--hqs-gold-soft); color: var(--hqs-ink); }
.hqs-filter.is-active {
    background: var(--hqs-gold-mid);
    color: var(--hqs-gold-deep);
    border-color: rgba(var(--color-primary-rgb), 0.45);
    font-weight: 600;
}

/* ---- 内容区 ---- */
.hqs-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 2px;
    -webkit-overflow-scrolling: touch;
}
.hqs-main::-webkit-scrollbar { width: 6px; }
.hqs-main::-webkit-scrollbar-track { background: transparent; }
.hqs-main::-webkit-scrollbar-thumb { background: rgba(58, 46, 40, 0.15); border-radius: 3px; }
.hqs-main::-webkit-scrollbar-thumb:hover { background: var(--hqs-gold); }

/* ---- 分区标题 ---- */
.hqs-section { margin-bottom: 16px; }
.hqs-section:last-child { margin-bottom: 0; }
.hqs-section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px 9px;
}
.hqs-section-title {
    font-family: var(--hqs-serif);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--hqs-ink-faint);
    margin: 0;
}
/* 独立标题（热门搜索，已移除 .hqs-section-row 包装）沿用原 row 的内边距；
   .hqs-section-row 内的标题由 row 提供，避免重复叠加 */
.hqs-section > .hqs-section-title { padding: 0 6px 9px; }
.hqs-clear-recent-btn {
    border: none;
    background: none;
    font-size: 12px;
    color: var(--hqs-ink-faint);
    cursor: pointer;
    font-family: inherit;
    padding: 2px 8px;
    border-radius: 6px;
    transition: color var(--hqs-ease), background-color var(--hqs-ease);
}
.hqs-clear-recent-btn:hover { color: var(--hqs-gold-deep); background: var(--hqs-gold-soft); }

/* ---- 热门搜索 ---- */
.hqs-trending { display: flex; flex-wrap: wrap; gap: 8px; }
.hqs-trending-item {
    padding: 7px 15px;
    border: 1px solid var(--hqs-glass-border);
    background: var(--hqs-glass);
    color: var(--hqs-ink-sub);
    font-size: 13px;
    font-family: inherit;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color var(--hqs-ease), color var(--hqs-ease),
                border-color var(--hqs-ease), transform var(--hqs-ease);
}
.hqs-trending-item:hover,
.hqs-trending-item.is-on {
    border-color: var(--hqs-gold);
    color: var(--hqs-gold-deep);
    background: var(--hqs-gold-soft);
    transform: translateY(-1px);
}

/* ---- 最近搜索 ---- */
.hqs-recent-list { display: flex; flex-direction: column; gap: 2px; }
.hqs-recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: none;
    background: none;
    color: var(--hqs-ink-muted);
    font-size: 14px;
    font-family: inherit;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background-color var(--hqs-ease), color var(--hqs-ease);
}
.hqs-recent-item i { flex-shrink: 0; font-size: 13px; color: var(--hqs-ink-faint); }
.hqs-recent-item:hover,
.hqs-recent-item.is-on { background: var(--hqs-glass); color: var(--hqs-ink); }

/* ---- 搜索结果 ---- */
.hqs-results { display: flex; flex-direction: column; gap: 2px; }
.hqs-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none;
    color: var(--hqs-ink);
    transition: background-color var(--hqs-ease);
    animation: hqs-fadein 0.18s ease both;
}
.hqs-result-item:hover,
.hqs-result-item.is-on { background: var(--hqs-glass); }
.hqs-result-thumb {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--hqs-chip);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hqs-ink-faint);
}
.hqs-result-content { flex: 1; min-width: 0; }
.hqs-result-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--hqs-ink);
    line-height: 1.4;
    margin: 0 0 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}
.hqs-result-title mark {
    background: var(--hqs-accent-soft);
    color: var(--hqs-accent);
    border-radius: 3px;
    padding: 0 2px;
}
.hqs-result-excerpt {
    font-size: 12px;
    color: var(--hqs-ink-faint);
    line-height: 1.5;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}
.hqs-result-badge {
    flex-shrink: 0;
    padding: 3px 9px;
    font-size: 11px;
    color: var(--hqs-ink-muted);
    background: var(--hqs-chip);
    border-radius: 999px;
}

/* ---- 加载中 ---- */
.hqs-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 46px 0;
    color: var(--hqs-ink-faint);
    font-size: 13px;
}
.hqs-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--hqs-hairline);
    border-top-color: var(--hqs-gold);
    border-radius: 50%;
    animation: hqs-spin 0.6s linear infinite;
}
@keyframes hqs-spin { to { transform: rotate(360deg); } }

/* ---- 空状态 ---- */
.hqs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 46px 20px;
    text-align: center;
}
.hqs-empty > i {
    font-size: 30px;
    color: rgba(var(--color-primary-rgb), 0.6);
    margin-bottom: 8px;
}
.hqs-empty p { font-size: 14px; font-weight: 600; color: var(--hqs-ink-sub); margin: 0; }
.hqs-empty span { font-size: 12.5px; color: var(--hqs-ink-faint); }

/* ---- 底部 ---- */
.hqs-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 22px;
    border-top: 1px solid var(--hqs-hairline);
    flex-shrink: 0;
}
.hqs-count { font-size: 12px; color: var(--hqs-ink-faint); }
.hqs-hints {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--hqs-ink-faint);
}
.hqs-hints kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    font-size: 10px;
    font-family: inherit;
    color: var(--hqs-ink-muted);
    background: var(--hqs-chip);
    border: 1px solid var(--hqs-hairline);
    border-radius: 5px;
}

/* ---- 入场动画 ---- */
@keyframes hqs-fadein {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}
.hqs-result-item:nth-child(2) { animation-delay: 0.03s; }
.hqs-result-item:nth-child(3) { animation-delay: 0.06s; }
.hqs-result-item:nth-child(4) { animation-delay: 0.09s; }
.hqs-result-item:nth-child(5) { animation-delay: 0.12s; }
.hqs-result-item:nth-child(6) { animation-delay: 0.15s; }

/* ---- 深色模式 ---- */
[data-theme="dark"] .hqs-panel {
    background: rgba(46, 38, 32, 0.82);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .hqs-head { color: #efe6db; }
[data-theme="dark"] .hqs-close {
    background: rgba(255, 255, 255, 0.08);
    color: #b8a898;
}
[data-theme="dark"] .hqs-close:hover {
    background: var(--hqs-gold-mid);
    color: var(--color-primary-pale);
}
[data-theme="dark"] { --hqs-ink: #efe6db; --hqs-ink-sub: #d8cbbd; --hqs-ink-muted: #b8a898; --hqs-ink-faint: #a89a8a; }
[data-theme="dark"] .hqs-searchbar,
[data-theme="dark"] .hqs-filter,
[data-theme="dark"] .hqs-recent-item:hover,
[data-theme="dark"] .hqs-recent-item.is-on,
[data-theme="dark"] .hqs-result-item:hover,
[data-theme="dark"] .hqs-result-item.is-on {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .hqs-trending-item {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #d8cbbd;
}
[data-theme="dark"] .hqs-trending-item:hover,
[data-theme="dark"] .hqs-trending-item.is-on {
    background: rgba(var(--color-primary-rgb), 0.18);
    border-color: rgba(var(--color-primary-rgb), 0.5);
    color: var(--color-primary-pale);
}
[data-theme="dark"] .hqs-foot { border-top-color: rgba(255, 255, 255, 0.1); }
[data-theme="dark"] .hqs-chip,
[data-theme="dark"] .hqs-shortcut kbd,
[data-theme="dark"] .hqs-hints kbd,
[data-theme="dark"] .hqs-result-badge {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #b8a898;
}
[data-theme="dark"] .hqs-main::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); }
[data-theme="dark"] .hqs-main::-webkit-scrollbar-thumb:hover { background: var(--hqs-gold); }

/* ---- 响应式（移动端：底部抽屉式） ---- */
@media (max-width: 760px) {
    .hqs-panel {
        top: auto;
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        max-width: none;
        max-height: 82vh;
        transform: translateY(20px) scale(0.98);
        border-radius: 18px;
    }
    .hqs-modal.is-open .hqs-panel { transform: translateY(0) scale(1); }
    .hqs-head { padding: 16px 18px 12px; }
    .hqs-body { padding: 0 18px 12px; }
    .hqs-foot { padding: 10px 18px; }
    .hqs-hints { display: none; }
    .hqs-shortcut { display: none; }
    .hqs-result-thumb { width: 40px; height: 40px; }
}
