/* =========================
   Archive
========================= */

#archive {
  background: #1f1f1f;
  padding: 1.5rem;
  border-radius: 5px;
  margin-bottom: 2rem;
}

#archive h2 {
  margin-bottom: 1.25rem;
}

.archive-track-link {
  color: #f5f5f5;
  text-decoration: none;
}

.archive-track-link:hover {
  color: #0ff;
  text-decoration: underline;
}

/* =========================
   Archive Search
========================= */

.archive-search {
  display: flex;
  gap: 6px;
  margin-bottom: 1rem;
  align-items: center;
}

.archive-search-input {
  flex: 1;
  background: #2a2a2a;
  border: 1px solid #444;
  color: #f5f5f5;
  padding: 0.4rem 0.8rem;
  border-radius: 5px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.archive-search-input:focus {
  outline: none;
  border-color: #666;
}

.archive-search-btn {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #f5f5f5;
  padding: 0.4rem 0.8rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

.archive-search-btn:hover {
  background: #333;
  border-color: #666;
}

.archive-search-clear {
  background: transparent;
  border: none;
  color: #888;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.4rem 0.4rem;
  transition: color 0.2s;
}

.archive-search-clear:hover {
  color: #e63946;
}


/* =========================
   Archive Table
========================= */

.archive-table {
  width: 100%;
  min-width: 580px;
  border-collapse: collapse;
  font-size: 0.95rem;
  table-layout: fixed;
}

.archive-table col.col-cover    { width: 40px; }
.archive-table col.col-artist   { width: 90px; }
.archive-table col.col-title    { width: auto; }
.archive-table col.col-duration { width: 70px; }
.archive-table col.col-created  { width: 90px; }
.archive-table col.col-language { width: 60px; }
.archive-table col.col-sample   { width: 140px; }

.archive-table-wrapper {
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  overflow-x: auto;
}

.archive-table-wrapper::-webkit-scrollbar {
  width: 4px;
}

.archive-table-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.archive-table-wrapper::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}

.archive-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #666;
}

.archive-table-wrapper .archive-table thead th {
  position: sticky;
  top: 0;
  background: #1f1f1f;
  z-index: 1;
}

.archive-table thead tr {
  border-bottom: 2px solid #e63946;
}

.archive-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: #aaa;
  font-weight: 600;
  white-space: nowrap;
}

.archive-table th[data-sort] {
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

.archive-table th[data-sort]:hover {
  color: #f5f5f5;
}

.archive-table th.sort-asc::after  { content: ' ↑'; color: #0ff; }
.archive-table th.sort-desc::after { content: ' ↓'; color: #0ff; }

.archive-table tbody tr {
  border-bottom: 1px solid #2a2a2a;
  transition: background 0.15s;
}

.archive-table tbody tr:hover {
  background: #222;
}

.archive-table td {
  padding: 0.5rem 0.75rem;
  color: #f5f5f5;
  vertical-align: middle;
  overflow: visible;
}

.archive-table td.col-title,
.archive-table td.col-artist {
  white-space: normal;
}

.archive-table td.col-duration,
.archive-table td.col-created,
.archive-table td.col-language,
.archive-table td.col-sample {
  white-space: nowrap;
}

/* =========================
   Sample buttons
========================= */

.track-timeline {
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 120px;
  height: 16px;
  gap: 0;
}

.track-timeline-intro,
.track-timeline-highlight {
  width: 20px;
  height: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  cursor: pointer;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
  border: 1px solid #444;
  border-radius: 3px;
  background: #2a2a2a;
  color: #888;
}

.track-timeline-gap {
  height: 6px;
  background: #333;
  border-radius: 0;
  flex: 1;
  pointer-events: none;
}

.track-detail .track-timeline {
  width: 100%;
  height: 32px;
}

.track-detail .track-timeline-intro,
.track-detail .track-timeline-highlight {
  width: 48px;
  height: 30px;
  font-size: 1rem;
  border-radius: 5px;
}

.track-detail .track-timeline-gap {
  height: 12px;
}

.track-timeline-intro:hover,
.track-timeline-intro.playing     { background: #0d1f1f; border-color: #0ff; color: #0ff; }

.track-timeline-intro::after {
  content: attr(data-tooltip);
  position: fixed;
  bottom: auto;
  left: auto;
  transform: translateY(-130%);
  background: #1a1a1a;
  border: 1px solid #444;
  color: #f5f5f5;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 1000;
}

.track-timeline-intro:hover::after {
  opacity: 1;
}

/* =========================
   Pagination
========================= */

.archive-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
  color: #aaa;
  font-size: 0.95rem;
}

.pagination-ellipsis {
  color: #666;
  padding: 0 0.25rem;
}

.pagination-current {
  color: #0ff;
  border: 1px solid #0ff;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font-size: 0.95rem;
  min-width: 32px;
  text-align: center;
}

.btn-page {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #f5f5f5;
  padding: 0.3rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.95rem;
  transition: background 0.2s, border-color 0.2s;
}

.btn-page:hover {
  background: #333;
  border-color: #666;
}

/* =========================
   Sample Player
========================= */

#samplePlayer {
  position: fixed;
  top: 12px;
  right: 52px;
  z-index: 999;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

#samplePlayerIcon {
  color: #0ff;
  font-size: 1rem;
  animation: samplePulse 1s ease-in-out infinite;
}

@keyframes samplePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#sampleVolume {
  width: 80px;
  accent-color: #0ff;
  cursor: pointer;
}

#sampleStop {
  background: transparent;
  border: none;
  color: #e63946;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.2s;
}

#sampleStop:hover {
  color: #ff4f6d;
}

/* =========================
   Track Detail
========================= */

#track {
  background: #1f1f1f;
  padding: 1.5rem;
  border-radius: 5px;
  margin-bottom: 2rem;
}

.track-detail-top {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.track-detail-cover {
  width: 360px;
  height: 360px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
}

.track-detail-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.track-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.track-detail-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #f5f5f5;
}

.track-field-label {
  font-size: 1rem;
  color: #888;
  margin-top: 0.4rem;
}

.track-field-note {
  font-size: 0.75rem;
  color: #666;
}

.track-field {
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  color: #f5f5f5;
  font-size: 0.95rem;
}

.track-field-instrumental {
  color: #aaa;
  font-style: italic;
}

.track-field-textarea {
  width: 100%;
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
  color: #ccc;
  font-size: 0.9rem;
  font-family: 'Rajdhani', sans-serif;
  resize: none;
  outline: none;
  cursor: default;
  line-height: 1.6;
  overflow-y: auto;
}

.track-field-textarea.lyrics {
  height: calc(1.6em * 5 + 1rem);
}

.track-field-textarea.styles {
  height: calc(1.6em * 3 + 1rem);
}

.track-field-textarea::-webkit-scrollbar,
.track-field-textarea::-webkit-scrollbar {
  width: 4px;
}

.track-field-textarea::-webkit-scrollbar-track {
  background: transparent;
}

.track-field-textarea::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}

.track-field-textarea::-webkit-scrollbar-thumb:hover {
  background: #666;
}

.track-detail-section {
  margin-bottom: 1rem;
}

.track-detail-section:last-child {
  text-align: right;
}

.track-detail-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}

.track-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 5px;
  padding: 0.5rem 1rem;
}

.track-stat-label {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 0.2rem;
}

.track-stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f5f5f5;
}

/* =========================
   Track Back Link
========================= */

.track-back-link {
  color: #0ff;
  text-decoration: none;
  font-size: 0.95rem;
  cursor: pointer;
  transition: color 0.2s;
}

.track-back-link::before {
  content: '← ';
}

.track-back-link:hover {
  color: #fff;
  text-decoration: underline;
}

/* =========================
   Responsive
========================= */

@media (max-width: 768px) {
  .archive-table th,
  .archive-table td {
    padding: 0.4rem 0.4rem;
    font-size: 0.85rem;
  }

  .btn-sample {
    padding: 0.15rem 0.4rem;
    font-size: 0.8rem;
  }

  .track-detail-top {
    flex-direction: column;
  }

  .track-detail-cover {
    width: 100%;
    height: auto;
    max-width: 360px;
  }

  .track-detail-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}
