/* Reset & Base Styles */
* { 
    -webkit-tap-highlight-color: transparent; 
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Lexend', Segoe UI, Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: rgb(30, 30, 46);
    color: #fff;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    overflow-x: hidden;
}

/* Player Container */
.container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 20px;
    width: 100vw;
    height: 100dvh;
    max-width: 1000px;
    max-height: auto;
    border-radius: 0;
    box-shadow: none;
    border: none;
    margin: 0;
    position: relative;
    backdrop-filter: blur(10px);
}

/* Top Action Buttons (theme, fullscreen) */
#fullscreen-btn,
#theme-btn {
    position: absolute;
    top: 10px;
    background: rgba(255, 255, 255, .1);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    bottom: 10px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all .3s;
    z-index: 10;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, .2);
}

#fullscreen-btn {
    right: 20px;
}

#theme-btn {
    right: 60px;
}

/* Layout Pieces */
.top-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.album-cover {
    width: 175px;
    height: 175px;
    border-radius: 10px;
    background: linear-gradient(45deg, #4a00e0, #8e2de2);
    box-shadow: 0 5px 15px rgba(0, 0, 0, .3);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    margin: 0 auto 30px auto;
    transition: width .2s ease, height .2s ease, border-radius .2s ease;
    cursor: pointer;
}

.album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Prevent the album cover (and the image inside it) from being selectable or draggable */
.album-cover,
.album-cover img {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}

/* When an actual cover image is present, remove the placeholder gradient background */
.album-cover.has-cover {
    background: transparent !important;
}


.album-cover.expanded {
    /* Size to the largest square that fits the viewport without causing scroll.
       We take the smaller of (viewport height - reserved space) and (viewport width - side padding).
       Adjust the reserved values if your layout changes. */
    width: min(calc(100dvh - 160px), calc(100vw - 40px)) !important;
    height: min(calc(100dvh - 175px), calc(100vw - 40px)) !important;
    max-width: 100% !important;
    max-height: 100% !important;
    box-sizing: border-box;
    border-radius: 1px !important;
}

.track-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.artist {
    color: #1db954;
    font-size: 18px;
    font-weight: 600;
}

/* Middle Section */
.middle-section {
    margin-bottom: 20px;
}

.time-display {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 14px;
    color: #b3b3b3;
}

.progress-container {
    position: relative;
    height: 6px;
    background: rgba(255, 255, 255, .1);
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden;
}

#progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    border-radius: 3px;
    transition: width .4s ease-out;
    background: #145c2c;
}

#progress-bar.gradient {
    background: linear-gradient(90deg, #145c2c 0%, #1db954 60%, #a8ff78 100%);
    background-size: 200% 100%;
    background-position: left;
}

.progress-container:hover {
    opacity: 1;
}

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    margin-top: 0;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    border: none;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    cursor: pointer;
    transition: all .3s;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, .2);
}

.control-btn.active {
    color: #1db954;
    background: rgba(29, 185, 84, .2);
}

.play-btn {
    width: 60px;
    height: 60px;
    background: #1db954;
    font-size: 24px;
    border: none;
    box-shadow: 0 4px 10px rgba(29, 185, 84, .3);
}

.play-btn i {
    position: relative;
}

.play-btn i.fas.fa-play {
    left: 2px;
}

/* Status and Login */
.status {
    margin-top: 20px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .05);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-20px);
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.6);
}

.login-btn {
    width: 100%;
    padding: 12px;
    border-radius: 25px;
    background: #1db954;
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    margin-top: 20px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.6);

}

/* Portrait Orientation */
@media (orientation: portrait) {
    .container {
        min-height: calc(100dvh - 216px);
        padding-left: 5px;
        padding-right: 5px;
        padding-top: 20px;
    }

    .album-cover {
        width: 320px !important;
        height: 320px !important;
        border-radius: 10px;
        max-width: 100vw !important;
        max-height: auto !important;
    }

    .album-cover.expanded {
        width: 360px !important;
        height: 360px !important;
        border-radius: 1px;
        max-width: 100vw !important;
        max-height: auto !important;
    }

    .play-btn {
        width: 70px !important;
        height: 70px !important;
        font-size: 28px !important;
    }

    .top-row {
        padding-top: 48px;
    }
}

/* Landscape Orientation */
@media (orientation: landscape) {
    .top-row {
        flex-direction: row;
        align-items: center;
        margin-bottom: 10px;
        padding-top: 5px;
    }

    .album-cover {
        margin: 0 20px 0 0 !important;
        transform: none !important;
    }

    body {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Login elements positioning in landscape mode */
    .status.login-landscape {
        position: absolute;
        top: 50%;
        left: 50%;
    /* keep centered but shifted up 20px to match .status */
    transform: translate(-50%, calc(-50% - 20px));
        margin: 0;
        padding: 15px 20px;
        text-align: center;
        font-size: 16px;
        font-weight: 600;
        background: rgba(255, 255, 255, .1);
        border-radius: 10px;
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, .2);
        z-index: 5;
    }

    .login-btn.login-landscape {
        position: absolute;
        top: 60%;
        left: 50%;
        transform: translate(-50%, -50%);
        margin: 0;
        width: auto;
        padding: 15px 30px;
        font-size: 16px;
        z-index: 5;
    }

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

    .middle-section {
        margin-bottom: 24px;
    }

    /* Hide track info when showing login in landscape */
    .track-info.hidden-for-login {
        display: none;
    }
}

/* Small Screens */
@media (max-width: 500px) {
    .container {
        padding: 8px;
    }

    .track-info {
        width: 100%;
    }
}

/* Landscape Small Height */
@media (orientation: landscape) and (max-height: 500px) {
    .container {
        padding: 20px 32px 16px 32px;
    }

    .status {
        margin-top: 16px;
    }

    .login-btn {
        margin-top: 16px;
    }

    .title {
        font-size: 18px;
    }

    .artist {
        font-size: 16px;
    }
}

/* Dark Mode */
.dark-mode body {
    background: #121212;
}

.dark-mode .container {
    background: rgba(18, 18, 18, .95);
    border-color: rgba(255, 255, 255, .04);
}

.dark-mode #progress-bar {
    background: #fff !important;
    background-image: none !important;
}

.dark-mode .progress-container {
    background: #4d4d4d;
}

.dark-mode .play-btn {
    background: #4c278e;
    box-shadow: 0 4px 10px rgba(76, 39, 142, .55);
}

.dark-mode .play-btn:hover {
    background: #5a3998;
}

.dark-mode .artist {
    color: #6932eb;
}

.dark-mode #shuffle.active,
.dark-mode #repeat.active {
    color: #a27dee;
    background: #331664;
    border-color: rgba(255, 255, 255, .04);
}

/* Version Info */
#version-info {
    position: absolute;
    top: 5px;
    left: 5px;
    color: #2d2d2d00;
    font-size: 8px;
    font-weight: 900;
    z-index: 9999;
    letter-spacing: 1px;
    pointer-events: none;
    font-family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif;
    display: block;
}

:fullscreen #version-info {
    display: none !important;
}
