/* ============================================
   MUSIC.CSS - 音乐选择器样式
   ============================================ */

/* --- MUSIC PICKER (REDESIGNED) --- */
.music-picker-container {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    margin-top: 1rem;
    width: 100%;
    animation: fadeIn 0.8s var(--easing) forwards;
}

.music-picker-container.active {
    display: flex;
}

/* Search Area */
.music-search-wrapper {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    z-index: 5;
}

.music-source-toggle,
.music-filter-toggle {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.music-source-toggle {
    margin-bottom: 0.1rem;
}

.music-filter-toggle {
    margin-top: -0.2rem;
}

.music-filter-toggle.hidden {
    display: none;
}

.source-btn,
.filter-btn {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.3s var(--easing);
    font-family: var(--font-sans);
}

.source-btn:hover,
.filter-btn:hover {
    transform: translateY(-1px);
}

.source-btn.active,
.filter-btn.active {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

body.light-theme .source-btn,
body.light-theme .filter-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #111;
}

body.light-theme .source-btn.active,
body.light-theme .filter-btn.active {
    background: rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.25);
}

.music-input-group {
    position: relative;
    width: 100%;
    height: 56px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 28px;
    display: flex;
    align-items: center;
    padding: 0 6px;
    backdrop-filter: blur(12px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.music-input-group:focus-within {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.input-icon {
    width: 44px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    margin-left: 8px;
}

.input-icon svg {
    width: 20px;
    height: 20px;
}

#musicLinkInput {
    flex: 1;
    height: 100%;
    background: transparent;
    border: none;
    font-size: 1rem;
    color: #fff;
    padding: 0 10px;
    font-family: var(--font-sans);
    text-align: left;
}

body.light-theme #musicLinkInput {
    color: #333;
}

body.light-theme .music-input-group {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .input-icon {
    color: rgba(0, 0, 0, 0.4);
}

.fetch-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #4facfe;
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s var(--easing);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.fetch-btn:hover:not(:disabled) {
    transform: scale(1.05);
    background: #00f2fe;
}

.fetch-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
    box-shadow: none;
}

body.light-theme .fetch-btn:disabled {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.2);
}

.music-status-text {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.3s;
    min-height: 20px;
    line-height: 1.4;
}

body.light-theme .music-status-text {
    color: rgba(0, 0, 0, 0.5);
}

.music-status-text.error {
    color: #ff6b6b;
}

.music-status-text.success {
    color: #51cf66;
}

/* Music Results */
.music-results {
    display: none;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
    max-width: 480px;
    max-height: 220px;
    overflow-y: auto;
    padding: 0.2rem 0.2rem 0.4rem;
}

.music-results.visible {
    display: flex;
}

.music-result-item {
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border-radius: 16px;
    padding: 0.6rem 0.8rem;
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 0.75rem;
    align-items: center;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s var(--easing);
}

.music-result-item:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
}

.music-result-item.active {
    border-color: #00f2fe;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.18);
}

.music-result-cover {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.music-result-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    overflow: hidden;
}

.music-result-title {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music-result-artist {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music-result-chip {
    font-size: 0.65rem;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.7);
}

body.light-theme .music-result-item {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #111;
}

body.light-theme .music-result-item:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.2);
}

body.light-theme .music-result-item.active {
    border-color: rgba(0, 0, 0, 0.35);
    background: rgba(0, 0, 0, 0.12);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

body.light-theme .music-result-artist {
    color: rgba(0, 0, 0, 0.5);
}

body.light-theme .music-result-chip {
    background: rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.6);
}

/* Active Music Content */
.music-content {
    width: 100%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.3);
    animation: cardPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

body.light-theme .music-content {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.1);
}

@keyframes cardPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.album-art-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
}

#albumArtImg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
    position: relative;
    z-index: 2;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.vinyl-record {
    position: absolute;
    top: 5px;
    right: -20px;
    width: 90px;
    height: 90px;
    background: #111;
    border-radius: 50%;
    z-index: 1;
    background: repeating-radial-gradient(#111 0, #111 2px, #222 3px, #222 4px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.5s ease;
}

.track-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    text-align: left;
}

#trackTitle {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-sans);
    opacity: 0;
    animation: fadeIn 0.5s ease forwards 0.2s;
}

#trackArtist {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 1rem;
    font-family: var(--font-sans);
    opacity: 0;
    animation: fadeIn 0.5s ease forwards 0.3s;
}

body.light-theme #trackArtist {
    color: rgba(0, 0, 0, 0.5);
}

.audio-control-wrapper {
    width: 100%;
    opacity: 0;
    animation: fadeIn 0.5s ease forwards 0.4s;
}

/* Custom Audio Styles */
audio {
    width: 100%;
    height: 32px;
    opacity: 0.9;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

audio::-webkit-media-controls-panel {
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
}

body.light-theme audio::-webkit-media-controls-panel {
    background-color: rgba(240, 240, 240, 0.8);
}

/* --- MOBILE RESPONSIVE --- */
@media (max-height: 700px) {
    .music-picker-container {
        gap: 1rem;
        margin-top: 0.5rem;
    }

    .music-search-wrapper {
        gap: 0.5rem;
    }

    .music-input-group {
        height: 48px;
    }

    .music-results {
        max-height: 180px;
        /* Increased from 120px */
    }

    .music-result-item {
        padding: 0.4rem 0.6rem;
        gap: 0.6rem;
        grid-template-columns: 36px 1fr auto;
    }

    .music-result-cover {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    .music-stage {
        max-height: 140px;
    }

    .music-content {
        padding: 1rem;
        gap: 1rem;
    }

    .album-art-wrapper {
        width: 70px;
        height: 70px;
    }

    .vinyl-record {
        width: 60px;
        height: 60px;
        right: -15px;
    }

    #trackTitle {
        font-size: 0.95rem;
    }

    #trackArtist {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }

    audio {
        height: 28px;
    }
}

@media (max-height: 600px) {
    .music-picker-container {
        gap: 0.5rem;
        margin-top: 0.2rem;
    }

    .music-search-wrapper {
        gap: 0.3rem;
    }

    .music-input-group {
        height: 40px;
        /* Smaller input */
    }

    .music-results {
        max-height: 160px;
        /* Increased from 90px to allow ~3 items */
    }

    .music-result-item {
        padding: 0.3rem 0.5rem;
        min-height: 48px;
    }


    .music-stage {
        max-height: 110px;
    }

    .music-content {
        padding: 0.8rem;
        gap: 0.8rem;
        border-radius: 16px;
    }

    .album-art-wrapper {
        width: 55px;
        height: 55px;
    }

    .vinyl-record {
        width: 45px;
        height: 45px;
        right: -10px;
        top: 3px;
    }

    #trackTitle {
        font-size: 0.85rem;
    }

    #trackArtist {
        font-size: 0.75rem;
        margin-bottom: 0.3rem;
    }

    audio {
        height: 24px;
    }

    .source-btn,
    .filter-btn {
        padding: 4px 10px;
        font-size: 0.7rem;
    }

    .music-status-text {
        font-size: 0.75rem;
        min-height: 16px;
    }
}

@media (max-width: 400px) {
    .music-content {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .track-details {
        text-align: center;
    }

    .album-art-wrapper {
        width: 80px;
        height: 80px;
    }

    .vinyl-record {
        display: none;
    }
}