/**
 * Glenn Bennett Music Player Styles
 * @version 1.0.0
 */

/* ═══════════════════════════════════════════════════════════════════════════
   CSS VARIABLES
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
    --player-primary: #4A90E2;
    --player-primary-dark: #667eea;
    --player-surface: rgba(255,255,255,0.12);
    --player-surface-hover: rgba(255,255,255,0.2);
    --player-text: #fff;
    --player-text-muted: rgba(255,255,255,0.7);
    --player-accent: #000000;
    --player-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BASE STYLES
   ═══════════════════════════════════════════════════════════════════════════ */
.player-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(165deg, var(--player-primary-dark) 0%, var(--player-primary) 100%);
    min-height: 100vh;
    color: var(--player-text);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: rgba(0,0,0,0.85);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ═══════════════════════════════════════════════════════════════════════════
   OFFLINE BANNER
   ═══════════════════════════════════════════════════════════════════════════ */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff6b6b;
    text-align: center;
    padding: 10px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    font-size: 14px;
    z-index: 1000;
    transform: translateY(-100%);
    transition: transform 0.3s;
}

.offline-banner.show {
    transform: translateY(0);
}

/* ═══════════════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════════════ */
.player-header {
    background: var(--player-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 15px 0 18px;
    padding-top: calc(15px + env(safe-area-inset-top, 0px));
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.player-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 15px;
}

.album-selector {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 25px;
    padding: 14px 45px 14px 22px;
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14'%3E%3Cpath fill='white' d='M7 10L2 5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
    min-width: 220px;
    max-width: 90%;
}

.album-selector option {
    background: #4A90E2;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN CONTAINER
   ═══════════════════════════════════════════════════════════════════════════ */
.player-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 25px 20px;
    padding-bottom: calc(140px + var(--player-safe-bottom));
}

/* ═══════════════════════════════════════════════════════════════════════════
   ALBUM DISPLAY
   ═══════════════════════════════════════════════════════════════════════════ */
.album-display {
    text-align: center;
    margin-bottom: 25px;
}

.album-cover {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.35);
    display: block;
    object-fit: cover;
}

.album-cover-placeholder {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Stacked covers for Favorites / virtual albums —
   Fan from bottom-left (front) toward upper-right (back),
   like a fanned stack of CD cases. */
.stacked-covers {
    width: 100%;
    aspect-ratio: 1;
    position: relative;
}

.stacked-covers img {
    position: absolute;
    width: 82%;
    height: 82%;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 4px -4px 16px rgba(0,0,0,0.45);
    transform-origin: bottom left;
}

/* ── 1 image: fill the whole area ── */
.stacked-covers.count-1 img {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.35);
    transform: none;
}

/* ── 2 images ── */
.stacked-covers.count-2 img:nth-child(1) {
    bottom: 0;
    left: 0;
    z-index: 2;
}

.stacked-covers.count-2 img:nth-child(2) {
    bottom: 0;
    left: 0;
    z-index: 1;
    transform: translate(14%, -14%) rotate(6deg);
}

/* ── 3 images ── */
.stacked-covers.count-3 img:nth-child(1) {
    bottom: 0;
    left: 0;
    z-index: 3;
}

.stacked-covers.count-3 img:nth-child(2) {
    bottom: 0;
    left: 0;
    z-index: 2;
    transform: translate(10%, -10%) rotate(5deg);
}

.stacked-covers.count-3 img:nth-child(3) {
    bottom: 0;
    left: 0;
    z-index: 1;
    transform: translate(20%, -20%) rotate(10deg);
}

/* Track cover thumbnail (replaces track number) */
.track-number {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: var(--player-text-muted);
    font-weight: 500;
}

.track-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.album-info h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 20px 0 6px;
}

.album-info p {
    font-size: 16px;
    opacity: 0.85;
}

.album-meta {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    font-size: 14px;
    color: var(--player-text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   PLAY ACTION BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.play-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 22px;
    flex-wrap: wrap;
}

.play-action-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 28px;
    padding: 12px 22px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.play-action-btn:active {
    transform: scale(0.96);
}

.play-action-btn svg {
    width: 22px;
    height: 22px;
}

.play-action-btn.primary {
    background: white;
    color: var(--player-primary-dark);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TRACK LIST
   ═══════════════════════════════════════════════════════════════════════════ */
.track-list {
    background: var(--player-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 10px;
    margin-top: 25px;
}

.track {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    gap: 14px;
    margin-bottom: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}

.track:last-child {
    margin-bottom: 0;
}

.track:hover {
    background: rgba(255,255,255,0.12);
}

.track:active {
    transform: scale(0.98);
    background: rgba(255,255,255,0.15);
}

.track.playing {
    background: rgba(255,255,255,0.2);
    border-color: var(--player-accent);
}

.track.loading {
    opacity: 0.6;
}

.track-cover {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--player-surface);
    flex-shrink: 0;
}

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

.track-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-artist {
    font-size: 14px;
    color: var(--player-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track.playing .track-title {
    color: var(--player-accent);
    font-weight: 700;
}

.track-duration {
    font-size: 15px;
    color: var(--player-text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PLAYING ANIMATION BARS
   ═══════════════════════════════════════════════════════════════════════════ */
.playing-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 18px;
    padding-right: 8px;
}

.playing-bars span {
    width: 4px;
    background: var(--player-accent);
    border-radius: 2px;
    animation: playingBars 0.8s ease-in-out infinite;
}

.playing-bars span:nth-child(1) {
    animation-delay: 0s;
    height: 10px;
}

.playing-bars span:nth-child(2) {
    animation-delay: 0.2s;
    height: 16px;
}

.playing-bars span:nth-child(3) {
    animation-delay: 0.4s;
    height: 12px;
}

@keyframes playingBars {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.5); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   BOTTOM PLAYER BAR (MINI PLAYER)
   ═══════════════════════════════════════════════════════════════════════════ */
.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(74,144,226,0.98) 0%, rgba(102,126,234,0.98) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 14px 18px;
    padding-bottom: calc(14px + var(--player-safe-bottom));
    box-shadow: 0 -4px 30px rgba(0,0,0,0.25);
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.3s;
}

.player-bar.visible {
    transform: translateY(0);
}

.mini-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255,255,255,0.2);
}

.mini-progress-fill {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0.1s linear;
}

.mini-player {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mini-player-cover {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--player-surface);
    flex-shrink: 0;
}

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

.mini-player-title {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-player-artist {
    font-size: 14px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.mini-player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONTROL BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.control-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn svg {
    width: 28px;
    height: 28px;
}

.control-btn.play-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: white;
    color: var(--player-primary);
}

.control-btn.play-btn svg {
    width: 26px;
    height: 26px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   EXPANDED PLAYER (FULL SCREEN)
   ═══════════════════════════════════════════════════════════════════════════ */
.expanded-player {
    position: fixed;
    inset: 0;
    background: linear-gradient(165deg, var(--player-primary-dark) 0%, var(--player-primary) 100%);
    z-index: 200;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(20px + var(--player-safe-bottom));
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    overflow-y: auto;
}

.expanded-player.show {
    transform: translateY(0);
}

.swipe-pill {
    width: 36px;
    height: 5px;
    background: rgba(255,255,255,0.4);
    border-radius: 3px;
    margin: 0 auto 8px;
    cursor: pointer;
}

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

.expanded-close {
    background: none;
    border: none;
    color: white;
    padding: 8px;
    cursor: pointer;
}

.expanded-album-name {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
}

.expanded-cover {
    width: 100%;
    max-width: 350px;
    aspect-ratio: 1;
    border-radius: 16px;
    margin: 0 auto 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    object-fit: cover;
}

.expanded-info {
    text-align: center;
    margin-top: 12px;
}

.expanded-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.expanded-artist {
    font-size: 18px;
    opacity: 0.85;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════════════════════════════════════════ */
.expanded-progress {
    margin-bottom: 8px;
}

.progress-bar {
    position: relative;
    height: 34px;
    cursor: pointer;
    margin-bottom: 8px;
}

.progress-track {
    position: absolute;
    top: 14px;
    left: 0;
    right: 0;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.progress-fill {
    height: 6px;
    background: white;
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
    position: absolute;
    top: 14px;
    left: 0;
    z-index: 1;
}

.progress-handle {
    z-index: 2;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 10px;
    left: 0%;
    transform: translateX(-50%);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    transition: left 0.1s linear;
    pointer-events: none;
}

.progress-times {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    opacity: 0.7;
}

/* ═══════════════════════════════════════════════════════════════════════════
   EXPANDED CONTROLS
   ═══════════════════════════════════════════════════════════════════════════ */
.expanded-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-bottom: 12px;
}

.expanded-controls .control-btn svg {
    width: 32px;
    height: 32px;
}

.expanded-controls .play-btn {
    width: 72px;
    height: 72px;
}

.expanded-controls .play-btn svg {
    width: 36px;
    height: 36px;
}

.secondary-controls {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 12px;
}

.secondary-controls .control-btn {
    opacity: 0.7;
}

.secondary-controls .control-btn.active {
    opacity: 1;
    color: #ffd700;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOADING SPINNER
   ═══════════════════════════════════════════════════════════════════════════ */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
    .expanded-cover {
        max-width: 400px;
    }
    
    .expanded-title {
        font-size: 28px;
    }
    
    .expanded-artist {
        font-size: 20px;
    }
}
