/* SPDX-FileCopyrightText: 2026 Sandro Santilli */
/* SPDX-License-Identifier: AGPL-3.0-or-later */

/**
 * Mini Player Styles
 * 
 * The mini-player is a fixed-position audio player that persists across
 * soft-navigation page transitions. It provides basic playback controls
 * and track information.
 */

/* ============================================
   MINI PLAYER CONTAINER
   ============================================ */

.mini-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    direction: ltr;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    pointer-events: none;
}

.mini-player.active {
    transform: translateY(0);
    pointer-events: auto;
}

.mini-player .mini-player-inner {
    -webkit-backdrop-filter: blur(8px) brightness(60%);
    backdrop-filter: blur(8px) brightness(60%);
    background: var(--bg-1-overlay, rgba(0, 0, 0, 0.85));
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.mini-player .progress-bar {
    position: relative;
    height: 4px;
    cursor: pointer;
    transition: height 0.15s ease;
}

.mini-player .progress-bar:hover {
    height: 6px;
}

.mini-player .progress-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: var(--bg-2, rgba(255, 255, 255, 0.1));
}

.mini-player .progress-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--bg-3, rgba(255, 255, 255, 0.2));
    width: 0%;
    transition: width 0.2s ease;
}

.mini-player .progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--mg-acc, var(--accent, #ff6b35));
    width: 0%;
}

.mini-player .progress-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

/* ============================================
   CONTROLS ROW
   ============================================ */

.mini-player .controls {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.8rem;
    gap: 0.5rem;
}

/* ============================================
   BUTTONS
   ============================================ */

.mini-player button {
    background: none;
    border: none;
    color: var(--fg-1, #fff);
    cursor: pointer;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.mini-player button:hover,
.mini-player button:focus-visible {
    background: var(--bg-2, rgba(255, 255, 255, 0.1));
    color: var(--fg-2, #fff);
}

.mini-player button:active {
    background: var(--bg-3, rgba(255, 255, 255, 0.15));
}

.mini-player button[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
}

.mini-player button svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: currentColor;
}

.mini-player .btn-playback svg {
    width: 2rem;
    height: 2rem;
}

/* Shuffle and Repeat buttons */
.mini-player .btn-shuffle,
.mini-player .btn-repeat {
    opacity: 0.5;
}

.mini-player .btn-shuffle:hover,
.mini-player .btn-repeat:hover {
    opacity: 0.8;
}

.mini-player .btn-shuffle.active,
.mini-player .btn-repeat.active {
    opacity: 1;
    color: var(--mg-acc, var(--accent, #ff6b35));
}

.mini-player .btn-shuffle svg,
.mini-player .btn-repeat svg {
    width: 1.2rem;
    height: 1.2rem;
}

/* ============================================
   TRACK INFO
   ============================================ */

.mini-player .track-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.mini-player .track-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--fg-1, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-player .track-artist {
    font-size: 0.8rem;
    color: var(--fg-3, rgba(255, 255, 255, 0.6));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-player .track-title a,
.mini-player .track-artist a {
    color: inherit;
    text-decoration: none;
}

.mini-player .track-title a:hover,
.mini-player .track-artist a:hover {
    text-decoration: underline;
}

/* ============================================
   TIME DISPLAY
   ============================================ */

.mini-player .time-display {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: var(--fg-3, rgba(255, 255, 255, 0.6));
}

.mini-player .time-current {
    color: var(--fg-1, #fff);
}

.mini-player .time-separator {
    opacity: 0.5;
}

/* ============================================
   QUEUE INDICATOR
   ============================================ */

.mini-player .queue-indicator {
    font-size: 0.75rem;
    color: var(--fg-3, rgba(255, 255, 255, 0.5));
    padding: 0.2rem 0.5rem;
    background: var(--bg-2, rgba(255, 255, 255, 0.1));
    border-radius: 0.8rem;
}

/* ============================================
   LOADING STATE
   ============================================ */

.mini-player.loading .btn-playback svg {
    animation: mini-player-spin 1s linear infinite;
}

@keyframes mini-player-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 480px) {
    .mini-player .controls {
        padding: 0.4rem 0.5rem;
        gap: 0.3rem;
    }
    
    .mini-player button svg {
        width: 1.3rem;
        height: 1.3rem;
    }
    
    .mini-player .btn-playback svg {
        width: 1.8rem;
        height: 1.8rem;
    }
    
    .mini-player .time-display {
        font-size: 0.75rem;
    }
    
    .mini-player .track-title {
        font-size: 0.85rem;
    }
    
    .mini-player .track-artist {
        font-size: 0.7rem;
    }
    
    /* Hide queue indicator on small screens */
    .mini-player .queue-indicator {
        display: none;
    }
    
    /* Smaller shuffle/repeat buttons on mobile */
    .mini-player .btn-shuffle svg,
    .mini-player .btn-repeat svg {
        width: 1rem;
        height: 1rem;
    }
}

/* ============================================
   BODY PADDING WHEN PLAYER ACTIVE
   ============================================ */

body.soft-nav-player-active {
    padding-bottom: 65px !important; /* Height of mini-player */
}

@media (max-width: 480px) {
    body.soft-nav-player-active {
        padding-bottom: 58px !important;
    }
}

/* ============================================
   TRANSITION STATES FOR SOFT NAVIGATION
   ============================================ */

.swup-transition-fade .mini-player {
    /* Mini player doesn't fade during transitions */
    transition: none !important;
    transform: translateY(0) !important;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.mini-player button:focus-visible {
    outline: 2px solid var(--mg-acc, var(--accent, #ff6b35));
    outline-offset: 2px;
}

.mini-player .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   DARK/LIGHT THEME SUPPORT
   ============================================ */

@media (prefers-color-scheme: light) {
    .mini-player .mini-player-inner {
        background: var(--bg-1-overlay, rgba(255, 255, 255, 0.95));
    }
}

/* ============================================
   SHUFFLE PLAY BUTTON
   ============================================ */

.shuffle-play-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.5em 0.75em;
    margin-left: 0.5em;
    font-size: inherit;
    font-family: inherit;
    color: inherit;
    background: var(--bg-2, rgba(0, 0, 0, 0.2));
    border: 1px solid var(--mg-1, rgba(255, 255, 255, 0.2));
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.shuffle-play-btn:hover {
    background: var(--bg-acc, var(--accent, #ff6b35));
    border-color: var(--mg-acc, var(--accent, #ff6b35));
}

.shuffle-play-btn:active {
    transform: scale(0.98);
}

.shuffle-play-btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.shuffle-play-btn.loading svg {
    animation: shuffle-spin 1s linear infinite;
}

@keyframes shuffle-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.shuffle-play-btn svg {
    flex-shrink: 0;
    width: 1em;
    height: 1em;
}

/* ============================================
   TRACK MENU BUTTON
   ============================================ */

.track-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75em;
    height: 1.75em;
    padding: 0;
    margin-left: 0.5em;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s, background 0.2s;
}

.track-menu-btn:hover {
    opacity: 1;
    background: var(--bg-2, rgba(0, 0, 0, 0.1));
}

.track-menu-btn svg {
    width: 1.2em;
    height: 1.2em;
    fill: currentColor;
}

/* ============================================
   TRACK CONTEXT MENU
   ============================================ */

.track-context-menu {
    position: fixed;
    z-index: 10001;
    min-width: 200px;
    padding: 0.5rem 0;
    background: var(--bg-1, #1a1a1a);
    border: 1px solid var(--mg-1, rgba(255, 255, 255, 0.15));
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
}

.track-context-menu.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.track-context-menu .menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    color: var(--fg-1, #fff);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.track-context-menu .menu-item:hover {
    background: var(--bg-2, rgba(255, 255, 255, 0.1));
}

.track-context-menu .menu-item:focus {
    outline: none;
    background: var(--bg-2, rgba(255, 255, 255, 0.1));
}

.track-context-menu .menu-item .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    height: 1.25em;
}

.track-context-menu .menu-item .icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.track-context-menu .menu-item .label {
    flex: 1;
}

/* ============================================
   NOTIFICATIONS
   ============================================ */

.soft-nav-notification {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 10002;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    color: var(--fg-1, #fff);
    background: var(--bg-1, #1a1a1a);
    border: 1px solid var(--mg-1, rgba(255, 255, 255, 0.15));
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
}

.soft-nav-notification.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Light theme support */
@media (prefers-color-scheme: light) {
    .track-context-menu {
        background: var(--bg-1, #fff);
        border-color: var(--mg-1, rgba(0, 0, 0, 0.15));
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    }
    
    .track-context-menu .menu-item {
        color: var(--fg-1, #000);
    }
    
    .track-context-menu .menu-item:hover {
        background: var(--bg-2, rgba(0, 0, 0, 0.05));
    }
    
    .soft-nav-notification {
        background: var(--bg-1, #fff);
        color: var(--fg-1, #000);
        border-color: var(--mg-1, rgba(0, 0, 0, 0.15));
    }
}

/* ============================================
   VOLUME CONTROL
   ============================================ */

.mini-player .volume-control {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.mini-player .btn-volume {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--fg-2, rgba(255, 255, 255, 0.8));
    transition: color 0.2s, background 0.2s;
}

.mini-player .btn-volume:hover {
    color: var(--fg-1, #fff);
    background: var(--bg-2, rgba(255, 255, 255, 0.1));
}

.mini-player .btn-volume.muted {
    color: var(--fg-3, rgba(255, 255, 255, 0.5));
}

.mini-player .btn-volume svg {
    width: 1.25em;
    height: 1.25em;
    fill: currentColor;
}

.mini-player .volume-slider-container {
    position: static;
    transform: none;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
}

.mini-player .volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 5.2rem;
    height: 4px;
    background: var(--bg-3, rgba(255, 255, 255, 0.2));
    border-radius: 2px;
    cursor: pointer;
    transform: none;
    transform-origin: center;
}

.mini-player .volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--fg-1, #fff);
    border-radius: 50%;
    cursor: pointer;
}

.mini-player .volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--fg-1, #fff);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

@media (max-width: 640px) {
    .mini-player .volume-slider {
        width: 3.8rem;
    }
}

/* ============================================
   QUEUE BUTTON
   ============================================ */

.mini-player .btn-queue {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--fg-2, rgba(255, 255, 255, 0.8));
    transition: color 0.2s, background 0.2s;
}

.mini-player .btn-queue:hover {
    color: var(--fg-1, #fff);
    background: var(--bg-2, rgba(255, 255, 255, 0.1));
}

.mini-player .btn-queue.active {
    color: var(--acc, #ff6b35);
}

.mini-player .btn-queue svg {
    width: 1.25em;
    height: 1.25em;
    fill: currentColor;
}

/* ============================================
   QUEUE PANEL
   ============================================ */

.queue-panel {
    position: fixed;
    right: 1rem;
    bottom: 75px;
    width: 360px;
    max-width: calc(100vw - 2rem);
    max-height: 60vh;
    background: var(--bg-1, #1a1a1a);
    border: 1px solid var(--mg-1, rgba(255, 255, 255, 0.15));
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}

.queue-panel.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.queue-panel-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
    padding: 1rem;
    border-bottom: 1px solid var(--mg-1, rgba(255, 255, 255, 0.1));
}

.queue-panel-title h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--fg-1, #fff);
}

.queue-panel-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.queue-panel-controls .btn-clear-queue {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    color: var(--fg-2, rgba(255, 255, 255, 0.7));
    background: transparent;
    border: 1px solid var(--mg-1, rgba(255, 255, 255, 0.2));
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.queue-panel-controls .btn-download-m3u {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    color: var(--fg-2, rgba(255, 255, 255, 0.7));
    background: transparent;
    border: 1px solid var(--mg-1, rgba(255, 255, 255, 0.2));
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.queue-panel-controls .btn-clear-queue:hover,
.queue-panel-controls .btn-download-m3u:hover {
    background: var(--bg-2, rgba(255, 255, 255, 0.1));
    color: var(--fg-1, #fff);
}

.queue-panel-controls .btn-close-queue {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    background: linear-gradient(145deg, rgba(255, 59, 48, 0.9), rgba(214, 40, 40, 0.95));
    border: 1px solid rgba(255, 120, 120, 0.9);
    border-radius: 999px;
    cursor: pointer;
    color: #fff;
    box-shadow: 0 0 0 1px rgba(255, 30, 30, 0.35), 0 6px 16px rgba(0, 0, 0, 0.35);
    transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.queue-panel-controls .btn-close-queue:hover,
.queue-panel-controls .btn-close-queue:focus-visible {
    color: #fff;
    background: linear-gradient(145deg, rgba(255, 82, 71, 1), rgba(230, 57, 70, 1));
    border-color: rgba(255, 180, 180, 1);
    box-shadow: 0 0 0 2px rgba(255, 82, 71, 0.4), 0 8px 22px rgba(230, 57, 70, 0.45);
    transform: scale(1.08);
}

.queue-panel-controls .btn-close-queue:active {
    transform: scale(0.98);
}

.queue-panel-controls .btn-close-queue svg {
    width: 1.35em;
    height: 1.35em;
    fill: currentColor;
}

.queue-item.current {
    scroll-margin-top: 2rem;
    scroll-margin-bottom: 2rem;
}

.queue-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.queue-section {
    margin-bottom: 1rem;
}

.queue-section h4 {
    margin: 0 0 0.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--fg-3, rgba(255, 255, 255, 0.5));
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.queue-item:hover {
    background: var(--bg-2, rgba(255, 255, 255, 0.08));
}

.queue-item.current {
    background: var(--bg-acc-subtle, rgba(255, 107, 53, 0.15));
}

.queue-item.queue-item-played {
    opacity: 0.75;
}

.queue-item.queue-item-played .queue-item-number {
    color: var(--fg-3, rgba(255, 255, 255, 0.45));
}

.queue-item-drag {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    height: 1.25em;
    color: var(--fg-3, rgba(255, 255, 255, 0.4));
    cursor: grab;
    flex-shrink: 0;
}

.queue-item-upcoming.drag-over {
    outline: 1px dashed var(--mg-acc, var(--accent, #ff6b35));
    background: var(--bg-acc-subtle, rgba(255, 107, 53, 0.12));
}

.queue-item-upcoming.dragging {
    opacity: 0.4;
}

.queue-item-drag svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.queue-item-number {
    flex-shrink: 0;
    width: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--fg-3, rgba(201, 95, 95, 0.5));
}

.queue-item.current .queue-item-number {
    color: var(--acc, #ff6b35);
}

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

.queue-item-title {
    display: block;
    font-size: 0.9rem;
    color: var(--fg-1, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item-artist {
    display: block;
    font-size: 0.8rem;
    color: var(--fg-3, rgba(255, 255, 255, 0.5));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--fg-3, rgba(255, 255, 255, 0.4));
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.queue-item-actions {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.queue-item-move,
.queue-item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.queue-item-move {
    color: var(--fg-3, rgba(255, 255, 255, 0.45));
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.queue-item:hover .queue-item-move,
.queue-item:hover .queue-item-remove {
    opacity: 1;
}

.queue-item-move:hover:not([disabled]) {
    color: var(--fg-1, #fff);
    background: var(--bg-2, rgba(255, 255, 255, 0.1));
}

.queue-item-move[disabled] {
    opacity: 0.35 !important;
    cursor: not-allowed;
}

.queue-item-move svg,
.queue-item-remove svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

.queue-item:hover .queue-item-remove {
    opacity: 1;
}

.queue-item-remove:hover {
    color: var(--error, #f44336);
    background: var(--bg-2, rgba(255, 255, 255, 0.1));
}

.queue-item-remove svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

.queue-empty {
    padding: 2rem 1rem;
    text-align: center;
}

.queue-empty p {
    margin: 0 0 0.5rem;
    color: var(--fg-2, rgba(255, 255, 255, 0.7));
}

.queue-empty .queue-hint {
    font-size: 0.85rem;
    color: var(--fg-3, rgba(255, 255, 255, 0.5));
}

/* Light theme support for queue panel */
@media (prefers-color-scheme: light) {
    .queue-panel {
        background: var(--bg-1, #fff);
        border-color: var(--mg-1, rgba(0, 0, 0, 0.15));
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    }
    
    .queue-panel-header {
        border-bottom-color: var(--mg-1, rgba(0, 0, 0, 0.1));
    }
    
    .queue-panel-header h3 {
        color: var(--fg-1, #000);
    }
    
    .queue-item-title {
        color: var(--fg-1, #000);
    }
    
    .mini-player .volume-slider-container {
        background: var(--bg-1, #fff);
        border-color: var(--mg-1, rgba(0, 0, 0, 0.15));
    }
}
