/* Reset e base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #000;
  color: #fff;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  overflow-x: hidden;
}

/* Header */
.header {
  text-align: center;
  padding: clamp(1rem, 4vw, 2rem);
  padding-top: max(env(safe-area-inset-top), 1rem);
}

.header-logo {
  display: block;
  margin: 0 auto 0.75rem;
  max-width: 120px;
  height: auto;
  object-fit: contain;
}

@media (min-width: 600px) {
  .header-logo {
    max-width: 160px;
  }
}

.header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #c084fc, #e879f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin: 0.25rem 0 0;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  color: #ccc;
}

/* Pacote e créditos */
.credits-bar {
  text-align: center;
  padding: 0.75rem 1rem;
  margin: 0 auto 1rem;
  max-width: 900px;
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 12px;
  font-size: 1rem;
  color: #e0d4f7;
}

.credits-bar.hidden {
  display: none;
}

.server-warning {
  background: rgba(220, 160, 0, 0.2);
  border: 1px solid rgba(220, 160, 0, 0.5);
  color: #f0e0a0;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  text-align: center;
  max-width: 900px;
  margin: 0 auto 1rem;
  border-radius: 12px;
}

.server-warning.hidden {
  display: none;
}

.server-warning code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.server-warning-link {
  color: #c084fc;
  font-weight: 600;
  text-decoration: underline;
}

.server-warning-link:hover {
  color: #e879f9;
}

.player-hint a {
  color: #a855f7;
  text-decoration: none;
}

.player-hint a:hover {
  text-decoration: underline;
}

.player-hint {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: #888;
}

.pacote-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 80px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.3) 0%, rgba(168, 85, 247, 0.2) 100%);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  max-width: 900px;
  margin: 0 auto 1.25rem;
}

.pacote-card:hover,
.pacote-card:focus-visible {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.4) 0%, rgba(168, 85, 247, 0.3) 100%);
  transform: scale(1.01);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.25);
}

.pacote-card .pacote-icon {
  font-size: 2rem;
}

.pacote-card .pacote-text {
  text-align: left;
}

.pacote-card .pacote-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.pacote-card .pacote-desc {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: #bbb;
}

/* Busca e categorias */
.search-and-filters {
  max-width: 900px;
  margin: 0 auto 1.25rem;
}

.search-wrap {
  margin-bottom: 1rem;
}

.search-input {
  width: 100%;
  max-width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  font-size: 1rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.search-input::placeholder {
  color: #888;
}

.search-input:focus {
  border-color: rgba(168, 85, 247, 0.5);
  background: rgba(255, 255, 255, 0.1);
}

.search-wrap {
  position: relative;
}

.search-wrap::before {
  content: '';
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23888'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") center/contain no-repeat;
  pointer-events: none;
}

.search-input {
  padding-left: 2.75rem;
}

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #ccc;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.category-btn:hover,
.category-btn:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.category-btn.active {
  color: #fff;
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  border-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.tracks-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: #888;
  font-size: 1rem;
}

/* Main e grid de faixas */
.main {
  padding: 0 clamp(1rem, 4vw, 2rem) clamp(2rem, 8vw, 3rem);
  padding-bottom: max(env(safe-area-inset-bottom), 1.5rem);
}

.tracks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: clamp(0.75rem, 2.5vw, 1.25rem);
  max-width: 900px;
  margin: 0 auto;
}

.track-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 1.25rem 1rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.track-card:hover,
.track-card:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.track-card:active {
  transform: scale(0.98);
}

.track-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 0.5rem;
  border-radius: 12px;
  background: linear-gradient(145deg, #7c3aed, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.track-card[data-type="video"] .track-icon {
  background: linear-gradient(145deg, #059669, #10b981);
}

.track-title {
  margin: 0;
  font-size: clamp(0.85rem, 2.2vw, 1rem);
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.track-price {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: #bbb;
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  color: #fff;
  width: 100%;
  margin-top: 1rem;
  min-height: 48px;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  opacity: 0.95;
}

.btn-copy {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border-radius: 8px;
  margin-top: 0.5rem;
}

/* Modal Pix */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.modal-box h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  color: #fff;
}

.track-name {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: #ccc;
}

.pix-area {
  margin-bottom: 0.5rem;
}

.qrcode-placeholder {
  width: 180px;
  height: 180px;
  margin: 0 auto 1rem;
  background: rgba(255, 255, 255, 0.08);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #aaa;
}

.qrcode-placeholder small {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
}

.pix-key {
  margin-bottom: 0.75rem;
}

.pix-key label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  color: #ccc;
}

.pix-key-value {
  padding: 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-size: 0.95rem;
  word-break: break-all;
  color: #fff;
}

.pix-value {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  color: #fff;
}

/* Player overlay */
.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.player-overlay[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.player-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.player-box {
  position: relative;
  width: 100%;
  max-width: 600px;
  background: #0a0a0a;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.player-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

.player-title {
  margin: 0 0 0.75rem;
  padding-right: 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.waveform-canvas {
  display: none;
  width: 100%;
  height: 80px;
  margin-bottom: 0.75rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
}

.waveform-canvas.visible {
  display: block;
}

#audio-player,
#video-player {
  width: 100%;
  border-radius: 12px;
  background: #000;
}

#audio-player {
  height: 54px;
}

#video-player {
  display: none;
  max-height: 70vh;
}

#video-player.visible {
  display: block;
}

#audio-player.visible {
  display: block;
}

#audio-player:not(.visible) {
  display: none;
}

/* Tablet: cards maiores e mais espaço */
@media (min-width: 600px) {
  .tracks {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }

  .track-card {
    min-height: 140px;
    padding: 1.5rem;
  }

  .track-icon {
    width: 56px;
    height: 56px;
    font-size: 1.75rem;
  }
}

@media (min-width: 900px) {
  .tracks {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Evitar zoom em inputs no iOS */
@media (max-width: 480px) {
  input, select, textarea, button {
    font-size: 16px !important;
  }
}
