/* ============================================================
   智能搜索组件样式 - 完整版（含手机优化）
   ============================================================ */

/* 搜索卡片容器 */
.search-card {
    background: #ffffff;
    border-radius: 0px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    padding: 20px 24px 24px;
    transition: box-shadow 0.3s ease;
    margin-bottom: 20px;
}

.search-card:focus-within {
    box-shadow: 0 8px 40px rgba(59, 130, 246, 0.15);
}

/* 搜索引擎标签 */
.engine-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    list-style: none;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 14px;
}

.engine-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.25s ease;
    background: transparent;
    border: 1.5px solid transparent;
    user-select: none;
    position: relative;
}

.engine-tab img {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    object-fit: contain;
}

.engine-tab:hover {
    background: #f1f5f9;
    color: #1e293b;
    transform: translateY(-1px);
}

.engine-tab.active {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.10);
}

.engine-tab .badge {
    font-size: 9px;
    background: #dbeafe;
    color: #2563eb;
    padding: 0 6px;
    border-radius: 10px;
    line-height: 16px;
    font-weight: 600;
}

.engine-tab.custom-engine-tab {
    border-style: dashed;
    border-color: #bfdbfe;
    color: #3b82f6;
}

.engine-tab .remove-engine {
    font-size: 12px;
    color: #94a3b8;
    margin-left: 2px;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 50%;
    transition: all 0.2s;
    line-height: 1;
}

.engine-tab .remove-engine:hover {
    background: #fee2e2;
    color: #ef4444;
}

#addEngineBtn {
    border-style: dashed;
    border-color: #e2e8f0;
    color: #94a3b8;
}

#addEngineBtn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #eff6ff;
}

/* 搜索表单 */
.search-form {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: #f8fafc;
    border-radius: 16px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.search-form:focus-within {
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.08);
}

/* 引擎选择器 */
.engine-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px 0 18px;
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
    border-right: 2px solid #e2e8f0;
    transition: all 0.2s;
    white-space: nowrap;
    background: transparent;
    border-radius: 16px 0 0 16px;
    position: relative;
    min-width: 90px;
}

.engine-selector:hover {
    background: #f1f5f9;
}

.engine-selector img {
    width: 18px;
    height: 18px;
    border-radius: 4px;
}

.engine-selector .arrow {
    font-size: 10px;
    color: #94a3b8;
    transition: transform 0.25s;
    margin-left: 2px;
}

.engine-selector.open .arrow {
    transform: rotate(180deg);
}

/* 下拉菜单 */
.engine-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
    border: 1px solid #f1f5f9;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.25s ease;
    z-index: 100;
}

.engine-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.engine-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    color: #1e293b;
    cursor: pointer;
    transition: background 0.15s;
}

.engine-dropdown .dropdown-item:hover {
    background: #f1f5f9;
}

.engine-dropdown .dropdown-item img {
    width: 18px;
    height: 18px;
    border-radius: 4px;
}

.engine-dropdown .dropdown-item .check {
    margin-left: auto;
    color: #3b82f6;
    font-size: 14px;
}

.engine-dropdown .dropdown-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 6px 10px;
}

.engine-dropdown .dropdown-item.custom-engine {
    color: #3b82f6;
    font-weight: 500;
}

/* 搜索输入 */
.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    border: none;
    background: transparent;
    outline: none;
    color: #0f172a;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.search-input::placeholder {
    color: #94a3b8;
    font-weight: 300;
}

/* 搜索按钮 */
.search-btn {
    padding: 0 28px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    margin: 4px 4px 4px 0;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.25);
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.35);
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.search-btn:active {
    transform: scale(0.97);
}

/* 搜索联想层 */
.search-suggest-layer {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.12);
    border: 1px solid #f1f5f9;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: all 0.25s ease;
    z-index: 99;
    max-height: 380px;
    overflow-y: auto;
}

.search-suggest-layer.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-suggest-layer::-webkit-scrollbar {
    width: 4px;
}

.search-suggest-layer::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.suggest-section-title {
    padding: 10px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.suggest-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    cursor: pointer;
    transition: background 0.12s;
    font-size: 14px;
    color: #1e293b;
}

.suggest-item:hover {
    background: #f8fafc;
}

.suggest-item .icon {
    color: #94a3b8;
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.suggest-item .highlight {
    color: #2563eb;
    font-weight: 600;
}

.suggest-item .meta {
    margin-left: auto;
    font-size: 11px;
    color: #94a3b8;
}

.suggest-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 4px 16px;
}

.suggest-hot-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 20px 12px;
}

.suggest-hot-tag {
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    background: #f1f5f9;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.suggest-hot-tag:hover {
    background: #dbeafe;
    color: #2563eb;
    border-color: #93c5fd;
}

.suggest-hot-tag .rank {
    color: #f97316;
    font-weight: 700;
    margin-right: 4px;
}

/* 分类标签 */
.search-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #f1f5f9;
}

.category-tag {
    padding: 4px 16px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    background: #f1f5f9;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1.5px solid transparent;
    user-select: none;
}

.category-tag:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: translateY(-1px);
}

.category-tag.active {
    background: #dbeafe;
    color: #2563eb;
    border-color: #93c5fd;
}

.category-tag i {
    margin-right: 4px;
    font-size: 11px;
}

.category-tag.custom-add {
    color: #3b82f6;
    background: transparent;
    border-style: dashed;
    border-color: #bfdbfe;
}

.category-tag.custom-add:hover {
    background: #eff6ff;
    border-color: #3b82f6;
}

.category-tag .remove-category {
    font-size: 11px;
    color: #94a3b8;
    margin-left: 4px;
    cursor: pointer;
}

.category-tag .remove-category:hover {
    color: #ef4444;
}

/* 模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
    animation: fadeIn 0.25s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-box {
    background: #ffffff;
    border-radius: 24px;
    padding: 32px 36px;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
}

.modal-box h3 {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 6px;
}

.modal-box .sub {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 24px;
}

.modal-box .form-group {
    margin-bottom: 16px;
}

.modal-box .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 5px;
}

.modal-box .form-group input,
.modal-box .form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    transition: border 0.2s;
    outline: none;
    background: #fff;
}

.modal-box .form-group input:focus,
.modal-box .form-group select:focus {
    border-color: #3b82f6;
}

.modal-box .btn-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-box .btn-group button {
    flex: 1;
    padding: 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.modal-box .btn-primary {
    background: #3b82f6;
    color: #fff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}

.modal-box .btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.modal-box .btn-secondary {
    background: #f1f5f9;
    color: #475569;
}

.modal-box .btn-secondary:hover {
    background: #e2e8f0;
}

/* Toast提示 */
.custom-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: white;
    padding: 12px 28px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 9999;
    animation: fadeIn 0.3s ease;
    max-width: 90%;
}

/* ============================================================
   响应式 - 手机版优化
   ============================================================ */

/* 平板和小屏笔记本 */
@media (max-width: 1024px) {
    .search-card {
        padding: 18px 20px;
    }
    .engine-tabs {
        gap: 4px;
    }
    .engine-tab {
        font-size: 12px;
        padding: 5px 12px;
    }
}

/* 手机版 - 重点优化 */
@media (max-width: 768px) {
    .search-card {
        padding: 14px 16px;
        border-radius: 14px;
        margin-bottom: 14px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    }
    
    /* 引擎标签 - 横向滚动 */
    .engine-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 4px;
        padding-bottom: 10px;
        margin-bottom: 12px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .engine-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .engine-tab {
        flex-shrink: 0;
        font-size: 11px;
        padding: 4px 12px;
        white-space: nowrap;
    }
    
    .engine-tab img {
        width: 14px;
        height: 14px;
    }
    
    /* 搜索表单 - 垂直堆叠 */
    .search-form {
        flex-wrap: wrap;
        background: #f8fafc;
        border-radius: 12px;
        border: 2px solid #e2e8f0;
        padding: 4px;
        gap: 6px;
    }
    
    .search-form:focus-within {
        border-color: #3b82f6;
        background: #ffffff;
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.06);
    }
    
    /* 引擎选择器 - 移到第一行 */
    .engine-selector {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        border-radius: 10px 10px 0 0;
        padding: 8px 14px;
        min-width: unset;
        height: 40px;
        font-size: 13px;
        background: #f8fafc;
    }
    
    .engine-selector img {
        width: 16px;
        height: 16px;
    }
    
    /* 搜索输入框 - 第二行 */
    .search-input-wrapper {
        flex: 1 1 100%;
        order: 2;
        background: #ffffff;
        border-radius: 8px;
        padding: 0 4px;
    }
    
    .search-input {
        padding: 10px 14px;
        font-size: 14px;
        height: 44px;
    }
    
    /* 搜索按钮 - 第三行 */
    .search-btn {
        width: 100%;
        order: 3;
        justify-content: center;
        border-radius: 10px;
        padding: 10px 16px;
        height: 44px;
        font-size: 14px;
        margin: 0;
        box-shadow: 0 2px 12px rgba(59, 130, 246, 0.2);
    }
    
    .search-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
    }
    
    /* 搜索联想层 - 手机版 */
    .search-suggest-layer {
        max-height: 280px;
        border-radius: 14px;
        margin-top: 4px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    }
    
    .suggest-item {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .suggest-hot-tag {
        font-size: 11px;
        padding: 3px 12px;
    }
    
    .suggest-hot-grid {
        gap: 4px;
        padding: 2px 16px 10px;
    }
    
    /* 分类标签 - 手机版 */
    .search-categories {
        gap: 4px;
        margin-top: 10px;
        padding-top: 10px;
    }
    
    .category-tag {
        font-size: 11px;
        padding: 3px 12px;
    }
    
    .category-tag i {
        font-size: 10px;
    }
    
    /* 下拉菜单 - 手机版 */
    .engine-dropdown {
        min-width: 180px;
        border-radius: 14px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
        padding: 6px;
        top: calc(100% + 6px);
    }
    
    .engine-dropdown .dropdown-item {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .engine-dropdown .dropdown-item img {
        width: 16px;
        height: 16px;
    }
}

/* 小屏手机 (480px以下) */
@media (max-width: 480px) {
    .search-card {
        padding: 10px 12px;
        border-radius: 12px;
        margin-bottom: 10px;
    }
    
    .engine-tabs {
        gap: 3px;
        padding-bottom: 8px;
        margin-bottom: 10px;
    }
    
    .engine-tab {
        font-size: 10px;
        padding: 3px 10px;
        border-radius: 20px;
    }
    
    .engine-tab img {
        width: 12px;
        height: 12px;
    }
    
    .engine-selector {
        height: 36px;
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .engine-selector img {
        width: 14px;
        height: 14px;
    }
    
    .search-input {
        padding: 8px 12px;
        font-size: 13px;
        height: 38px;
    }
    
    .search-btn {
        height: 38px;
        font-size: 13px;
        padding: 8px 14px;
        border-radius: 8px;
    }
    
    .search-btn i {
        font-size: 14px;
    }
    
    .category-tag {
        font-size: 10px;
        padding: 2px 10px;
    }
    
    .suggest-item {
        padding: 8px 14px;
        font-size: 12px;
    }
    
    .suggest-hot-tag {
        font-size: 10px;
        padding: 2px 10px;
    }
    
    .suggest-section-title {
        font-size: 10px;
        padding: 6px 16px 4px;
    }
    
    .search-suggest-layer {
        max-height: 220px;
        border-radius: 12px;
    }
    
    .modal-box {
        padding: 20px 16px;
        border-radius: 16px;
    }
    
    .modal-box h3 {
        font-size: 17px;
    }
    
    .modal-box .form-group input,
    .modal-box .form-group select {
        font-size: 13px;
        padding: 8px 12px;
    }
}

/* 超小屏手机 (380px以下) */
@media (max-width: 380px) {
    .search-card {
        padding: 8px 10px;
        border-radius: 10px;
    }
    
    .engine-tab {
        font-size: 9px;
        padding: 2px 8px;
    }
    
    .engine-selector {
        height: 32px;
        font-size: 11px;
        padding: 4px 10px;
    }
    
    .search-input {
        height: 34px;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .search-btn {
        height: 34px;
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .category-tag {
        font-size: 9px;
        padding: 2px 8px;
    }
    
    .engine-dropdown {
        min-width: 150px;
    }
    
    .engine-dropdown .dropdown-item {
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* 横屏手机优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .search-card {
        padding: 12px 16px;
    }
    
    .search-form {
        flex-wrap: nowrap;
        flex-direction: row;
        padding: 4px;
    }
    
    .engine-selector {
        width: auto;
        border-right: 1px solid #e2e8f0;
        border-bottom: none;
        border-radius: 10px 0 0 10px;
        flex-shrink: 0;
        min-width: 70px;
    }
    
    .search-input-wrapper {
        flex: 1;
        order: 0;
    }
    
    .search-btn {
        width: auto;
        flex-shrink: 0;
        order: 0;
        padding: 0 18px;
        border-radius: 0 10px 10px 0;
    }
    
    .engine-tabs {
        flex-wrap: wrap;
        overflow-x: visible;
    }
}

/* 有刘海屏的手机 */
@supports (padding: max(0px)) {
    .search-suggest-layer {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}