/* ===== CSS Variables ===== */
:root {
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #242424;
    --bg-card: #1e1e1e;
    --bg-card-hover: #2a2a2a;
    --bg-glass: rgba(30, 30, 30, 0.8);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-tertiary: #6e6e6e;
    --accent: #fa233b;
    --accent-hover: #fc4c5f;
    --accent-glow: rgba(250, 35, 59, 0.3);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --sidebar-width: 240px;
    --player-height: 88px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
}

a { text-decoration: none; color: inherit; }
button { background: none; border: none; cursor: pointer; color: inherit; font-family: inherit; }
input { background: none; border: none; outline: none; color: inherit; font-family: inherit; }

/* ===== Background Blur ===== */
#bg-blur {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 0;
    background: var(--bg-primary);
    transition: background 1.5s ease;
    pointer-events: none;
}

#bg-blur::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at 30% 20%, var(--bg-blur-color, transparent) 0%, transparent 60%);
    opacity: 0.4;
    transition: background 1.5s ease;
}

/* ===== App Layout ===== */
#app {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: 1fr var(--player-height);
    height: 100vh;
    position: relative;
    z-index: 1;
}

/* ===== Sidebar ===== */
#sidebar {
    grid-row: 1 / 3;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    overflow-y: auto;
}

#sidebar::-webkit-scrollbar { width: 0; }

.sidebar-header {
    padding: 0 24px 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
}

.logo span {
    background: linear-gradient(135deg, var(--accent), #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    padding: 0 12px;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
    color: var(--accent);
    background: rgba(250, 35, 59, 0.12);
}

.sidebar-playlists {
    margin-top: 24px;
    padding: 0 12px;
}

.sidebar-title {
    padding: 0 14px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    transition: all var(--transition);
    cursor: pointer;
}

.playlist-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.playlist-item.active {
    color: var(--accent);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 24px 0;
}

.stats-info {
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.6;
}

/* ===== Main Content ===== */
#main-content {
    grid-column: 2;
    grid-row: 1;
    overflow-y: auto;
    padding: 0 32px 32px;
    position: relative;
}

#main-content::-webkit-scrollbar {
    width: 8px;
}
#main-content::-webkit-scrollbar-track {
    background: transparent;
}
#main-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
#main-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== Top Bar ===== */
#top-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 20px 0;
    background: linear-gradient(to bottom, var(--bg-primary) 70%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 0 16px;
    width: 360px;
    height: 40px;
    transition: all var(--transition);
}

.search-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 2px var(--accent);
}

.search-icon {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

#search-input {
    width: 100%;
    padding: 0 12px;
    font-size: 14px;
}

#search-input::placeholder {
    color: var(--text-tertiary);
}

/* ===== Views ===== */
.view {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-header {
    margin-bottom: 24px;
}

.view-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.view-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    margin: 32px 0 16px;
}

/* ===== Album Grid ===== */
.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.album-card {
    cursor: pointer;
    transition: all var(--transition);
    border-radius: var(--radius-md);
    padding: 12px;
    background: transparent;
}

.album-card:hover {
    background: rgba(255, 255, 255, 0.05);
}

.album-card:hover .album-art {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.album-card:hover .album-art .play-overlay {
    opacity: 1;
}

.album-art {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: box-shadow var(--transition);
}

.album-art-bg {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.album-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.play-overlay {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.play-overlay:hover {
    background: var(--accent-hover);
    transform: scale(1.08);
}

.play-overlay svg {
    width: 20px;
    height: 20px;
    fill: white;
    margin-left: 2px;
}

.album-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.album-artist {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.album-year {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ===== Artist Grid ===== */
.artist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 24px;
}

.artist-card {
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    padding: 16px;
    border-radius: var(--radius-lg);
}

.artist-card:hover {
    background: rgba(255, 255, 255, 0.05);
}

.artist-avatar {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    transition: transform var(--transition);
}

.artist-card:hover .artist-avatar {
    transform: scale(1.05);
}

.artist-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.artist-count {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== Album Detail View ===== */
.album-detail-header {
    display: flex;
    gap: 32px;
    align-items: flex-end;
    padding: 24px 0 32px;
}

.album-detail-art {
    width: 240px;
    height: 240px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    flex-shrink: 0;
}

.album-detail-art .album-art-bg {
    font-size: 56px;
}

.album-detail-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-detail-info {
    flex: 1;
}

.album-detail-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.album-detail-title {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.1;
}

.album-detail-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.album-detail-meta .dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.album-detail-actions {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    align-items: center;
}

.btn-play-all {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background: var(--accent);
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    transition: all var(--transition);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-play-all:hover {
    background: var(--accent-hover);
    transform: scale(1.03);
}

.btn-shuffle-all {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition);
}

.btn-shuffle-all:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ===== Track List ===== */
.track-list {
    margin-top: 16px;
}

.track-list-header {
    display: grid;
    grid-template-columns: 40px 1fr 120px 60px;
    gap: 16px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.track-item {
    display: grid;
    grid-template-columns: 40px 1fr 120px 60px;
    gap: 16px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    align-items: center;
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}

.track-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.track-item.playing {
    background: rgba(250, 35, 59, 0.1);
}

.track-item.playing .track-number {
    color: var(--accent);
}

.track-item.playing .track-name {
    color: var(--accent);
}

.track-number {
    font-size: 15px;
    color: var(--text-tertiary);
    text-align: center;
    position: relative;
}

.track-item:hover .track-number-text {
    display: none;
}

.track-item:hover .track-play-icon {
    display: flex;
}

.track-play-icon {
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    fill: var(--text-primary);
}

.track-item.playing .track-number-text {
    display: none;
}

.track-item.playing .track-playing-icon {
    display: flex;
}

.track-playing-icon {
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.track-info {
    overflow: hidden;
}

.track-name {
    font-size: 15px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-artist {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-album {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-duration {
    font-size: 13px;
    color: var(--text-tertiary);
    text-align: right;
}

/* Equalizer animation for playing track */
.equalizer {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.equalizer-bar {
    width: 3px;
    background: var(--accent);
    border-radius: 2px;
    animation: eq 0.8s ease-in-out infinite;
}

.equalizer-bar:nth-child(1) { animation-delay: 0s; }
.equalizer-bar:nth-child(2) { animation-delay: 0.2s; }
.equalizer-bar:nth-child(3) { animation-delay: 0.4s; }

@keyframes eq {
    0%, 100% { height: 4px; }
    50% { height: 16px; }
}

/* ===== Artist Detail View ===== */
.artist-detail-header {
    display: flex;
    gap: 32px;
    align-items: center;
    padding: 40px 0;
}

.artist-detail-avatar {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    flex-shrink: 0;
}

.artist-detail-name {
    font-size: 56px;
    font-weight: 700;
}

/* ===== Search Results ===== */
.search-results {
    margin-top: 24px;
}

.search-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.search-empty svg {
    width: 64px;
    height: 64px;
    opacity: 0.3;
    margin-bottom: 16px;
}

/* ===== Player Bar ===== */
#player-bar {
    grid-column: 2;
    grid-row: 2;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    z-index: 20;
}

.player-section {
    display: flex;
    align-items: center;
}

/* Now Playing */
.now-playing {
    gap: 12px;
    min-width: 0;
}

.now-playing-art {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.now-playing-art .album-art-bg {
    font-size: 20px;
}

.now-playing-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.art-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
}

.now-playing-info {
    min-width: 0;
    flex: 1;
}

.now-playing-title {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.now-playing-artist {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Player Controls */
.player-controls {
    flex-direction: column;
    gap: 8px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.control-buttons {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: center;
}

.player-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition);
    padding: 4px;
    border-radius: 50%;
}

.player-icon-btn:hover {
    color: var(--text-primary);
}

.player-icon-btn.active {
    color: var(--accent);
}

.play-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.play-btn:hover {
    transform: scale(1.06);
}

.progress-section {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.time-display {
    font-size: 11px;
    color: var(--text-tertiary);
    min-width: 36px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.progress-bar {
    flex: 1;
    cursor: pointer;
    padding: 6px 0;
}

.progress-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    position: relative;
    transition: height var(--transition);
}

.progress-bar:hover .progress-track {
    height: 6px;
}

.progress-fill {
    height: 100%;
    background: var(--text-primary);
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
    position: relative;
}

.progress-bar:hover .progress-fill {
    background: var(--accent);
}

.progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.progress-bar:hover .progress-handle {
    opacity: 1;
}

/* Volume */
.volume-section {
    gap: 8px;
    justify-content: flex-end;
}

.volume-bar {
    width: 100px;
    cursor: pointer;
    padding: 6px 0;
}

.volume-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    position: relative;
}

.volume-fill {
    height: 100%;
    background: var(--text-primary);
    border-radius: 2px;
    width: 100%;
}

.volume-bar:hover .volume-fill {
    background: var(--accent);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    #app {
        grid-template-columns: 200px 1fr;
    }
    :root {
        --sidebar-width: 200px;
    }
    .album-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 16px;
    }
    .album-detail-art {
        width: 180px;
        height: 180px;
    }
    .album-detail-title {
        font-size: 36px;
    }
}

@media (max-width: 768px) {
    #app {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr var(--player-height);
    }
    #sidebar {
        display: none;
    }
    #main-content {
        grid-column: 1;
        padding: 0 16px 16px;
    }
    #player-bar {
        grid-template-columns: 1fr auto 1fr;
        padding: 0 12px;
    }
    .volume-section {
        display: none;
    }
    .now-playing-info {
        max-width: 120px;
    }
    .album-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    .album-detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .track-list-header,
    .track-item {
        grid-template-columns: 32px 1fr 50px;
    }
    .track-album {
        display: none;
    }
    .album-detail-title {
        font-size: 28px;
    }
    .search-wrapper {
        width: 100%;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
