/* ===== Variáveis ===== */
:root {
  --bg: #0f0f0f;
  --bg-surface: #1a1a1a;
  --bg-card: #222222;
  --accent: #ffffff;
  --text-primary: #ffffff;
  --text-secondary: #888888;
  --progress: #ffffff;
  --radius: 12px;
  --player-height: 196px;
}

/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== Base ===== */
html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  padding-bottom: calc(var(--player-height) + 16px);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Cabeçalho ===== */
.cabecalho {
  padding: 20px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cabecalho__titulo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ===== Loading ===== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 64px 16px;
  color: var(--text-secondary);
}

.loading__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}

@keyframes girar {
  to { transform: rotate(360deg); }
}

.loading__texto {
  font-size: 0.9rem;
}

/* ===== Biblioteca ===== */
.biblioteca {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  padding: 16px;
}

.biblioteca--vazia {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 16px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: center;
}

/* ===== Card ===== */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.card:hover {
  transform: translateY(-2px);
  background-color: #2a2a2a;
}

.card:active {
  transform: translateY(0);
}

.card--ativo {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.card__capa-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background-color: #2d2d2d;
}

.card__capa {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card__capa-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.card__overlay-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.card:hover .card__overlay-play,
.card--ativo .card__overlay-play {
  opacity: 1;
}

.card__info {
  padding: 10px 10px 0;
}

.card__titulo {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.card__autor {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__progresso-barra {
  margin-top: 10px;
  height: 3px;
  background-color: rgba(255,255,255,0.1);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.card__progresso-fill {
  height: 100%;
  background-color: var(--progress);
  border-radius: 2px;
  transition: width 0.3s ease;
  min-width: 0;
}

/* ===== Player ===== */
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  background-color: var(--bg-surface);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 16px 16px;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== Progresso ===== */
.player__progresso-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player__barra-progresso {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.player__barra-progresso::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--progress);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.player__barra-progresso::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.player__barra-progresso::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--progress);
  cursor: pointer;
  border: none;
}

.player__tempos {
  display: flex;
  justify-content: space-between;
}

.player__tempo {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ===== Info linha ===== */
.player__info-linha {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player__capa {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background-color: var(--bg-card);
}

.player__meta {
  flex: 1;
  min-width: 0;
}

.player__titulo {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player__autor {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ===== Controles ===== */
.player__controles {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: relative;
}

.player__btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.player__btn:hover {
  background-color: rgba(255,255,255,0.08);
}

.player__btn:active {
  transform: scale(0.92);
}

.player__btn--play {
  background-color: var(--accent);
  color: #000;
  width: 52px;
  height: 52px;
  border-radius: 50%;
}

.player__btn--play:hover {
  background-color: rgba(255,255,255,0.9);
}

.player__btn--velocidade-wrapper {
  min-width: 44px;
}

.player__velocidade-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  pointer-events: none;
  white-space: nowrap;
}

/* ===== Painel de velocidades ===== */
.player__velocidades {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 8px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 110;
}

.player__vel-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 5px 10px;
  cursor: pointer;
  transition: background-color 0.1s ease, color 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.player__vel-btn:hover {
  background-color: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.player__vel-btn--ativo {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
}

/* ===== Utilidades ===== */
[hidden] {
  display: none !important;
}

/* ===== Responsividade ===== */
@media (min-width: 480px) {
  .biblioteca {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (min-width: 768px) {
  .biblioteca {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    padding: 24px;
    gap: 20px;
  }

  .player {
    padding: 14px 24px 18px;
  }

  .player__info-linha {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
  }

  .player__controles {
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
  }

  .player__progresso-wrap {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
  }
}
