:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --accent-color: #1db954;
    --accent-hover: #1ed760;
    --border-color: #333;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background: #000;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1db954;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.header-right {
    display: flex;
    align-items: center;
}

#search-input {
    background: #333;
    border: none;
    color: #fff;
    border-radius: 4px;
}

main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

#library-section {
    flex: 2;
    padding: 1rem;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

#guestbook-section {
    flex: 1;
    padding: 1rem;
    background-color: var(--card-bg);
    display: flex;
    flex-direction: column;
}

/* Track List */
.track-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.track-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

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

.track-item.active {
    background-color: rgba(29, 185, 84, 0.2);
}

.track-check {
    margin-right: 1rem;
}

.track-info {
    flex: 1;
}

.track-title {
    font-weight: bold;
    display: block;
}

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

/* Player Bar */
#player-bar {
    height: 80px;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    justify-content: space-between;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

button {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: 0.2s;
}

button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

button.primary {
    background-color: var(--text-primary);
    color: var(--bg-color);
}

button.primary:hover {
    transform: scale(1.05);
}

/* Guestbook */
#comment-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.comment-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.comment-content {
    font-size: 0.9rem;
}

#comment-form {
    display: flex;
    gap: 0.5rem;
}

#comment-form input {
    background-color: #333;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
}

/* Checkbox Styles */
.track-checkbox {
    margin-right: 15px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #1db954;
}

.track-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Active Button Style (Shuffle) */
button.active {
    color: #1db954 !important;
    text-shadow: 0 0 10px rgba(29, 185, 84, 0.5);
    /* Glow effect */
    transform: scale(1.1);
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .header-left,
    .header-right {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    header h1 {
        font-size: 1.2rem;
        margin: 0;
    }

    .header-right {
        gap: 5px;
    }

    #search-input {
        flex: 1;
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    #btn-rescan {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
    }

    .track-item {
        padding: 1rem;
        /* Larger touch area */
    }

    .track-title {
        font-size: 1.1rem;
    }

    .track-artist {
        font-size: 0.9rem;
    }

    .track-checkbox {
        width: 24px;
        height: 24px;
        margin-right: 20px;
    }

    /* Player Controls */
    .player-controls {
        gap: 20px;
    }

    .control-btn {
        font-size: 1.5rem;
        padding: 10px;
    }

    #btn-play {
        font-size: 2rem;
    }

    .track-stats {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }

    /* Stack Main Content */
    main {
        flex-direction: column;
    }

    #library-section {
        flex: none;
        height: 30vh;
        /* Give library less than half screen height to ensure guestbook space */
        border-right: none;
        border-bottom: 1px solid #333;
        overflow-y: auto;
        transition: height 0.3s ease, flex 0.3s ease;
    }

    #library-section.expanded {
        flex: 1;
        height: auto;
    }

    #guestbook-section {
        flex: 1;
        /* Guestbook takes remaining space */
        min-height: 0;
        /* Important for nested flex scrolling */
        transition: flex 0.3s ease, min-height 0.3s ease;
    }

    #guestbook-section.collapsed {
        flex: 0 0 auto;
        min-height: auto;
        overflow: hidden;
    }

    #guestbook-section.collapsed #comment-list,
    #guestbook-section.collapsed #comment-form {
        display: none;
    }
}

/* Toggle Button Transition */
#btn-toggle-gb {
    transition: transform 0.3s ease;
}

#guestbook-section.collapsed #btn-toggle-gb {
    transform: rotate(-90deg);
}