/* AerMusic CSS 修复补丁 */

/* ============================================================
 * 修复 4: 拆分 topbar，搜索框与标题分离
 * ============================================================ */

/* 将 #top-bar 改为 flex-start，让 logo 和搜索框各自独立定位 */
#top-bar {
    justify-content: flex-start !important;
    gap: 2vh;
}

/* Logo 保持原位 */
#app-logo {
    flex-shrink: 0;
    pointer-events: auto;
}

/* 搜索框独立定位，避免被 topbar 的 pointer-events: none 影响 */
.search-container {
    position: relative;
    z-index: 2200 !important; /* 高于搜索页、设置页的 overlay */
    pointer-events: auto !important;
}

/* ============================================================
 * 修复 5: 修复搜索框在搜索页被隐藏的问题
 * ============================================================ */

/* 确保搜索框始终可见且在最上层 */
body.page-search-center .search-container,
body.page-search-results .search-container {
    z-index: 2200 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* 搜索结果容器的 z-index 应该低于搜索框 */
#search-results-page {
    position: relative;
    z-index: 1400;
}

#search-overlay {
    z-index: 1500 !important;
}

/* 搜索建议下拉框应该在搜索框下方但高于内容 */
.search-suggestions {
    z-index: 2199 !important;
}

/* ============================================================
 * 修复 6: 优化搜索框在不同状态下的表现
 * ============================================================ */

/* 搜索页居中模式 */
body.page-search-center .search-container {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
    width: 50vh !important;
    z-index: 2200 !important;
}

/* 搜索结果页模式 */
body.page-search-results .search-container {
    position: fixed !important;
    top: 4vh !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 2200 !important;
}

/* 确保在搜索模式下 logo 不干扰 */
body.page-search-center #app-logo,
body.page-search-results #app-logo {
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

/* ============================================================
 * 修复 7: 确保搜索框输入框可交互
 * ============================================================ */

.search-container input {
    pointer-events: auto !important;
    z-index: 1 !important;
}

.search-container .btn {
    pointer-events: auto !important;
    z-index: 1 !important;
}

/* ============================================================
 * 性能优化：减少不必要的 GPU 加速
 * ============================================================ */

/* 只对需要动画的元素启用 GPU 加速 */
.search-container {
    will-change: transform, opacity;
}

body:not(.page-search-center):not(.page-search-results) .search-container {
    will-change: auto;
}

/* ============================================================
 * 播放器布局：缩短歌曲信息区与歌词 iframe 的距离
 * ============================================================ */

/* 原主样式里 .lyric-side 的 margin-left 为 300px，非纯净歌词模式下显得过远。
 * 这里使用响应式间距，既不贴太近，也避免大屏过度分散。
 */
body:not(.only-lyrics-enabled) .song-page:not(.lyrics-hidden) .lyric-side {
    margin-left: clamp(5vh, 6vw, 11vh) !important;
}

body.only-lyrics-enabled .lyric-side,
.song-page.lyrics-hidden .lyric-side {
    margin-left: 0 !important;
}

/* 只显示歌词模式：彻底隐藏底部 Genius 控制栏与进度滑杆 */
body.only-lyrics-enabled #fixed-genius-bar,
body.only-lyrics-enabled #fixed-genius-bar.hidden,
body.only-lyrics-enabled .genius-progress-container,
body.only-lyrics-enabled .fixed-genius-content,
body.only-lyrics-enabled .fixed-seek-input {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* 只显示歌词模式：确保歌词 iframe 自身裁切，由 iframe 内 mask 做边缘淡出 */
body.only-lyrics-enabled .lyric-side,
body.only-lyrics-enabled .lyric-side iframe {
    overflow: hidden !important;
}

/* ============================================================
 * 设置页：歌词对齐选择框美化
 * ============================================================ */

.lyric-align-select {
    width: auto !important;
    min-width: 12vh !important;
    padding: 0.7vh 3.2vh 0.7vh 1.2vh !important;
    border-radius: 1.1vh !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    background-color: rgba(10,10,12,0.72) !important;
    color: rgba(255,255,255,0.92) !important;
    font-size: 1.3vh !important;
    font-weight: 600 !important;
    outline: none !important;
    cursor: pointer !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    background-image: linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.8) 50%), linear-gradient(135deg, rgba(255,255,255,0.8) 50%, transparent 50%) !important;
    background-position: calc(100% - 1.5vh) 50%, calc(100% - 1.05vh) 50% !important;
    background-size: 0.45vh 0.45vh, 0.45vh 0.45vh !important;
    background-repeat: no-repeat !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0.8vh 2vh rgba(0,0,0,0.18) !important;
}

.lyric-align-select:hover,
.lyric-align-select:focus {
    background-color: rgba(20,20,24,0.9) !important;
    border-color: rgba(255,255,255,0.22) !important;
}

.lyric-align-select option {
    background: #141418;
    color: #fff;
}

/* ============================================================
 * 移动端歌词适配：透明背景 + 自适应歌词区域
 * ============================================================ */

@media (max-width: 768px), (pointer: coarse) and (max-width: 1024px) {
    .song-page .lyric-side {
        position: absolute !important;
        inset: 0 !important;
        background: transparent !important;
        background-color: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100svh !important;
        max-height: 100svh !important;
        padding: max(6svh, env(safe-area-inset-top)) 0 max(7svh, env(safe-area-inset-bottom)) 0 !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        overflow: hidden !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    body.mobile-lyric-active .lyric-side {
        background: transparent !important;
        background-color: transparent !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    .song-page .lyric-side iframe {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        background: transparent !important;
        overflow: hidden !important;
    }
}
