/* Global Persistent Music Player */
.global-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-top: 2px solid #ff6b35;
  padding: 1rem 2rem;
  display: none;
  z-index: 9999;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  transition: transform 0.3s ease;
}

.global-player.active {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* Add padding to body when player is active to prevent content being hidden */
body:has(.global-player.active) {
  padding-bottom: 100px;
}

@media (max-width: 768px) {
  body:has(.global-player.active) {
    padding-bottom: 140px;
  }
}

.global-player.minimized {
  transform: translateY(calc(100% - 50px));
}

/* Track Info */
.player-track-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.player-artwork {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #ff6b35, #f7931e);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

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

.player-track-name {
  font-weight: bold;
  color: #fff;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.player-track-artist {
  color: #b8b8b8;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

/* Controls */
.player-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.player-btn {
  background: rgba(255, 107, 53, 0.1);
  border: 1px solid #ff6b35;
  color: #ff6b35;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.player-btn:hover {
  background: #ff6b35;
  color: #fff;
  transform: scale(1.1);
}

.player-btn.play-pause {
  width: 50px;
  height: 50px;
  font-size: 1.2rem;
  background: #ff6b35;
  color: #fff;
}

.player-btn.play-pause:hover {
  background: #f7931e;
  transform: scale(1.15);
}

/* Progress Bar */
.player-progress-container {
  flex: 2;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 200px;
}

.player-time {
  color: #b8b8b8;
  font-size: 0.8rem;
  font-family: monospace;
  min-width: 40px;
  flex-shrink: 0;
}

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

.player-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #ff6b35, #f7931e);
  border-radius: 3px;
  transition: width 0.1s linear;
  position: relative;
}

.player-progress-bar::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.player-progress:hover .player-progress-bar {
  background: linear-gradient(90deg, #f7931e, #ff6b35);
}

/* Volume Control */
.player-volume {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.player-volume-slider {
  width: 80px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.player-volume-bar {
  height: 100%;
  background: #ff6b35;
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* Voting Section */
.player-vote-section {
    display: flex;
    flex-direction: column; /* Stack vertically */
    align-items: center; /* Center horizontally */
    gap: 0.2rem; /* Reduce gap for vertical stacking */
    flex-shrink: 0;
}

.player-vote-buttons {
    display: flex;
    gap: 0.5rem; /* Space between upvote and downvote buttons */
    align-items: center;
}

.player-vote-btn {
    background: rgba(255, 107, 53, 0.1);
    border: 1px solid #ff6b35;
    color: #ff6b35;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
    line-height: 1; /* Adjust for better vertical alignment */
}

.player-vote-btn:hover {
    background: #ff6b35;
    color: #fff;
    transform: scale(1.1);
}

.player-vote-btn.voted {
    background: #ff6b35;
    color: #fff;
}

.player-vote-count {
    color: #fff;
    font-size: 1rem; /* Slightly larger for readability */
    font-weight: bold;
    min-width: 20px; /* Ensure space for negative numbers */
    text-align: center;
}

.player-vote-cta {
    color: #b8b8b8; /* Similar to track artist */
    font-size: 0.7rem; /* Smaller hint text */
    flex-shrink: 0;
    margin-top: 0.2rem; /* Space from buttons */
}

/* Sharing Section */
.player-share-section {
    position: relative;
    flex-shrink: 0;
}

/* Reusing grid's .share-btn styles for consistency */
.player-share-section .share-btn {
    background: rgba(0, 168, 232, 0.2);
    border: 2px solid #00A8E8;
    color: #00A8E8;
    padding: 0.5rem 1rem;
    border-radius: 5px; /* Changed from 20px for consistency with grid */
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.player-share-section .share-btn:hover {
    background: rgba(0, 168, 232, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 168, 232, 0.3);
}

.player-share-menu {
    position: absolute;
    bottom: calc(100% + 10px); /* Position above the share button */
    right: 0;
    /* Styles from grid.css .share-menu */
    background: rgba(0, 30, 70, 0.95);
    border: 1px solid #004E89;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    padding: 0.5rem;
    overflow: hidden;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 150px;
}

.player-share-menu.hidden {
    display: none;
}

.player-share-option {
    background: none;
    border: none;
    color: #00A8E8; /* From grid.css .share-option */
    padding: 0.7rem 1rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    width: 100%;
}

.player-share-option:hover {
    background: rgba(0, 78, 137, 0.3); /* From grid.css .share-option:hover */
    color: #FF6B35; /* From grid.css .share-option:hover */
}

/* Close Button */
.player-close {
  background: transparent;
  border: none;
  color: #b8b8b8;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.3s ease;
  flex-shrink: 0;
}

.player-close:hover {
  color: #ff6b35;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .player-progress-container {
    min-width: 150px;
  }

  .player-volume {
    display: none;
  }
}

@media (max-width: 768px) {
  .global-player {
    padding: 0.75rem 1rem;
    gap: 1rem;
    flex-wrap: wrap;
  }

  .player-track-info {
    flex-basis: 100%;
    order: 1;
  }

  .player-controls {
    order: 2; /* Main play/pause/next/prev buttons */
    gap: 0.5rem;
  }

  .player-progress-container {
    flex-basis: 100%;
    order: 5; /* Adjusted order */
    margin-top: 0.5rem;
  }

  .player-btn {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }

  .player-btn.play-pause {
    width: 45px;
    height: 45px;
  }

  .player-vote-section {
    order: 3; /* Adjusted order */
    gap: 0.1rem; /* Adjust gap for vertical stacking */
  }

  .player-vote-btn {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }

  .player-vote-count {
    font-size: 0.9rem; /* Slightly larger for mobile readability */
  }

  .player-vote-cta {
    font-size: 0.6rem; /* Smaller hint text for mobile */
  }

  .player-share-section {
    order: 4; /* Place share button to the right */
  }

  .player-share-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
  }

  .player-share-menu {
    bottom: calc(100% + 5px); /* Adjust position for smaller screen */
    right: 0;
    width: 120px;
  }

  .player-share-option {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }

  .player-close {
    order: 0;
    margin-left: auto;
  }

  .player-minimize {
    order: 0; /* Place next to close button */
    margin-right: 0.5rem; /* Add some spacing */
  }

}

/* Loading Animation */
.player-loading {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Page Loading State for AJAX Navigation */
body.page-loading {
  position: relative;
}

body.page-loading::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #ff6b35, #f7931e);
  z-index: 99999;
  animation: loading-bar 1s ease-in-out infinite;
}

@keyframes loading-bar {
  0% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(0%);
  }
  100% {
    transform: translateX(100%);
  }
}

body.page-loading .container,
body.page-loading .grid-container,
body.page-loading .song-container,
body.page-loading .upload-container {
  opacity: 0.6;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* Minimize Toggle */
.player-minimize {
  background: transparent;
  border: none;
  color: #00A8E8; /* More obvious color */
  font-size: 1.5rem; /* Larger arrow icon */
  cursor: pointer;
  padding: 0.2rem 0.5rem; /* Adjust padding */
  transition: color 0.3s ease, transform 0.3s ease;
  flex-shrink: 0;
  font-weight: bold;
}

.player-minimize:hover {
  color: #ff6b35; /* Orange on hover */
  transform: scale(1.1);
}
