/* 搜索页面专用样式 */

/* 仅在未输入时（无查询）去掉外框，输入后恢复主页的“大框”样式 */
.rt-search-page:not(.has-query) .api-list {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
}
.rt-search-page .api-grid {
    margin-top: 0 !important;
}

/* 搜索结果容器：初始隐藏，输入后显示并上移渐显进入 */
#searchApiList {
    display: none; /* 初始化为隐藏，避免布局抖动 */
	opacity: 0;
	transform: translateY(16px);
	transition: transform 420ms cubic-bezier(.22,1,.36,1), opacity 320ms ease;
    position: relative; /* 作为占位层的定位参考 */
}
.rt-search-page.has-query #searchApiList {
    display: block; /* 仅在就绪时显示，位置一次性到位 */
    opacity: 1;
    transform: translateY(0);
    margin-top: 100px;
    animation: rtsp-box-fade-in 280ms ease-out both;
}

/* 初始不显示占位文案，按需由JS显示 */
#rtspPlaceholder { display: none; }

/* 搜索占位框样式：未输入时显示一个简洁的提示框 */
.rtsp-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    width: 100%;
    color: #6b7280;
    border: none;
    background: transparent;
    font-size: 16px;
    text-align: center;
}
html.theme-dark .rtsp-placeholder {
    color: #9ca3af;
    border: none;
    background: transparent;
}

/* 全屏搜索页（滑入下一页） */
.rt-search-page {
    position: fixed;
    left: 0;
    right: 0; /* 与主页相同宽度，不做避让 */
    top: 80px;   /* 与主页内容起始位置一致 */
    bottom: 0;
    background: transparent;
    z-index: 950; /* 低于导航栏(1000)与右侧边栏(1200) */
    pointer-events: none; /* 默认不拦截事件，打开后启用 */
}

/* 独立搜索页面样式 - 当在独立页面中时使用相对定位 */
.main-content .rt-search-page {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    min-height: calc(100vh - 160px); /* 减去导航栏和页脚的高度 */
    pointer-events: auto !important; /* 独立页面中始终允许交互，提高优先级 */
    background: transparent; /* 使用透明背景，继承body的白色背景 */
}
html.theme-dark .rt-search-page { background: transparent; }
html.theme-dark .main-content .rt-search-page { background: transparent; }

/* 当导航栏收起时，搜索页顶边与视口贴齐，避免分层缝隙 */
#navbar.hidden ~ .main-content .rt-search-page { top: 0; }
#navbar.hidden ~ .main-content .rt-search-page .rtsp-sheet { border-radius: 0; }

.rtsp-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px 24px;
    pointer-events: auto; /* 确保内容容器可以交互 */
}

/* 独立搜索页面的内容容器 */
.main-content .rt-search-page .rtsp-inner {
    position: relative;
    inset: auto;
    min-height: 100%;
    padding: 40px 16px 60px;
}

.rtsp-input-wrap {
    width: min(880px, 92vw);
    transform: translateY(calc(50vh - 150px)); /* 统一使用考虑导航栏高度的居中位置 */
    transition: transform 500ms cubic-bezier(.22,1,.36,1), box-shadow 300ms ease;
    opacity: 1; /* 默认显示输入框 */
    position: relative;
    pointer-events: auto; /* 确保输入框容器可以交互 */
    z-index: 10; /* 确保输入框在所有元素之上 */
    will-change: transform; /* 优化动画性能 */
}

/* 搜索框获得焦点时的悬浮效果 */
.rtsp-input-wrap.focused {
    transform: translateY(calc(50vh - 150px)) scale(1.02);
    z-index: 20; /* 提高z-index避免冲突 */
}

/* 搜索框有内容时移动到顶部 */
.rtsp-input-wrap.has-content {
    transform: translateY(40px) scale(1);
}

.rt-sp-search {
    width: 100%;
    height: 54px;
    border-radius: 28px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #fff;
    color: #111827;
    font-size: 16px;
    padding: 0 18px;
    outline: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    pointer-events: auto; /* 确保输入框可以交互 */
    cursor: text; /* 显示文本输入光标 */
    z-index: 15; /* 确保输入框在最顶层 */
    position: relative;
}
html.theme-dark .rt-sp-search { 
    background: #171a20; 
    color: #e8e8e8; 
    border-color: rgba(255,255,255,0.08); 
}

.rtsp-results-card {
    width: min(1100px, 94vw);
    margin-top: 28px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 22px;
    box-shadow: 0 14px 50px rgba(0,0,0,0.12);
    transform: translateY(100vh); /* 初始位置在屏幕下方 */
    transition: transform 500ms cubic-bezier(.22,1,.36,1), opacity 300ms ease;
    opacity: 0;
    padding: 24px;
    min-height: 300px;
    position: relative;
    z-index: 5; /* 确保结果卡片在底板之上 */
}

/* 搜索结果框上移进入 */
.rtsp-results-card.show {
    transform: translateY(0);
    opacity: 1;
}
html.theme-dark .rtsp-results-card { 
    background: rgba(22,24,28,0.92); 
    border-color: rgba(255,255,255,0.06); 
    box-shadow: 0 20px 60px rgba(0,0,0,0.6); 
}

/* 搜索页卡片渐显上移动画（不影响主页） */
.rt-search-page .api-grid .api-card {
	opacity: 0;
	transform: translateY(12px);
	animation: search-card-enter .36s ease forwards;
}

.rt-search-page.open { pointer-events: auto; }
.rt-search-page.has-query .rtsp-input-wrap { transform: translateY(40px); opacity: 1; }
.rt-search-page.has-query .rtsp-results-card { transform: translateY(0); opacity: 1; }

/* 注：has-query状态的样式已在上面的通用规则中定义 */
.main-content .rt-search-page .rtsp-results-card {
    opacity: 0;
    transform: translateY(30px);
}
.main-content .rt-search-page.has-query .rtsp-results-card { 
    opacity: 1; 
    transform: translateY(0); 
}

/* 升起底板 */
.rtsp-sheet {
    position: absolute;
    left: 0; right: 0; bottom: 0; top: 0;
    background: #f5f7fb; /* 与主页背景保持一致 */
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.08);
    transform: translateY(100%);
    transition: transform 360ms cubic-bezier(.22,1,.36,1);
    pointer-events: none; /* 底板不应该阻止交互 */
    z-index: -1; /* 确保底板在所有内容后面 */
}
.rt-search-page.open .rtsp-sheet { transform: translateY(0); }
html.theme-dark .rtsp-sheet { background: #0f1115; }

/* 独立搜索页面隐藏底板动画 */
.main-content .rt-search-page .rtsp-sheet {
    display: none;
}

.rtsp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 8px;
}

/* 自定义滚动条 */
.rtsp-grid::-webkit-scrollbar {
    width: 6px;
}
.rtsp-grid::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-radius: 3px;
}
.rtsp-grid::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}
.rtsp-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.3);
}

/* API卡片样式 */
.rtsp-api-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    animation: search-card-enter 0.4s ease forwards;
}

.rtsp-api-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    border-color: #3b82f6;
}

html.theme-dark .rtsp-api-card {
    background: #1f2937;
    border-color: #374151;
    color: #f9fafb;
}

html.theme-dark .rtsp-api-card:hover {
    border-color: #60a5fa;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.rtsp-api-card .api-name {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
    line-height: 1.4;
}

html.theme-dark .rtsp-api-card .api-name {
    color: #f9fafb;
}

.rtsp-api-card .api-description {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

html.theme-dark .rtsp-api-card .api-description {
    color: #d1d5db;
}

.rtsp-api-card .api-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #9ca3af;
}

html.theme-dark .rtsp-api-card .api-meta {
    color: #9ca3af;
}

.rtsp-api-card .api-visits {
    background: #f3f4f6;
    padding: 4px 8px;
    border-radius: 8px;
    font-weight: 500;
}

html.theme-dark .rtsp-api-card .api-visits {
    background: #374151;
    color: #d1d5db;
}

.rtsp-api-card .api-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
}

/* 搜索动画 */
@keyframes search-card-enter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 搜索状态指示器 */
.rtsp-search-indicator {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.rtsp-search-indicator.searching {
    opacity: 1;
}

.rtsp-search-indicator .spinner {
    width: 100%;
    height: 100%;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: rtsp-spin 1s linear infinite;
}

@keyframes rtsp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 空状态和错误状态 */
.rtsp-empty-state,
.rtsp-error-state {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    animation: rtsp-fade-in 0.3s ease;
}

html.theme-dark .rtsp-empty-state,
html.theme-dark .rtsp-error-state {
    color: #9ca3af;
}

.rtsp-empty-state h3,
.rtsp-error-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #374151;
}

html.theme-dark .rtsp-empty-state h3,
html.theme-dark .rtsp-error-state h3 {
    color: #d1d5db;
}

.rtsp-empty-state p,
.rtsp-error-state p {
    font-size: 14px;
    margin: 0;
}

@keyframes rtsp-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 大框渐显动画 */
@keyframes rtsp-box-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .rtsp-input-wrap {
        width: 94vw;
    }
    
    .rtsp-results-card {
        width: 96vw;
        margin-top: 20px;
        padding: 16px;
    }
    
    .rtsp-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .rtsp-api-card {
        padding: 16px;
    }
}
