/* YouTube Music Style CSS */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark theme colors like YouTube Music */
    --bg-primary: #0f0f0f;
    --bg-secondary: #212121;
    --bg-tertiary: #2a2a2a;
    --bg-hover: #3c3c3c;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --text-muted: #717171;
    --accent-color: #ff0000;
    --accent-hover: #cc0000;
    --border-color: #3c3c3c;
    --player-bg: #181818;
    --sidebar-width: 240px;
    --header-height: 64px;
    --player-height: 88px;
    --player-expanded-height: 100vh;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Header */
.header {
    position: relative;
    height: var(--header-height);
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
    display: flex;
    align-items: center;
}

.header-content {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0 16px;
}

.header-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    margin-right: 16px;
    transition: background-color 0.2s;
}

.menu-btn:hover {
    background-color: var(--bg-hover);
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.logo-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-center {
    flex: 1;
    max-width: 600px;
    margin: 0 40px;
}

.search-container {
    position: relative;
    display: flex;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.search-container:focus-within {
    border-color: var(--accent-color);
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 0 24px 24px 0;
    transition: background-color 0.2s;
}

.search-btn:hover {
    background-color: var(--bg-hover);
}

.header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.profile-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
}

.profile-btn:hover {
    background-color: var(--bg-hover);
}

/* Sidebar */
.sidebar {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height) - var(--player-height));
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    z-index: 900;
    overflow-y: auto;
    padding: 12px 0;
    transition: transform 0.3s ease;
}

.sidebar-nav {
    padding: 0 12px;
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 400;
}

.nav-link:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active .nav-link {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 500;
}

.nav-link svg {
    margin-right: 24px;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    margin-left: 0;
    margin-top: 0;
    margin-bottom: var(--player-height);
    padding: 0;
    min-height: calc(100vh - var(--player-height));
}

.section {
    margin-bottom: 48px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title {
    font-size: 24px;
    font-weight: 400;
    color: var(--text-primary);
}

.see-all-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s;
}

.see-all-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sort-select {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

/* Horizontal Scroll for Playlists */
.horizontal-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    margin: 0 -12px;
    padding: 0 12px;
}

.horizontal-scroll::-webkit-scrollbar {
    height: 8px;
}

.horizontal-scroll::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.horizontal-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.horizontal-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.playlist-grid {
    display: flex;
    gap: 16px;
    padding-bottom: 8px;
}

.playlist-card {
    flex: 0 0 200px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.playlist-card:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-color);
}

.playlist-thumbnail {
    width: 100%;
    height: 120px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    border-radius: 4px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.playlist-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.playlist-info h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.playlist-info p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* Albums Grid */
.albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.album-card {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.album-card:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-color);
}

.album-thumbnail {
    width: 100%;
    height: 148px;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.album-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-play-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
    background-color: var(--accent-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.2s;
}

.album-card:hover .album-play-btn {
    opacity: 1;
    transform: translateY(0);
}

.album-info h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.album-info p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Tracks List */
.tracks-list {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
}

.track-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.track-item:last-child {
    border-bottom: none;
}

.track-item:hover {
    background-color: var(--bg-hover);
}

.track-item.playing {
    background-color: rgba(255, 0, 0, 0.08);
    border-left: 3px solid var(--accent-color);
    padding-left: 13px;
}

.track-item.playing .track-number {
    position: relative;
    color: transparent;
}

.track-item.playing .track-number::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.5; transform: translate(-50%, -50%) scale(0.8); }
}

.track-number {
    width: 32px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    margin-right: 16px;
}

.track-thumbnail {
    position: relative;
    width: 40px;
    height: 40px;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    margin-right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.track-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.track-info {
    flex: 1;
    min-width: 0;
}

.track-title {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-item.playing .track-title {
    color: var(--accent-color);
}

.track-artist {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-duration {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 16px;
    min-width: 40px;
    text-align: right;
}

.load-more-container {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

.load-more-btn {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.load-more-btn:hover {
    background-color: var(--bg-hover);
}

/* Bottom Player */
.bottom-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--player-bg);
    border-top: 1px solid var(--border-color);
    z-index: 1100;
}

.player-mini {
    height: var(--player-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.player-track-info {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.player-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    margin-right: 12px;
    object-fit: cover;
}

.player-text {
    min-width: 0;
    flex: 1;
}

.player-title {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-artist {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-controls-mini {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background-color: var(--bg-hover);
}

.play-pause-btn svg {
    width: 24px;
    height: 24px;
}

/* Expanded Player */
.player-expanded {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--player-bg);
    z-index: 1200;
    display: flex;
    flex-direction: column;
}

.player-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
}

.collapse-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    margin-right: 16px;
    transition: background-color 0.2s;
}

.collapse-btn:hover {
    background-color: var(--bg-hover);
}

.player-header-title {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-primary);
}

.player-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.player-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    max-width: 480px;
    margin: 0 auto;
}

.player-artwork {
    width: 320px;
    height: 320px;
    margin-bottom: 32px;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-artwork img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-info {
    text-align: center;
    margin-bottom: 48px;
}

.expanded-title {
    font-size: 32px;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.2;
}

.expanded-artist {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.expanded-album {
    font-size: 14px;
    color: var(--text-muted);
}

.player-controls {
    width: 100%;
    max-width: 480px;
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}

.play-pause-btn-large {
    width: 64px;
    height: 64px;
    background-color: var(--accent-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.play-pause-btn-large:hover {
    background-color: var(--accent-hover);
    transform: scale(1.05);
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.time-current,
.time-total {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 32px;
    text-align: center;
}

.progress-container {
    flex: 1;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background-color: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background-color: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
}

.volume-row {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.volume-slider {
    width: 100px;
    height: 4px;
    background-color: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background-color: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
}

/* Player Sidebar (Queue) */
.player-sidebar {
    width: 320px;
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.queue-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.queue-header h4 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.queue-clear-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.queue-clear-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.queue-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.queue-item {
    display: flex;
    align-items: center;
    padding: 8px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.queue-item:hover {
    background-color: var(--bg-hover);
}

.queue-item.current {
    background-color: var(--bg-hover);
}

.queue-thumbnail {
    width: 40px;
    height: 40px;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    margin-right: 12px;
    overflow: hidden;
}

.queue-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.queue-info {
    flex: 1;
    min-width: 0;
}

.queue-title {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item.current .queue-title {
    color: var(--accent-color);
}

.queue-artist {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: var(--text-primary);
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --mobile-player-clearance: 172px;
    }

    .sidebar {
        display: flex;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .content-views {
        padding-bottom: 140px; /* Extra space for taller mobile player bar */
    }

    /* Mobile Player Bar - stacked layout */
    body .player-bar {
        display: grid;
        flex-direction: column;
        grid-template-columns: 44px minmax(0, 1fr) 38px 46px 54px 46px 38px minmax(0, 1fr) 44px;
        grid-template-areas:
            "crossfade track track track track track track track radio"
            ". . shuffle prev play next repeat . ."
            "progress progress progress progress progress progress progress progress progress";
        align-items: center;
        height: auto !important;
        padding: 8px 12px calc(20px + env(safe-area-inset-bottom));
        row-gap: 8px;
        column-gap: 6px;
    }

    body .player-track-info {
        grid-area: track;
        width: 100%;
        margin: 0;
        padding: 8px;
        padding-right: 32px;
        background: rgba(255,255,255,0.05);
        border-radius: 8px;
        position: relative;
        flex-shrink: 0;
    }

    /* Expand indicator arrow */
    body .player-track-info::after {
        content: 'expand_less';
        font-family: 'Material Icons';
        font-size: 20px;
        color: #717171;
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        pointer-events: none;
    }

    body .player-track-info:active {
        background: rgba(255,255,255,0.1);
    }

    body .player-thumbnail {
        width: 40px;
        height: 40px;
    }

    body .player-title {
        font-size: 15px;
        font-weight: 700;
    }

    body .player-artist {
        font-size: 11.5px;
    }

    body .player-controls {
        display: contents;
        transform: none;
    }

    body .control-buttons {
        display: contents;
    }

    body .control-button {
        width: 36px;
        height: 36px;
    }

    body #crossfadeBtn,
    body #radioBtn {
        position: static;
        width: 40px;
        height: 40px;
    }

    body #crossfadeBtn {
        grid-area: crossfade;
    }

    body #radioBtn {
        grid-area: radio;
    }

    body #shuffleBtn {
        grid-area: shuffle;
        justify-self: center;
        width: 36px;
        height: 36px;
    }

    body #prevBtn {
        grid-area: prev;
        justify-self: center;
        width: 46px;
        height: 46px;
    }

    body #playPauseBtn {
        grid-area: play;
        justify-self: center;
    }

    body #nextBtn {
        grid-area: next;
        justify-self: center;
        width: 46px;
        height: 46px;
    }

    body #repeatBtn {
        grid-area: repeat;
        justify-self: center;
        width: 36px;
        height: 36px;
    }

    body #shuffleBtn .material-icons,
    body #repeatBtn .material-icons {
        font-size: 24px;
    }

    body #prevBtn .material-icons,
    body #nextBtn .material-icons {
        font-size: 30px;
    }

    body .play-pause-button {
        width: 50px;
        height: 50px;
    }

    body .play-pause-button .material-icons {
        font-size: 30px;
    }

    body .progress-container {
        grid-area: progress;
        width: 100%;
        margin-bottom: 10px;
    }

    body .progress-bar {
        height: 6px;
    }

    body .progress-handle {
        width: 16px;
        height: 16px;
    }

    body .track-view {
        bottom: calc(var(--mobile-player-clearance) + env(safe-area-inset-bottom));
    }

    body .track-view-content {
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
        scroll-padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }

    body .track-view-lyrics {
        padding-bottom: calc(96px + env(safe-area-inset-bottom));
    }

    .header-center {
        margin: 0 16px;
    }
    
    .albums-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    
    .player-content {
        flex-direction: column;
    }
    
    .player-sidebar {
        width: 100%;
        height: 50%;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
    
    .player-main {
        padding: 20px;
    }
    
    .player-artwork {
        width: 240px;
        height: 240px;
        margin-bottom: 24px;
    }
    
    .expanded-title {
        font-size: 24px;
    }
}
