/* --- GLOBAL --- */
body {
  font-family: system-ui, sans-serif;
  background: #111;
  color: #eee;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  touch-action: manipulation;
}

/* --- HEADER --- */
header {
  background: #222;
  padding: 1em;
  text-align: center;
}

nav button {
  margin: 0.3em;
  background: #333;
  color: #fff;
  border: none;
  padding: 0.5em 1em;
  cursor: pointer;
  border-radius: 4px;
}

nav button:hover {
  background: #555;
}

.shadow-text {
  text-shadow: 0px 3px 0px red;
}

.shadow-box {
  text-shadow: 0px 3px 0px red;
}

/* --- MAIN LAYOUT --- */
main {
  flex: 1;
  padding: 1em;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-title {
  margin-top: 4px;
  text-transform: uppercase;
}

.hidden {
  display: none;
}

/* --- LISTS --- */
ul {
  list-style: none;
  padding: 0;
}

li {
  margin: 0.4em 0;
  padding: 0.4em;
  background: #222;
  border-radius: 4px;
  cursor: pointer;
}

li button {
  margin-left: 0.5em;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

li button:hover {
  background: #555;
}

/* --- TRACK ITEMS --- */
.track-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: #222;
  padding: 0.6em 0.8em;
  border-radius: 4px;
  margin: 0.4em 0;
  cursor: pointer;
  gap: 0.5em;
}

.track-item span {
  flex: 1;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  line-height: 1.4;
}

.track-item button {
  background: #333;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 0.4em 0.7em;
  flex-shrink: 0;
  align-self: flex-start;
}

.track-item button:hover {
  background: #555;
}

.track-item.playing {
  background: #333;
  border: 1px solid #555;
  box-shadow: 0 0 4px #666;
}

.track-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.track-title {
  font-weight: 600;
  white-space: normal;
  word-break: break-word;
}

.track-artist {
  font-size: 0.9em;
  color: #aaa;
  margin-top: 2px;
  white-space: normal;
  word-break: break-word;
}

/* --- PLAYLIST ITEMS --- */
.playlist-item {
  position: relative;      
  background: #222;
  padding: 0.6em 0.8em;
  margin: 0.4em 0;
  border-radius: 4px;
  cursor: pointer;
}

.playlist-item span {
  display: block;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
  padding-right: 50px; 
}

.playlist-item button.edit-playlist-btn {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.3em 0.6em;
  cursor: pointer;
}

.playlist-item button.edit-playlist-btn:hover {
  background: #555;
}

/* --- NEW PLAYLIST & BACK BUTTON --- */
#create-playlist-btn, #back-to-playlists {
  display: block;
  margin: 0.5em 0;
  padding: 0.5em 1em;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
}

#create-playlist-btn:hover, #back-to-playlists:hover {
  background: #555;
}

/* --- SHARED MODAL & UPLOAD STYLE --- */
.modal-content,
#view-upload {
  background: #222;
  padding: 1em;
  border-radius: 6px;
  color: #fff;
  width: 90%;
  max-width: 400px;
  box-sizing: border-box;
  margin: 0 auto;
}

.modal-content input,
.modal-content label,
.modal-content button,
#view-upload input,
#view-upload label,
#view-upload button {
  display: block;
  width: 100%;
  box-sizing: border-box; 
  font-family: inherit;
  line-height: 1.2;
  border-radius: 4px;
}

.modal-content label,
#view-upload label {
  margin-top: 0.5em;
  margin-bottom: 0.2em;
}

.modal-content input,
#view-upload input {
  margin-bottom: .4em;
  padding: .5em;
  background: #111;
  color: #eee;
  border: 1px solid #333;
}

.modal-content button,
#view-upload button {
  margin-top: 0.5em;
  margin-bottom: 0.3em;
  padding: 0.5em;
  background: #333;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.modal-content button:hover,
#view-upload button:hover {
  background: #555;
}

.modal-content button + button,
#view-upload button + button {
  margin-top: 0.4em;
}

/* --- PLAYLIST MODAL FIXED SIZE + SCROLLABLE TRACKS --- */
#playlist-modal .modal-content {
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#playlist-name-input {
  margin-bottom: 0.6em;
}

/* Scrollable track list area */
#track-checkboxes {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 10px;
  background: #111;
  max-height: 50vh;
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
}

/* Each track option (checkbox + title inline) */
#track-checkboxes .track-option {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Checkbox alignment fix */
#track-checkboxes .track-option input[type="checkbox"] {
  display: inline-block !important;
  width: auto !important;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

/* Song label beside checkbox */
#track-checkboxes .track-option label {
  display: inline-block !important;
  margin: 0;
  color: #eee;
  white-space: normal;
  word-break: break-word;
  flex: 1;
}

/* Scrollbar styling */
#track-checkboxes::-webkit-scrollbar {
  width: 6px;
}
#track-checkboxes::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}
#track-checkboxes::-webkit-scrollbar-thumb:hover {
  background: #666;
}

/* --- FILE INPUTS --- */
input[type="file"] {
  display: none;
}

#view-upload label[for="file-input"],
#view-upload label[for="cover-input"],
.modal-content label[for="edit-cover"] {
  display: inline-block;
  background: #333;
  color: #fff;
  padding: 0.5em 1em;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 0.3em;
  transition: background 0.2s;
  text-align: center;
}

#view-upload label[for="file-input"]:hover,
#view-upload label[for="cover-input"]:hover,
.modal-content label[for="edit-cover"]:hover {
  background: #555;
}

.file-name {
  display: inline-block;
  margin-left: 0.5em;
  font-size: 0.9em;
  color: #ccc;
  max-width: calc(100% - 120px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* --- NOW PLAYING VIEW --- */
#view-player.view {
  display: none; 
}

#view-player.view.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1em 1em;
}

#cover-art {
  width: 250px;
  height: 250px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 1em;
  box-shadow: 0 0 12px rgba(0,0,0,0.5);
}

#song-title {
  font-size: 1.5em;
  font-weight: bold;
  margin: 0.3em 0 0.2em;
}

#song-artist {
  font-size: 1em;
  color: #aaa;
  margin: 0 0 1em;
}

#audio {
  width: 90%;
  max-width: 400px;
  display: block;
  margin: 0 auto;
  filter: brightness(0.9);
}

/* --- MINI PLAYER --- */
footer {
  background: #222;
  padding: 0.75em 0.5em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.4em;
  position: fixed;
  bottom: 0;
  width: 100%;
  z-index: 1000;
  box-sizing: border-box;
}

#mini-song-title {
  font-size: 0.9em;
  color: #ccc;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 90%;
}

.mini-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6em;
}

.mini-controls img {
  width: 18px;
  height: 18px;
}

.mini-controls button {
  background: #333;
  color: #fff;
  border: none;
  padding: 0.4em 0.6em;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.mini-controls button:hover {
  background: #555;
}

/* --- MODALS --- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal.hidden {
  display: none;
}

.modal-title {
  margin-top: 4px;
  margin-bottom: 14px;
  text-transform: uppercase;
  text-align: center;
}

.modal-subtitle {
  font-weight: bold;
  margin-bottom: 5px;
}

/* --- INFO / SETTINGS MODAL --- */
#info-modal .modal-content {
  max-width: 400px;
  margin: auto;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 20px;
  color: #eee;
  text-align: left;
}

#info-content {
  margin-bottom: 1em;
  line-height: 1.4;
}

#close-info-btn {
  display: block;
  margin: 0 auto;
  background: #333;
  color: #fff;
  border: none;
  padding: 0.5em 1em;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
}
#close-info-btn:hover {
  background: #555;
}

/* --- INFO BUTTON --- */
#info-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #333;
  color: #fff;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 0.2em 0.6em;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

#info-btn:hover {
  background: #555;
  border-color: #777;
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 600px) {
  #cover-art {
    width: 70vw;
    height: 70vw;
  }

  #song-title {
    font-size: 1.2em;
  }

  #song-artist {
    font-size: 0.9em;
  }

  #audio {
    width: 95%;
  }

  nav button {
    padding: 0.4em 0.8em;
    font-size: 0.9em;
  }

  footer {
    padding: 0.5em;
    gap: 0.3em;
  }

  .mini-controls button {
    padding: 0.35em 0.5em;
  }

  #track-checkboxes > div {
    flex-wrap: wrap;
  }
}

#debug {
  display: none !important;
}