/**
 * search.css - 搜索框样式
 */
.search-section {
    margin-bottom: 40px;
}
.search-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 20%;
}
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 24px;
    padding: 8px 8px 8px 20px;
    width: 100%;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}
.search-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 2px 16px rgba(30, 136, 229, 0.15);
}
.search-icon {
    color: var(--text-muted);
    margin-right: 10px;
    flex-shrink: 0;
}
.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: calc(16px * var(--font-scale));
    padding: 8px 0;
    background: transparent;
    color: var(--text-color);
}
.search-right {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-left: 1px solid var(--border-color);
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
    user-select: none;
}
.search-right:hover {
    color: var(--primary-color);
}
.search-more {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    color: #ffffff;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(30, 136, 229, 0.3);
}
.search-more:hover {
    border-color: var(--primary-light);
    background: var(--primary-light);
    color: #ffffff;
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(30, 136, 229, 0.4);
}
/* 搜索引擎菜单（层级高于搜索历史面板，确保展开时盖在历史面板之上） */
.engine-menu {
    position: absolute;
    top: 100%;
    right: 8px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    overflow: hidden;
    z-index: 100;
    margin-top: 8px;
}
.engine-menu.hidden {
    display: none;
}
.engine-option {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-color);
}
.engine-option:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}
.engine-option.active {
    background: var(--bg-color);
    color: var(--primary-color);
}

/* ============ 搜索历史记录面板 ============ */
/* 历史面板使用独立透明度变量 --shp-bg，与主分类 UI（--bg-card）区分；
   由 JS applyHistoryPanelOpacity 写入 rgba 值，默认 96% 不透明 */
.search-history-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 10px;
    background: var(--shp-bg, var(--bg-card));
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    overflow: hidden;
    z-index: 50;
    /* 最大高度受视口约束，超出时 .shp-list 自动出滚动条 */
    max-height: min(480px, 70vh);
    display: flex;
    flex-direction: column;
    animation: shpFadeIn 0.2s ease;
}
.search-history-panel.hidden {
    display: none;
}
@keyframes shpFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.shp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(30, 136, 229, 0.03);
    flex-shrink: 0;
}
.shp-title {
    font-size: calc(13px * var(--font-scale));
    font-weight: 600;
    color: var(--text-color);
}
.shp-clear {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: calc(12px * var(--font-scale));
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}
.shp-clear:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.08);
}
.shp-list {
    overflow-y: auto;
    flex: 1;
    /* Firefox：细滚动条 */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}
/* WebKit：美化滚动条 */
.shp-list::-webkit-scrollbar {
    width: 6px;
}
.shp-list::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}
.shp-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
    transition: background 0.2s;
}
.shp-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}
.shp-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: calc(13px * var(--font-scale));
}

/* ============ 单条历史记录 ============ */
.shp-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}
.shp-item:last-child {
    border-bottom: none;
}
.shp-item:hover {
    background: var(--bg-color);
}
/* 深色模式下：hover 时保证标题/副文字颜色明亮可读 */
body[data-theme="dark"] .shp-item:hover .shp-item-title {
    color: #ffffff;
}
body[data-theme="dark"] .shp-item:hover .shp-item-sub {
    color: #b8c0cc;
}
/* 深色模式下：条目内引擎下拉的 option 底色与文字 */
body[data-theme="dark"] .shp-engine-select,
body[data-theme="dark"] .shp-engine-select option {
    background-color: var(--bg-card-base);
    color: var(--text-base);
}
.shp-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.shp-icon-site {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}
.shp-icon-search {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: #fff;
}
.shp-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.shp-item-title {
    font-size: calc(14px * var(--font-scale));
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.shp-item-sub {
    font-size: calc(12px * var(--font-scale));
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.shp-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.shp-engine-select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-light);
    font-size: calc(12px * var(--font-scale));
    cursor: pointer;
    outline: none;
    max-width: 110px;
    transition: all 0.2s;
}
.shp-engine-select:hover {
    border-color: var(--primary-light);
    color: var(--primary-color);
}
.shp-engine-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.15);
}
.shp-item-del {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: calc(16px * var(--font-scale));
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.shp-item-del:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

/* 响应式：历史面板在手机上更紧凑 */
@media (max-width: 640px) {
    .search-container {
        padding: 0 12px;
    }
    .shp-item {
        padding: 10px 14px;
        gap: 10px;
    }
    .shp-engine-select {
        max-width: 90px;
        font-size: calc(11px * var(--font-scale));
    }
}

/* ============ 扩展相关：扩展已连接徽标 ============ */
.shp-extension-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, #d4f0dd, #e8f8ec);
    color: #1e8e48;
    font-size: calc(11px * var(--font-scale));
    font-weight: 600;
    letter-spacing: 0.3px;
    line-height: 1.6;
    border: 1px solid rgba(30, 142, 72, 0.25);
}
body[data-theme="dark"] .shp-extension-badge {
    background: rgba(30, 142, 72, 0.15);
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.3);
}

/* ============ 扩展相关：切换到此标签页按钮 ============ */
.shp-switch-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid var(--primary-color);
    background: linear-gradient(135deg, rgba(30, 136, 229, 0.08), rgba(0, 198, 255, 0.08));
    color: var(--primary-color);
    border-radius: 8px;
    font-size: calc(12px * var(--font-scale));
    font-weight: 600;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
    transition: all 0.18s ease;
}
.shp-switch-tab:hover {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(30, 136, 229, 0.25);
    transform: translateY(-1px);
}
.shp-switch-tab:active {
    transform: translateY(0);
}
.shp-switch-tab:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
    background: rgba(30, 136, 229, 0.06) !important;
    color: var(--primary-color) !important;
}

/* 响应式：小屏幕下缩短按钮文字 */
@media (max-width: 640px) {
    .shp-switch-tab {
        padding: 5px 8px;
        font-size: calc(11px * var(--font-scale));
    }
}
