/* ================================================================
   PLAYER V2 — Drei-Zustands Musikplayer + Globale abgerundete Ecken
   Einbinden NACH visual-v2.css:
     <link rel="stylesheet" href="player-v2.css">
   ================================================================ */

/* ── Globale abgerundete Ecken ──────────────────────────────── */
:root {
  --p2-radius: 18px;
  --p2-radius-sm: 12px;
  --p2-radius-xs: 8px;
  --p2-teal:   #0d9488;
  --p2-teal-lt: #5eead4;
  --p2-blue:   #38bdf8;
  --p2-glass:  rgba(6, 10, 18, 0.92);
  --p2-border: rgba(255, 255, 255, 0.08);
  --p2-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* Toolbar & Navigationsleisten */
.toolbar,
.toolbar-actions-row,
.sh-topbar,
.sg-topbar,
.sh-tabs,
.multi-select-bar,
.quick-actions,
.context-menu,
.modal-box,
.sh-modal,
.modal,
.file-list-container,
.search-container,
.progress-container,
.pending-upload-banner,
.wakelock-badge,
.sidebar,
.mp3-player,
#mp3-player,
.toast {
  border-radius: var(--p2-radius-sm) !important;
}

.search-container {
  border-radius: var(--p2-radius) !important;
}

.multi-select-bar {
  border-radius: var(--p2-radius) !important;
}

.file-list-container {
  border-radius: var(--p2-radius) !important;
}

.action-btn-modern,
.btn-push,
.lp-cta-btn,
.toolbar-icon-btn,
.player-btn {
  border-radius: var(--p2-radius-xs) !important;
}

.sg-terminal,
.sg-terminal-header,
.sg-terminal-wrap,
.sh-stat-card,
.sh-devices,
.sh-device-icon,
.sh-card,
.sh-stat-card {
  border-radius: var(--p2-radius-sm) !important;
}

.sg-idle-logo {
  border-radius: var(--p2-radius) !important;
}

/* ================================================================
   PLAYER CONTAINER — Hülle für alle Zustände
   ================================================================ */
#p2-player-root {
  position: fixed;
  z-index: 10000;
  pointer-events: none; /* Kinder übernehmen pointer-events */
  transition: none;
}

/* Kein alter Player sichtbar */
#mp3-player.p2-hidden {
  display: none !important;
}

/* ================================================================
   ZUSTAND 1: BAR — volle Bodenleiste
   ================================================================ */
#p2-bar {
  pointer-events: all;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: auto;
  background: var(--p2-glass);
  border-top: 1px solid var(--p2-border);
  border-radius: var(--p2-radius) var(--p2-radius) 0 0;
  backdrop-filter: blur(40px) saturate(1.8);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5), 0 -1px 0 rgba(255,255,255,0.04);
  padding: 14px 24px 16px;
  display: none;
  animation: p2-bar-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#p2-bar.visible {
  display: block;
}

@keyframes p2-bar-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.p2-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

/* ── Bar: Linke Seite — Cover + Infos ── */
.p2-bar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.p2-cover {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0d9488 0%, #0ea5e9 100%);
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.45);
}

.p2-cover-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.p2-cover-note {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.p2-cover-note svg {
  width: 22px;
  height: 22px;
  stroke: rgba(255,255,255,0.85);
}

/* Vinyl-Streifen Overlay */
.p2-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.06) 3px,
    rgba(0,0,0,0.06) 4px
  );
  border-radius: inherit;
  pointer-events: none;
}

/* Spinning-Animation wenn abgespielt wird */
.p2-cover.playing {
  animation: p2-vinyl-spin 8s linear infinite;
}
@keyframes p2-vinyl-spin {
  to { transform: rotate(360deg); }
}

.p2-track-info {
  min-width: 0;
  flex: 1;
}
.p2-title, 
.p2-artist {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p2-track-name {
  font-family: 'DM Sans', 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.p2-track-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: #475569;
  margin-top: 3px;
  letter-spacing: 0.05em;
}

/* ── Bar: Mitte — Steuerung ── */
.p2-bar-center {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.p2-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  color: #64748b;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.p2-btn svg {
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.p2-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #e2e8f0;
  transform: scale(1.08);
}

.p2-btn:active {
  transform: scale(0.94);
}

.p2-btn-play {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--p2-teal), var(--p2-blue));
  border: none;
  color: white;
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.45);
}

.p2-btn-play:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 24px rgba(13, 148, 136, 0.65);
  background: linear-gradient(135deg, #0f9d91, #0ab8e8);
  color: white;
}

.p2-btn-play svg {
  width: 18px;
  height: 18px;
}

/* ── Bar: Rechte Seite — Seeker + State Toggle ── */
.p2-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  justify-content: flex-end;
}

/* ── Seek-Leiste ── */
.p2-seek-wrap {
  flex: 1;
  min-width: 80px;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.p2-seek {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgb(255, 255, 255);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  outline: none;
}

.p2-seek::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(
    to right,
    var(--p2-teal) 0%,
    var(--p2-teal) var(--p2-seek-pct, 0%),
    rgba(255,255,255,0.12) var(--p2-seek-pct, 0%),
    rgba(255,255,255,0.12) 100%
  );
  border-radius: 2px;
}

.p2-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  margin-top: -5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.p2-seek::-webkit-slider-thumb:hover {
  transform: scale(1.3);
  box-shadow: 0 0 0 4px rgba(94,234,212,0.2);
}

.p2-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  cursor: pointer;
}

/* State-Toggle Buttons */
.p2-state-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 3px;
  flex-shrink: 0;
}

.p2-state-btn {
  width: 28px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.p2-state-btn svg { width: 13px; height: 13px; }

.p2-state-btn:hover {
  background: rgba(255,255,255,0.07);
  color: #94a3b8;
}

.p2-state-btn.active {
  background: rgba(13,148,136,0.18);
  color: var(--p2-teal-lt);
  box-shadow: 0 0 0 1px rgba(13,148,136,0.3);
}

/* Bar: Untere Seek-Reihe (Vollanzeige, Mobile ausgeblendet) */
.p2-bar-seek-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.p2-bar-seek-row .p2-seek-wrap {
  max-width: none;
}

/* ================================================================
   ZUSTAND 2: FLOAT — verschiebbares Karten-Widget
   ================================================================ */
#p2-float {
  pointer-events: all;
  position: fixed;
  width: 280px;
  bottom: 24px;
  right: 24px;
  background: var(--p2-glass);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--p2-radius);
  backdrop-filter: blur(40px) saturate(1.8);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  box-shadow: var(--p2-shadow), 0 0 0 1px rgba(255,255,255,0.04);
  display: none;
  overflow: hidden;
  animation: p2-float-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  user-select: none;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
}

#p2-float.visible {
  display: block;
}

@keyframes p2-float-in {
  from { opacity: 0; transform: scale(0.88) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Drag-Handle Topbar */
.p2-float-handle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  cursor: grab;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(255,255,255,0.02);
}

.p2-float-handle:active { cursor: grabbing; }

.p2-float-drag-dots {
  display: flex;
  gap: 3px;
  align-items: center;
  flex: 1;
  justify-content: center;
}

.p2-float-drag-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
}

.p2-float-handle-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Float Cover Art */
.p2-float-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: linear-gradient(135deg, #061020 0%, #0a1828 100%);
}

.p2-float-cover-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Noten-Hintergrund wenn kein Bild */
.p2-float-cover-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0d9488 0%, #0ea5e9 50%, #7c3aed 100%);
  opacity: 0.9;
}

.p2-float-cover-bg svg {
  width: 80px;
  height: 80px;
  stroke: rgba(255,255,255,0.3);
  stroke-width: 1;
}

/* Gradient Overlay auf Cover */
.p2-float-cover-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(to top, rgba(6,10,18,0.95) 0%, transparent 100%);
}

/* Titel über dem Cover */
.p2-float-track-info {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
}

.p2-float-track-name {
  font-family: 'DM Sans', 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 8px rgba(0,0,0,0.8);
}

/* Float Controls */
.p2-float-controls {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.p2-float-seek-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.p2-float-seek-row .p2-seek-wrap {
  flex: 1;
  max-width: none;
}

.p2-float-btn-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Waveform-Balken */
.p2-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 24px;
}

.p2-wave-bar {
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(to top, var(--p2-teal), var(--p2-blue));
  opacity: 0.6;
  transform-origin: bottom;
}

.p2-waveform.playing .p2-wave-bar {
  animation: p2-wave 1.2s ease-in-out infinite;
}

.p2-wave-bar:nth-child(1)  { height: 35%; animation-delay: 0.00s; }
.p2-wave-bar:nth-child(2)  { height: 65%; animation-delay: 0.10s; }
.p2-wave-bar:nth-child(3)  { height: 100%; animation-delay: 0.20s; }
.p2-wave-bar:nth-child(4)  { height: 55%; animation-delay: 0.15s; }
.p2-wave-bar:nth-child(5)  { height: 80%; animation-delay: 0.30s; }
.p2-wave-bar:nth-child(6)  { height: 45%; animation-delay: 0.05s; }
.p2-wave-bar:nth-child(7)  { height: 90%; animation-delay: 0.25s; }
.p2-wave-bar:nth-child(8)  { height: 70%; animation-delay: 0.10s; }

@keyframes p2-wave {
  0%, 100% { transform: scaleY(0.3); opacity: 0.3; }
  50%       { transform: scaleY(1);   opacity: 0.9; }
}

/* ================================================================
   ZUSTAND 3: MINI — Cover-Thumbnail in der Ecke
   ================================================================ */
#p2-mini {
  pointer-events: all;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  display: none;
  box-shadow: var(--p2-shadow);
  animation: p2-mini-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

#p2-mini.visible {
  display: block;
}

#p2-mini:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 0 2px rgba(94,234,212,0.3);
}

@keyframes p2-mini-in {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

.p2-mini-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--p2-teal), var(--p2-blue));
}

.p2-mini-note {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.p2-mini-note svg {
  width: 28px;
  height: 28px;
  stroke: rgba(255,255,255,0.9);
}

/* Play/Pause Overlay bei Hover */
.p2-mini-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  backdrop-filter: blur(4px);
}

#p2-mini:hover .p2-mini-overlay {
  opacity: 1;
}

.p2-mini-overlay svg {
  width: 22px;
  height: 22px;
  stroke: white;
}

/* Puls-Ring wenn abgespielt */
#p2-mini.playing::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 20px;
  border: 2px solid rgba(94,234,212,0.5);
  animation: p2-mini-pulse 2s ease-in-out infinite;
  pointer-events: none;
  z-index: 5;
}

@keyframes p2-mini-pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.04); }
}

/* Track-Name Tooltip */
.p2-mini-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  background: rgba(6,10,18,0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 7px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.p2-mini-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 20px;
  border: 5px solid transparent;
  border-top-color: rgba(255,255,255,0.1);
  border-bottom: none;
}

#p2-mini:hover .p2-mini-tooltip {
  opacity: 1;
  transform: translateY(0);
}

/* ================================================================
   DATEILISTEN-PADDING ANPASSUNG
   ================================================================ */
.file-list-container.p2-pad-bar    { padding-bottom: var(--p2-bar-height, 90px) !important; }
.file-list-container.p2-pad-float  { padding-bottom: 0 !important; }
.file-list-container.p2-pad-mini   { padding-bottom: 0 !important; }
.file-list-container.p2-pad-hidden { padding-bottom: 0 !important; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
  .p2-bar-inner {
    grid-template-columns: 1fr auto;
    gap: 12px;
  }

  .p2-bar-seek-row {
    display: none; /* Auf Mobile: nur obere Steuerung */
  }

  .p2-bar-right .p2-seek-wrap {
    display: flex; /* Seek in der rechten Seite auf Mobile */
    max-width: 120px;
  }

  #p2-float {
    width: calc(100vw - 32px);
    right: 16px;
    left: 16px;
    bottom: 16px;
  }

  #p2-mini {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 480px) {
  .p2-bar-inner {
    grid-template-columns: 1fr auto;
  }
  .p2-bar-right .p2-seek-wrap {
    display: none;
  }
}

/* ================================================================
   ÜBERGANGS-ANIMATIONEN
   ================================================================ */
.p2-state-exit {
  animation: p2-exit 0.2s ease forwards !important;
}

@keyframes p2-exit {
  to { opacity: 0; transform: scale(0.92); }
}
