:root {
    --primary-color: #6a5af9;
    --secondary-color: #f0f2f5;
    --background-color: #ffffff;
    --text-color: #333;
    --light-text-color: #777;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --success-color: #28a745;
    --warning-color: #ffc107;
    --error-color: #dc3545;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    background-color: var(--secondary-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.main-container {
    display: grid;
    grid-template-columns: 350px 1.5fr 0.8fr;
    width: 100%;
    max-width: 1800px;
    height: 90vh;
    max-height: 900px;
    background: var(--background-color);
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--shadow-color);
    overflow: hidden;
}

.left-panel, .middle-panel {
    padding: 30px;
    overflow-y: auto;
}

.lyrics-panel {
    padding: 30px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.left-panel {
    border-right: 1px solid var(--border-color);
}

.middle-panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.lyrics-panel h2 {
    font-size: 20px;
    margin-bottom: 20px;
}

.lyrics-content {
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.8;
    color: var(--light-text-color);
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
    min-height: 0;
}

h1 {
    font-size: 24px;
    margin-bottom: 20px;
}

/* Config Section */
.config-section {
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.config-header {
    background-color: var(--secondary-color);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.config-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.toggle-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.toggle-btn:hover {
    background-color: rgba(106, 90, 249, 0.1);
}

.config-content {
    padding: 15px;
    transition: all 0.3s ease;
}

.config-content.collapsed {
    display: none;
}

/* Sync Status */
.sync-status {
    background-color: #e3f2fd;
    color: #1976d2;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 15px;
    border-left: 3px solid #1976d2;
}

.sync-status.syncing {
    background-color: #fff3e0;
    color: #f57c00;
    border-left-color: #f57c00;
}

.sync-status.success {
    background-color: #e8f5e8;
    color: #2e7d32;
    border-left-color: #2e7d32;
}

.sync-status.error {
    background-color: #ffebee;
    color: #c62828;
    border-left-color: #c62828;
}

/* Search and Filter Controls */
.search-controls {
    margin-right: 15px;
}

.search-input {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 12px;
    width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(106, 90, 249, 0.2);
}

.filter-controls {
    margin-right: 15px;
}

.filter-controls select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 12px;
}

/* Playlist Section */
.playlist-section {
    background-color: var(--background-color);
    border-top: 1px solid var(--border-color);
    padding: 15px;
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 12px 12px 0 0;
    margin-top: 20px;
    min-height: 0;
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.playlist-header h3 {
    margin: 0;
    font-size: 14px;
    color: var(--text-color);
    flex: 1;
}

.toggle-playlist-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 3px;
    transition: background-color 0.2s;
    min-width: 32px;
    text-align: center;
}

.toggle-playlist-btn:hover {
    background-color: rgba(106, 90, 249, 0.1);
}

.playlist-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    transform-origin: bottom;
}

.playlist-content.expanded {
    max-height: 60vh;
}

.playlist-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.playlist-btn {
    background-color: var(--secondary-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.playlist-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.playlist-list {
    max-height: 400px;
    overflow-y: auto;
}

.playlist-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 6px;
    background-color: var(--card-bg);
}

.playlist-item:hover {
    background-color: var(--secondary-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(106, 90, 249, 0.1);
}

.playlist-item.playing {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.playlist-item .song-cover {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    margin-right: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.playlist-item .song-info {
    flex: 1;
    margin-right: 8px;
    min-width: 0;
}

.playlist-item .song-title {
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item .song-meta {
    color: var(--light-text-color);
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item .favorite-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    border-radius: 2px;
    transition: all 0.2s;
}

.playlist-item .favorite-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.playlist-item .favorite-btn.favorited {
    color: #ff6b6b;
}

/* Drag and Drop Styles */
.playlist-item {
    cursor: move;
    user-select: none;
}

.playlist-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.playlist-item.drag-over {
    border-top: 2px solid var(--primary-color);
}

.playlist-item .play-count {
    font-size: 10px;
    color: var(--light-text-color);
    margin-left: 8px;
}

.playlist-item .play-count::before {
    content: "▶ ";
}

/* Lazy Loading */
.song-item img {
    transition: opacity 0.3s ease;
}

.song-item img.loading {
    opacity: 0.5;
}

.song-item img.loaded {
    opacity: 1;
}

/* Archive Section */
.archive-section {
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

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

.archive-header h3 {
    margin: 0;
    font-size: 14px;
    color: var(--text-color);
}

.toggle-archive-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.toggle-archive-btn:hover {
    background-color: rgba(106, 90, 249, 0.1);
}

.archive-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.archive-content.expanded {
    max-height: 300px;
}

.archive-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.archive-btn {
    background-color: var(--secondary-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.archive-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.archive-list {
    max-height: 200px;
    overflow-y: auto;
}

.archive-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 5px;
}

.archive-item:hover {
    background-color: var(--secondary-color);
}

.archive-item .archive-info {
    flex: 1;
    margin-right: 8px;
}

.archive-item .archive-title {
    font-weight: 500;
    margin-bottom: 2px;
}

.archive-item .archive-meta {
    color: var(--light-text-color);
    font-size: 10px;
}

.archive-item .archive-actions {
    display: flex;
    gap: 4px;
}

.archive-item .restore-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 2px;
    transition: background-color 0.2s;
}

.archive-item .restore-btn:hover {
    background-color: rgba(106, 90, 249, 0.1);
}

.archive-item .delete-btn {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 2px;
    transition: background-color 0.2s;
}

.archive-item .delete-btn:hover {
    background-color: rgba(198, 40, 40, 0.1);
}

/* Archive buttons in task items */
.archive-song-btn, .archive-task-btn {
    background: none;
    border: none;
    color: var(--light-text-color);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 2px;
    transition: all 0.2s;
    margin-left: 4px;
}

.archive-song-btn:hover, .archive-task-btn:hover {
    color: var(--primary-color);
    background-color: rgba(106, 90, 249, 0.1);
}

/* Icon Buttons */
.icon-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 4px;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: translateY(0);
}

/* Favorite Heart Button */
.favorite-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

.favorite-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.favorite-btn.favorited {
    color: #ff6b6b;
}

.favorite-btn:not(.favorited) {
    color: #ccc;
}

.favorite-btn:not(.favorited):hover {
    color: #ff6b6b;
}

/* Sync Status Display */
.sync-status-display {
    margin-top: 15px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.sync-status-display h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--text-color);
}

.sync-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.sync-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 12px;
}

.sync-label {
    color: var(--light-text-color);
    font-weight: 500;
}

.sync-value {
    color: var(--text-color);
    font-weight: 600;
}

.sync-value.synced {
    color: #2e7d32;
}

.sync-value.unsynced {
    color: #f57c00;
}

.sync-value.outdated {
    color: #c62828;
}

/* API Key Section */
.api-key-section {
    margin-bottom: 20px;
}
.api-key-section label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    display: block;
}
.api-key-input-wrapper {
    display: flex;
    gap: 10px;
}

/* Firebase Config Section */
.firebase-config-section {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.firebase-config-section label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    display: block;
}
.firebase-config-section textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    resize: vertical;
    min-height: 80px;
}
.firebase-status {
    margin-top: 8px;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
}
.firebase-status.connected {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.firebase-status.disconnected {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.firebase-status.loading {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Firebase Login Section */
.firebase-login-section {
    margin-top: 15px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.firebase-login-section button {
    margin-right: 10px;
    margin-bottom: 10px;
}

/* Form Elements */
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 14px;
}
input[type="text"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    background-color: var(--secondary-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(106, 90, 249, 0.2);
}

.tags-input-wrapper {
    position: relative;
}

.autocomplete-items {
    position: absolute;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background-color: var(--background-color);
    border-radius: 8px;
    box-shadow: 0 4px 15px var(--shadow-color);
}

.autocomplete-items div {
    padding: 10px;
    cursor: pointer;
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
}

.autocomplete-items div:hover {
    background-color: var(--secondary-color);
}

.common-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.tag-button {
    background-color: var(--secondary-color);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    border: 1px solid var(--border-color);
}

.tag-button:hover {
    background-color: var(--primary-color);
    color: white;
}

button {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.2s, transform 0.1s;
}
button:hover {
    background-color: #5244d5;
}
button:active {
    transform: scale(0.98);
}
button.secondary {
    background-color: #6c757d;
}
button.secondary:hover {
    background-color: #5a6268;
}

/* Task List */
.task-list-header {
    padding: 0 0 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}
.task-list-header h2 {
    font-size: 20px;
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.auto-refresh-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.auto-refresh-toggle input[type="checkbox"] {
    width: auto;
}

.loader {
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-left: 8px;
}

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

#tasks-container {
    flex-grow: 1;
    overflow-y: auto;
    padding-top: 20px;
}

.task-item {
    background: var(--background-color);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s, border-color 0.2s;
}
.task-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px var(--shadow-color);
}
.task-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.task-item-header p {
    font-size: 12px;
    color: var(--light-text-color);
    margin: 0;
}

.task-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reuse-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reuse-btn:hover {
    background-color: #8b7cf6;
    transform: translateY(-1px);
}

.reuse-btn:active {
    transform: translateY(0);
}

.task-item .status {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}
.status-SUCCESS { background-color: #e9f7ef; color: var(--success-color); }
.status-IN_PROGRESS, .status-QUEUED, .status-SUBMITTED { background-color: #fff8e1; color: var(--warning-color); }
.status-FAILURE { background-color: #fbe9e7; color: var(--error-color); }

.song-list {
    margin-top: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.song-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    overflow: hidden;
}

.song-item:hover {
    background-color: var(--secondary-color);
    border-color: var(--primary-color);
}

.song-item.selected {
    border-color: var(--primary-color);
    background-color: #f0eeff;
}

.song-item img {
    width: 100%;
    height: auto;
    display: block;
}

.song-item-info {
    padding: 10px;
}

.song-item-info h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-item-info p {
    font-size: 11px;
    color: var(--light-text-color);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Music Player */
.music-player {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}
.player-content {
    display: flex;
    align-items: center;
}
.player-info {
    flex-grow: 1;
}
.player-info h3 {
    margin: 0 0 5px 0;
    font-size: 18px;
}
.player-info p {
    margin: 0;
    font-size: 14px;
    color: var(--light-text-color);
}
.player-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}
.player-controls button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.2s ease;
}

.player-controls button:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

.player-controls a {
    text-decoration: none;
}

#player-image-container {
    width: 50px;
    height: 50px;
    margin-right: 15px;
    flex-shrink: 0; /* Prevent container from shrinking */
}

#player-image-container img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    cursor: pointer;
    margin-top: 10px;
}
.progress-bar {
    width: 0;
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 3px;
}
.time-display {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--light-text-color);
    margin-top: 5px;
}

/* Utility */
.hidden {
    display: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--secondary-color);
}
::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}