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

html, body {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow: hidden; /* no page scroll */
}

/* ===== App Layout: sidebar + main, locked to viewport ===== */
.app {
    display: flex;
    height: 100vh;
    gap: 16px;
    padding: 12px;
}

/* ===== Sidebar (Player + Queue) ===== */
.sidebar {
    flex: 0 0 320px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    transition: margin-left 0.3s ease, opacity 0.3s ease;
}

/* Collapsed state (toggled with the ☰ button) */
.app.sidebar-hidden .sidebar {
    margin-left: -336px; /* width + gap */
    opacity: 0;
    pointer-events: none;
}

.player-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 18px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.player-controls {
    margin-bottom: 16px;
}

.current-song {
    padding: 8px;
    background: #f7fafc;
    border-radius: 10px;
    font-weight: 600;
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 10px;
    word-break: break-word;
}

#audioPlayer {
    border-radius: 10px;
}

/* Queue fills the remaining sidebar height */
.queue-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.queue-title {
    font-weight: 700;
    color: #4a5568;
    margin-bottom: 10px;
    display: block;
}

.queue-list {
    background: #f7fafc;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
    flex: 1;
    min-height: 0;
    overflow-y: auto; /* queue scrolls internally */
}

.queue-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.queue-item:last-child {
    margin-bottom: 0;
}

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

.queue-item-info h4 {
    margin: 0;
    color: #2d3748;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-item-info p {
    margin: 0;
    color: #718096;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remove-queue-btn {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 8px;
    flex-shrink: 0;
}

.remove-queue-btn:hover {
    background: #c53030;
}

.btn-secondary {
    background: #718096;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn-secondary:hover {
    background: #4a5568;
}

/* ===== Main column ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px 12px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    width: 36px;
    height: 32px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
    line-height: 1;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.35);
}

header h1 {
    color: #fff;
    font-size: 1.35rem;   /* smaller title */
    font-weight: 700;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sidebar-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
    flex-shrink: 0;
}

.logout-btn {
    display: inline-block;
    background: transparent;
    color: #e53e3e;
    padding: 6px 14px;
    border: 1px solid #e53e3e;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: #e53e3e;
    color: #fff;
}

/* Only this area scrolls */
.content-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

/* ===== Songs Section ===== */
.songs-section h2 {
    color: #fff;
    font-size: 1.1rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding-left: 4px;
}

.songs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 14px;
    padding: 4px;
}

.search-input {
    margin-top: 12px;
    background: rgba(255, 255, 255, 0.95);
}

/* ===== Song cards (unchanged look) ===== */
.song-card {
    background: white;
    border-radius: 15px;
    padding: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.song-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.song-card.playing {
    border-color: #48bb78;
    background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
}

.song-thumbnail {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 15px;
}

.song-info h3 {
    margin: 0 0 5px 0;
    color: #2d3748;
    font-size: 1.2rem;
}

.song-info p {
    margin: 0 0 15px 0;
    color: #718096;
    font-size: 0.9rem;
}

.song-actions {
    display: flex;
    gap: 10px;
}

.play-btn, .queue-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.play-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.play-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.queue-btn {
    background: #e2e8f0;
    color: #4a5568;
}

.queue-btn:hover {
    background: #cbd5e0;
    transform: translateY(-2px);
}

.no-songs {
    text-align: center;
    color: #f7fafc;
    font-style: italic;
    grid-column: 1 / -1;
    padding: 40px;
}

/* ===== Auth Section (compact) ===== */
.auth-section {
    background: rgba(255, 255, 255, 0.85);
    padding: 8px 12px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin: 14px 4px;
    display: inline-block;
}

.auth-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.auth-label {
    font-weight: 700;
    color: #4a5568;
    font-size: 0.85rem;
    white-space: nowrap;
}

.auth-form input {
    width: 160px;
    padding: 7px 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.auth-form input:focus {
    outline: none;
    border-color: #667eea;
}

.auth-form button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 7px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ===== Upload Section ===== */
.upload-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 24px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin: 20px 4px;
}

.upload-section h2 {
    font-size: 1.1rem;
    color: #4a5568;
}

.upload-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #4a5568;
}

.form-group input {
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.upload-form button {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    padding: 12px 28px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* ===== Messages ===== */
.error, .success, .info {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.error {
    background: #fed7d7;
    color: #c53030;
    border-left: 4px solid #e53e3e;
}

.success {
    background: #c6f6d5;
    color: #2f855a;
    border-left: 4px solid #48bb78;
}

.info {
    background: #ebf8ff;
    color: #2b6cb0;
    border-left: 4px solid #4299e1;
}

/* Toast messages (injected by JS) — float instead of pushing layout */
.main > .error, .main > .success, .main > .info,
.app > .error, .app > .success, .app > .info {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    max-width: 320px;
}

/* Slim scrollbars */
.content-scroll::-webkit-scrollbar,
.queue-list::-webkit-scrollbar {
    width: 8px;
}

.content-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 4px;
}

.queue-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    body {
        overflow: auto; /* allow scroll on small screens */
    }

    .app {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        padding: 10px;
    }

    .sidebar {
        flex: none;
        width: 100%;
        min-width: 0;
        transition: none;
    }

    .app.sidebar-hidden .sidebar {
        display: none;
        margin-left: 0;
    }

    .player-section {
        flex: none;
    }

    .queue-list {
        max-height: 180px;
        flex: none;
    }

    .content-scroll {
        overflow: visible;
    }

    header h1 {
        font-size: 1.15rem;
    }

    .songs-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}
