/* ══════════════════════════════════════════════════════
   OLIVER TREE ARCHIVE — library.css
   Favorites + Playlists UI (library.js)
   ══════════════════════════════════════════════════════ */

/* ── Nav button ───────────────────────────────────────── */
.ot-lib-nav-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  /* Pushes itself (and the Library button right after it) all the way
     to the right end of the nav row — including its own line if the
     nav wraps on narrow screens, since it's the last thing in the bar. */
  margin-left: auto;
}

.ot-lib-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--grey, #9a9a9a);
  font-family: "Space Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.ot-lib-nav-btn svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.ot-lib-nav-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

/* ── Star + add-to-playlist buttons on track rows ────────
   Pinned to the far right edge of the row itself (.t / .track-item
   are position:relative — see style.css's per-track play button
   block), the same way .ot-play-btn is pinned to the left edge.
   Track rows only define 3 grid columns (num / info / badge), so
   these buttons must be taken out of grid flow entirely — otherwise
   they land in an implicit 4th/5th grid cell, which pushes them onto
   their own row underneath everything else instead of sitting at the
   end of the track. renderStars() adds .ot-has-favbtns to the row so
   we can reserve room on the right without affecting rows that don't
   have these buttons. ── */
.t.ot-has-favbtns,
.track-item.ot-has-favbtns {
  padding-right: 68px;
}

.ot-fav-btn,
.ot-addlist-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
  padding: 0;
  z-index: 2;
}

.ot-fav-btn {
  right: 36px;
}

.ot-addlist-btn {
  right: 6px;
}

.ot-fav-btn:hover,
.ot-addlist-btn:hover {
  transform: translateY(-50%) scale(1.08);
}

.ot-fav-btn:active,
.ot-addlist-btn:active {
  transform: translateY(-50%) scale(0.92);
}

.ot-fav-btn:hover,
.ot-addlist-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.ot-fav-btn svg {
  width: 12px;
  height: 12px;
}

.ot-fav-btn.active {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}

.ot-addlist-btn {
  font-size: 15px;
  line-height: 1;
  font-weight: 600;
}

/* ── "Save offline" button ───────────────────────────────
   Base look (circular, matches fav/add) works as-is inside the library
   modal's flex rows (.ot-lib-row). On the main tracklist it's pinned
   absolute like the other two, one slot further left — see
   .ot-has-offlinebtn below. ── */
.ot-offline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}

.ot-offline-btn:hover:not(:disabled) {
  transform: scale(1.08);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.ot-offline-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.ot-offline-btn.active {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
}

.ot-offline-btn.pending {
  color: rgba(255, 255, 255, 0.55);
  cursor: wait;
  animation: ot-offline-pulse 1.1s ease-in-out infinite;
}

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

.t .ot-offline-btn,
.track-item .ot-offline-btn {
  position: absolute;
  top: 50%;
  right: 66px;
  transform: translateY(-50%);
  z-index: 2;
}

.t .ot-offline-btn:hover:not(:disabled),
.track-item .ot-offline-btn:hover:not(:disabled) {
  transform: translateY(-50%) scale(1.08);
}

.t .ot-offline-btn:active:not(:disabled),
.track-item .ot-offline-btn:active:not(:disabled) {
  transform: translateY(-50%) scale(0.92);
}

.t.ot-has-offlinebtn,
.track-item.ot-has-offlinebtn {
  padding-right: 98px;
}

/* ── Favorite star on the player bar ─────────────────── */
.ot-p-fav svg {
  width: 15px;
  height: 15px;
}

.ot-p-fav.active {
  color: #fbbf24;
  opacity: 1;
}

/* ── Add-to-playlist popover ──────────────────────────── */
.ot-lib-popover {
  position: fixed;
  z-index: 2000;
  width: 210px;
  max-height: 240px;
  overflow-y: auto;
  background: #17171a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.ot-lib-popover-empty {
  font-family: "Inter", sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  padding: 6px 4px 10px;
}

.ot-lib-popover-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 4px;
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 12.5px;
  color: #fff;
}

.ot-lib-popover-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ot-lib-popover-row input {
  accent-color: #1db954;
}

.ot-lib-popover-new {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ot-lib-popover-addbtn {
  background: #1db954;
  border: none;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 0 10px;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.ot-lib-popover-addbtn:hover {
  background: #1ed760;
}

/* ── Modal overlay ────────────────────────────────────── */
.ot-lib-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 24px;
}

.ot-lib-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.ot-lib-modal {
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: #131316;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
}

.ot-lib-overlay.open .ot-lib-modal {
  transform: translateY(0) scale(1);
}

.ot-lib-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ot-lib-tabs {
  display: flex;
  gap: 6px;
}

.ot-lib-tab {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.55);
  font-family: "Inter", sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.ot-lib-tab:hover {
  color: #fff;
}

.ot-lib-tab.active {
  background: rgba(29, 185, 84, 0.16);
  border-color: rgba(29, 185, 84, 0.4);
  color: #1db954;
}

.ot-lib-profile {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "Inter", sans-serif;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.45);
  margin-left: auto;
}

.ot-lib-profile select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-family: "Inter", sans-serif;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 4px;
  max-width: 110px;
}

.ot-lib-icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: rgba(255, 255, 255, 0.6);
  width: 24px;
  height: 24px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ot-lib-icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.ot-lib-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
  flex-shrink: 0;
}

.ot-lib-close:hover {
  color: #fff;
}

.ot-lib-note {
  margin: 0;
  padding: 10px 18px;
  font-family: "Inter", sans-serif;
  font-size: 11px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.38);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ot-lib-body {
  padding: 14px 18px 20px;
  overflow-y: auto;
}

.ot-lib-empty,
.ot-lib-empty-small {
  font-family: "Inter", sans-serif;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  padding: 24px 10px;
  font-size: 13px;
  line-height: 1.5;
}

.ot-lib-empty-small {
  padding: 12px 4px;
  text-align: left;
}

/* ── Track rows (shared by Favorites list + playlist detail) ── */
.ot-lib-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ot-lib-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 6px;
}

.ot-lib-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* Currently-playing row — playback now stays inside this modal instead
   of booting you back out to the main tracklist, so this is the only
   visual cue you get that something's actually still playing. */
.ot-lib-row.playing {
  background: rgba(29, 185, 84, 0.1);
}

.ot-lib-row.playing .ot-lib-row-title {
  color: #1db954;
}

.ot-lib-row.playing .ot-lib-row-play {
  background: #1db954;
  color: #fff;
}

.ot-lib-row-play {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(29, 185, 84, 0.15);
  color: #1db954;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ot-lib-row-play:hover {
  background: #1db954;
  color: #fff;
}

.ot-lib-row-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ot-lib-row-title {
  font-family: "Inter", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ot-lib-row-era {
  font-family: "Space Mono", monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
}

.ot-lib-row-remove {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  flex-shrink: 0;
}

.ot-lib-row-remove:hover {
  color: #f87171;
}

/* ── Offline tab ──────────────────────────────────────── */
.ot-lib-offline-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: "Space Mono", monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 4px;
}

.ot-lib-offline-note {
  font-family: "Space Mono", monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin: 0 0 14px;
}

/* ── Playlists tab ────────────────────────────────────── */
.ot-lib-create-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.ot-lib-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-family: "Inter", sans-serif;
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 6px;
}

.ot-lib-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.ot-lib-input-sm {
  padding: 6px 8px;
  font-size: 12px;
}

.ot-lib-create-btn {
  background: #1db954;
  border: none;
  color: #fff;
  font-family: "Inter", sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.ot-lib-create-btn:hover {
  background: #1ed760;
}

.ot-lib-playlist {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.ot-lib-playlist-head {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: none;
  padding: 12px 76px 12px 14px;
  text-align: left;
  cursor: pointer;
}

.ot-lib-playlist.open .ot-lib-playlist-head {
  background: rgba(255, 255, 255, 0.06);
}

.ot-lib-playlist-name {
  font-family: "Inter", sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
}

.ot-lib-playlist-count {
  font-family: "Space Mono", monospace;
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.4);
}

.ot-lib-playlist-tools {
  position: absolute;
  top: 8px;
  right: 10px;
  display: flex;
  gap: 4px;
}

.ot-lib-playlist-tracks {
  padding: 8px 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Small screens ────────────────────────────────────── */
@media (max-width: 560px) {
  .t.ot-has-favbtns,
  .track-item.ot-has-favbtns {
    padding-right: 60px;
  }
  .ot-fav-btn,
  .ot-addlist-btn {
    width: 21px;
    height: 21px;
  }
  .ot-fav-btn {
    right: 31px;
  }
  .ot-addlist-btn {
    right: 5px;
  }
  .ot-offline-btn {
    width: 21px;
    height: 21px;
  }
  .t .ot-offline-btn,
  .track-item .ot-offline-btn {
    right: 57px;
  }
  .t.ot-has-offlinebtn,
  .track-item.ot-has-offlinebtn {
    padding-right: 86px;
  }
  .ot-lib-modal {
    max-height: 88vh;
  }
  .ot-lib-profile {
    margin-left: 0;
    width: 100%;
    order: 3;
  }
  .ot-lib-playlist-head {
    padding-right: 14px;
  }
  .ot-lib-playlist-tools {
    position: static;
    padding: 0 10px 10px;
  }
}
