@import url('lyrics.css');

:root {
    /* Color Palette - Material/Modern */
    --primary-color: #1db954; /* Spotify Green as base */
    --primary-dark: #1aa34a;
    --surface-color: #ffffff;
    --background-color: #f5f5f5;
    --text-primary: #212121;
    --text-secondary: #757575;
    --divider-color: #e0e0e0;
    
    /* Lyric Settings (Dynamic) */
    --lyric-highlight: #1db954;
    --lyric-base: #757575;
    --lyric-size: 16px;

    /* Layout */
    --header-height: 64px;
    --footer-height: 90px;
    --sidebar-width: 400px;

    /* Effects */
    --shadow-1: 0 2px 1px -1px rgba(0,0,0,0.2), 0 1px 1px 0 rgba(0,0,0,0.14), 0 1px 3px 0 rgba(0,0,0,0.12);
    --shadow-2: 0 3px 1px -2px rgba(0,0,0,0.2), 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12);
    --shadow-3: 0 3px 3px -2px rgba(0,0,0,0.2), 0 3px 4px 0 rgba(0,0,0,0.14), 0 1px 8px 0 rgba(0,0,0,0.12);
    --shadow-4: 0 2px 4px -1px rgba(0,0,0,0.2), 0 4px 5px 0 rgba(0,0,0,0.14), 0 1px 10px 0 rgba(0,0,0,0.12);

    --border-radius: 8px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-medium: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* App Layout */
.app-layout {
    display: grid;
    grid-template-rows: var(--header-height) 1fr var(--footer-height);
    height: 100%;
    width: 100%;
}

/* Header */
.top-app-bar {
    background: var(--surface-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-2);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--primary-color);
}

.search-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 20px;
}

.search-box {
    background: #f0f2f5;
    border-radius: 24px;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 600px;
    height: 40px;
    padding: 0 8px;
    transition: box-shadow var(--transition-fast);
}

.search-box:focus-within {
    background: #fff;
    box-shadow: var(--shadow-1);
}

.search-box select {
    border: none;
    background: transparent;
    padding: 0 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    border-right: 1px solid var(--divider-color);
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0 12px;
    font-size: 1rem;
    outline: none;
}

.search-box button {
    background: transparent;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 50%;
    transition: background-color 0.2s;
}

.search-box button:hover {
    background-color: rgba(0,0,0,0.05);
    color: var(--primary-color);
}

/* Main Container */
.main-container {
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Lyric Panel (Left) */
.lyric-panel {
    width: var(--sidebar-width);
    background: var(--surface-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    border-right: 1px solid var(--divider-color);
    z-index: 5;
}

.album-art-wrapper {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-2);
    margin-bottom: 24px;
    background: #eee;
}

.album-art-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.song-meta-large {
    margin-bottom: 20px;
    text-align: center;
}

#meta-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#meta-artist {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* List Panel (Right) */
.list-panel {
    flex: 1;
    background: var(--background-color);
    overflow-y: auto;
    padding: 24px;
}

.list-tabs {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--divider-color);
    padding-bottom: 8px;
}

.tab-btn {
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 8px 16px;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

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

.tab-btn.active {
    color: var(--primary-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -9px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary-color);
}

.track-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.track-card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-1);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
}

.track-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
    border-color: var(--primary-color);
}

.track-card-cover {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    object-fit: cover;
    background: #eee;
}

.track-card-info {
    flex: 1;
    min-width: 0;
}

.track-card-title {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-card-artist {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.track-card-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.track-card:hover .track-card-actions {
    opacity: 1;
}

/* Bottom Player */
.bottom-player {
    background: var(--surface-color);
    border-top: 1px solid var(--divider-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    justify-content: space-between;
    z-index: 20;
}

.player-info-mini {
    width: 250px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-controls-center {
    flex: 1;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.control-buttons {
    display: flex;
    align-items: center;
    gap: 24px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s, background 0.2s;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(0,0,0,0.05);
}

.fab-mini {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-2);
    transition: transform 0.1s, background 0.2s;
}

.fab-mini:hover {
    transform: scale(1.05);
    background: var(--primary-dark);
}

.fab-mini:active {
    transform: scale(0.95);
}

.progress-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Custom Range Slider */
.slider-container {
    flex: 1;
    position: relative;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    cursor: pointer;
}

.slider-track {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    width: 0%; /* JS updates this */
    pointer-events: none;
}

input[type=range] {
    position: absolute;
    top: -6px; /* center vertically over 4px track */
    left: 0;
    width: 100%;
    height: 16px;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

/* Hover effect for slider thumb indicator */
.slider-container:hover .slider-track::after {
    content: '';
    position: absolute;
    right: -6px;
    top: -4px;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.player-actions-right {
    width: 250px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.volume-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 120px;
}

/* Settings Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-card {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 12px;
    padding: 24px;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal-overlay.show .modal-card {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 500;
}

.setting-item {
    margin-bottom: 24px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.color-options {
    display: flex;
    gap: 12px;
}

.color-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-btn.active {
    border-color: #333;
    transform: scale(1.1);
}

/* Loading */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    z-index: 200;
    display: none;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 16px;
    color: #e0e0e0;
}

/* Pagination */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    padding: 16px 0;
    grid-column: 1 / -1;
}

.page-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--divider-color);
    background: var(--surface-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Top Lists */
.toplist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
}

.toplist-card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.toplist-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-2);
}

.toplist-cover {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #eee;
}

.toplist-info {
    padding: 12px;
}

.toplist-name {
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toplist-update {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.toplist-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.toplist-header h3 {
    font-size: 1.25rem;
    font-weight: 500;
}

/* Settings Select */
.setting-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--divider-color);
    border-radius: 4px;
    background: white;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
}

.setting-select:focus {
    border-color: var(--primary-color);
}

/* Download Manager UI */
.download-view {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.download-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--divider-color);
}

.download-stats {
    display: flex;
    gap: 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.download-stats b {
    color: var(--primary-color);
}

.download-tabs-sub {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.sub-tab {
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid var(--divider-color);
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.sub-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.dl-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    max-height: 400px;
}

.dl-item {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-1);
}

.dl-item-info {
    flex: 1;
    min-width: 0;
}

.dl-title {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dl-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    align-items: center;
}

.dl-progress-bg {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.dl-progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.2s;
}

.dl-actions {
    display: flex;
    gap: 8px;
}

.text-btn {
    background: transparent;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px 8px;
}

.text-btn:hover {
    text-decoration: underline;
}

.batch-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.dl-section-title {
    margin: 20px 0 12px;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .app-layout {
        grid-template-rows: auto 1fr auto;
    }

    .main-container {
        flex-direction: column;
        overflow-y: auto; /* Allow window scroll on mobile */
    }

    .lyric-panel {
        width: 100%;
        height: 40vh; /* Mobile lyric height */
        flex-shrink: 0;
        border-right: none;
        border-bottom: 1px solid var(--divider-color);
        padding: 16px;
    }

    .album-art-wrapper {
        width: 120px; /* Smaller cover on mobile */
        margin: 0 auto 12px;
    }

    .list-panel {
        overflow: visible; /* Content flows naturally */
    }

    .player-info-mini, .player-actions-right {
        display: none;
    }

    .bottom-player {
        justify-content: center;
        padding: 12px;
    }
    
    .player-controls-center {
        max-width: 100%;
    }
    
    .search-wrapper {
        padding: 0 10px;
    }
    
    .search-box {
        border-radius: 8px;
    }
}
