/**
 * Global Audio Player: Pille unten rechts, Tasten per Knopf, YouTube-Video im Menue
 */

.global-audio-player {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 10000000;
    display: none;
    align-items: center;
    gap: 10px;
    height: 44px;
    max-width: min(340px, calc(100vw - 28px));
    padding: 0 4px 0 14px;
    border-radius: 22px;
    background-color: rgba(42, 42, 42, 0.55);
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    color: #fff;
    cursor: pointer;
    user-select: none;
    outline: none;
    transition: right 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.global-audio-player.loaded {
    display: flex;
}

/* Auf der JukeBox-Seite hat die JukeBox ihre eigene Leiste unten */
html[data-zckn-app="jb"] .global-audio-player,
html[data-zckn-app="calc"] .global-audio-player {
    display: none !important;
}

/* Titel und Dauer - mit eingeblendeten Tasten ausgeblendet */
.track-info {
    min-width: 0;
    max-width: 220px;
    line-height: 1.2;
}

.track-title {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-time {
    font-size: 10px;
    color: #999;
    font-family: 'Courier New', monospace;
}

.time-separator {
    margin: 0 3px;
    color: #666;
}

.global-audio-player .player-controls {
    display: none;
    align-items: center;
    gap: 6px;
}

.global-audio-player.visible .track-info {
    display: none;
}

.global-audio-player.visible .player-controls {
    display: flex;
}

/* Kleiner Knopf (Menue offen): Note, bei laufender Musik animierte EQ-Baender */
.gap-eq {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.gap-eq-bars {
    display: none;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.gap-eq-bars i {
    width: 3px;
    height: 100%;
    border-radius: 1px;
    background: var(--accent-color, #fff);
    transform-origin: bottom;
    animation: gap-eq 0.9s ease-in-out infinite;
}

.gap-eq-bars i:nth-child(2) { animation-duration: 0.7s; animation-delay: -0.3s; }
.gap-eq-bars i:nth-child(3) { animation-duration: 1.1s; animation-delay: -0.5s; }
.gap-eq-bars i:nth-child(4) { animation-duration: 0.8s; animation-delay: -0.1s; }

@keyframes gap-eq {
    0%, 100% { transform: scaleY(0.25); }
    50% { transform: scaleY(1); }
}

.global-audio-player.playing .gap-eq .gap-icon { display: none; }
.global-audio-player.playing .gap-eq-bars { display: flex; }

/* Menue offen: Pille wird zum runden Knopf direkt links neben dem Menue (Breite wie side-panel.css).
   Eingefahren (Longpress auf den Knopf rechts): derselbe runde Knopf unten rechts. */
body.side-panel-open .global-audio-player,
html.zckn-frame-panel .global-audio-player {
    right: calc(min(420px, 90vw) + 6px);
}

@media (max-width: 480px) {
    body.side-panel-open .global-audio-player,
    html.zckn-frame-panel .global-audio-player {
        right: calc(85vw + 6px);
    }
}

body.side-panel-open .global-audio-player:not(.visible),
html.zckn-frame-panel .global-audio-player:not(.visible),
.global-audio-player.mini:not(.visible) {
    width: 44px;
    padding: 0;
    justify-content: center;
}

body.side-panel-open .global-audio-player:not(.visible) .gap-eq,
html.zckn-frame-panel .global-audio-player:not(.visible) .gap-eq,
.global-audio-player.mini:not(.visible) .gap-eq {
    display: flex;
}

body.side-panel-open .global-audio-player:not(.visible) .track-info,
body.side-panel-open .global-audio-player:not(.visible) .gap-toggle,
body.side-panel-open .global-audio-player:not(.visible) .progress-bar,
html.zckn-frame-panel .global-audio-player:not(.visible) .track-info,
html.zckn-frame-panel .global-audio-player:not(.visible) .gap-toggle,
html.zckn-frame-panel .global-audio-player:not(.visible) .progress-bar,
.global-audio-player.mini:not(.visible) .track-info,
.global-audio-player.mini:not(.visible) .gap-toggle,
.global-audio-player.mini:not(.visible) .progress-bar {
    display: none !important;
}

/* Tasten */
.global-audio-player .control-btn,
.gap-yt .control-btn {
    background: rgba(255, 255, 255, 0.05) !important;
    border: none !important;
    color: #ffffff !important;
    font-size: 14px !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    border-radius: 50% !important;
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.15s, transform 0.15s !important;
    padding: 0 !important;
    box-shadow: none !important;
    flex-shrink: 0;
}

.global-audio-player .control-btn:hover,
.gap-yt .control-btn:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    transform: scale(1.08) !important;
}

.global-audio-player .control-btn:active,
.gap-yt .control-btn:active {
    transform: scale(0.95) !important;
}

.global-audio-player .play-pause-btn,
.gap-yt .play-pause-btn {
    background-color: rgba(255, 255, 255, 0.1) !important;
    font-size: 15px !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
}

.global-audio-player .gap-toggle {
    margin-left: auto;
}

.global-audio-player.visible .gap-toggle {
    color: var(--accent-color, #fff) !important;
}

.global-audio-player #global-shuffle-btn {
    opacity: 0.5;
}

.global-audio-player #global-shuffle-btn.active {
    color: var(--accent-color, #888888) !important;
    opacity: 1;
}

/* Fortschritt: feine Linie unten in der Pille */
.global-audio-player .progress-bar {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

.progress-fill {
    width: 0;
    height: 100%;
    background: var(--accent-color, #888888);
    transition: width 0.1s linear;
    pointer-events: none;
}

/* Lautstaerke (mittlere Maustaste auf der Pille) */
.volume-indicator {
    position: absolute;
    left: 16px;
    bottom: 0;
    height: 2px;
    background: var(--accent-color, #888888);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.volume-indicator.visible {
    opacity: 0.9;
}

/* Playlist ueber der Pille */
.playlist-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    width: min(360px, calc(100vw - 28px));
    max-height: 400px;
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(30, 30, 30, 0.92), rgba(20, 20, 20, 0.95));
    backdrop-filter: blur(25px) saturate(160%);
    -webkit-backdrop-filter: blur(25px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(8px);
    opacity: 0;
    pointer-events: none;
    cursor: default;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.playlist-panel.visible {
    transform: none;
    opacity: 1;
    pointer-events: auto;
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.playlist-header h3 {
    margin: 0;
    font-size: 16px;
    color: #ffffff;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

/* Stern im Titel auf derselben Zeile wie der Text */
.global-audio-player .playlist-header h3 .gap-icon {
    display: inline-block;
    flex: none;
}

.playlist-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.playlist-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.playlist-items {
    max-height: 340px;
    overflow-y: auto;
    padding: 10px;
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    position: relative;
}

.playlist-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-color, #888888);
    transition: none;
}

.playlist-item-remove {
    position: absolute;
    right: 15px;
    font-size: 16px;
    color: #ffffff;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    cursor: pointer;
    z-index: 10;
}

.playlist-item:hover .playlist-item-remove {
    opacity: 1;
}

.playlist-item-remove:hover {
    transform: scale(1.2);
    color: #ff4444;
}

.playlist-item.active {
    background: rgba(136, 136, 136, 0.2);
    border-left-color: var(--accent-color, #888888);
}

.playlist-item-number {
    font-size: 12px;
    color: #666;
    min-width: 30px;
    font-family: 'Courier New', monospace;
}

.playlist-item-name {
    flex: 1;
    color: #ffffff;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Scrollbar styling */
.playlist-items::-webkit-scrollbar {
    width: 8px;
}

.playlist-items::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.playlist-items::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.playlist-items::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive design */
/* Eingebettete SVG-Symbole (statt FontAwesome) */
.global-audio-player .gap-icon,
.gap-yt .gap-icon {
    width: 1em;
    height: 1em;
    display: block;
    pointer-events: none;
}

.playlist-item-remove .gap-icon {
    width: 16px;
    height: 16px;
}

/* YouTube-Favorit: das Video liegt fixiert im body (wird nie verschoben, sonst laedt es neu).
   Menue zu: unsichtbar unter dem Bildschirmrand, spielt weiter. Menue offen: oben im Menue,
   Lage und Groesse setzt global-audio-player.js. Klick aufs Video -> gross in der JukeBox. */
.gap-yt {
    position: fixed;
    left: 0;
    top: 100%;
    width: 128px;
    height: 72px;
    z-index: 10000001;
    overflow: hidden;
    background: #000;
    display: flex;
    flex-direction: column;
}

.gap-yt.in-menu {
    border-radius: 12px;
}

html[data-zckn-app="jb"] .gap-yt,
html[data-zckn-app="calc"] .gap-yt {
    visibility: hidden;
}

.gap-yt iframe {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    border: 0;
    display: block;
    pointer-events: none;
}

.gap-yt-hit {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    cursor: zoom-in;
}

.gap-yt-hit:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Tasten unter dem Video (Platz dafuer haelt side-panel.css frei: 48px) */
.gap-yt-controls {
    display: none;
    height: 48px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(20, 20, 20, 0.95);
}

.gap-yt.in-menu .gap-yt-controls {
    display: flex;
}

.gap-yt.in-menu .gap-yt-hit {
    bottom: 48px;
}
