/* ====== RESET E ESTILOS BASE ====== */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: white;
  background: #0f172a;
  display: flex;
  min-height: 100vh;
}

/* ====== LAYOUT PRINCIPAL ====== */
.container {
  flex: 1;
  max-width: calc(100% - 300px);
  margin-right: 280px;
  padding: 20px;
}

.main-logo {
  max-width: 220px;
  height: auto;
  display: block;
  margin-bottom: 10px;
}

/* ====== FORMULÁRIO DE BUSCA ====== */
form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

#buscador {
  flex: 1;
  max-width: 400px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b1220;
  color: #e2e8f0;
  font-size: medium;
}

#buscar {
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

button {
  padding: 5px 5px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  margin: 3px;
}

button:hover {
  filter: brightness(1.2);
}

#limparBusca {
  background: #334155; /* Um tom de cinza para diferenciar do buscar */
  color: #f87171;     /* Texto avermelhado para indicar limpeza */
}

#limparBusca:hover {
  background: #475569;
  filter: brightness(1.1);
}

/* ====== TOP 10 E CARROSSEL ====== */
#top10-section {
    position: relative;
    padding: 0 45px; /* Espaço para as setas nas laterais */
    margin-bottom: 20px;
}

.carousel-container {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 15px 5px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Oculta no Firefox */
    -ms-overflow-style: none; /* Oculta no IE/Edge */
}

.carousel-container::-webkit-scrollbar {
    height: 6px;
}

.carousel-container::-webkit-scrollbar-thumb {
    background: #3b82f6;
    border-radius: 10px;
}

.carousel-container .card {
    min-width: 140px;
    max-width: 140px;
    flex-shrink: 0;
}

.section-title {
    font-size: 1.2rem;
    color: #fff;
    margin-bottom: 10px;
    margin-left: 5px;
}

/* ====== SETAS DE NAVEGAÇÃO ====== */
.nav-btn {
    position: absolute;
    top: 60%; /* Alinhado ao centro dos cards */
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    font-size: 20px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 110;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

.nav-btn:hover {
    background: #3b82f6;
}

.prev { left: 0; }
.next { 
    right: 40px; /* Altere o 0 para 15px para mover para a esquerda */
}

/* ====== GRID DE RESULTADOS ====== */
.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  max-width: 1000px;
}

/* ====== ESTILO DOS CARDS ====== */
.card {
  position: relative;
  background: #0b1220;
  border: 1px solid #1f2a44;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  transition: all 0.2s ease-in-out;
}

.card img {
  width: 100%;
  border-radius: 8px;
  transition: transform 0.2s;
}

.card img:hover {
  transform: scale(1.05);
}

.card h4 {
  margin: 10px 0 5px;
  font-size: 14px;
}

.card p {
  margin: 0 0 10px;
  font-size: 12px;
  color: #94a3b8;
}

.rank-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(59, 130, 246, 0.9);
    color: white;
    padding: 2px 8px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 12px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* ====== BARRA LATERAL ====== */
#favorites-sidebar {
  position: fixed;
  right: 0;
  top: 0;
  height: 95vh;
  width: 275px;
  background: #0f172a;
  padding: 20px;
  border-left: 1px solid #1f2a44;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

/* No seu estilo geral para Desktop */
#favorites.favorites-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: min-content; /* Define altura mínima para as linhas */
  align-content: start; /* Alinha os cards no topo, deixando o espaço vazio embaixo */
  gap: 10px;
  flex-grow: 1;
  overflow-y: auto;
  margin-bottom: 15px;
}

.card.favorite {
    height: fit-content;
    align-self: start;
}

#clearFavorites {
  width: 100%;
  padding: 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #f87171;
  font-weight: bold;
  cursor: pointer;
}

#clearFavorites:hover {
  background: #ef4444;
  color: white;
}

/* ====== PLAYER ====== */
.player {
  position: fixed;
  bottom: 20px;
  right: 300px;
  width: 300px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
  padding: 15px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.hidden { display: none; }

/* ====== RESPONSIVIDADE ====== */
@media (max-width: 768px) {
  /* Esconde as setas pois o scroll é via touch no telemóvel */
  .nav-btn { 
    display: none; 
  }
  
  /* Ajusta o corpo para empilhar os elementos verticalmente */
  body {
    flex-direction: column;
  }

  /* Faz a área de busca e Top 10 ocupar a largura total */
  .container {
    max-width: 100%;
    margin-right: 0;
    padding: 10px;
  }

  /* Move o sidebar para baixo da busca */
  #favorites-sidebar {
    position: relative;
    width: 100%;
    height: auto;
    border-left: none;
    border-top: 1px solid #1f2a44;
    padding: 20px;
    box-sizing: border-box;
  }

  /* Ajusta a grid de favoritas para não esticar os cards */
  #favorites.favorites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    grid-template-rows: min-content;
    align-content: start;
    gap: 10px;
    max-height: none; /* Remove limite de altura no mobile se preferires */
  }

  /* Garante que o card de favorito termine logo após o botão */
  .card.favorite {
    height: fit-content;
  }

  /* Ajusta o player para não sumir no ecrã do telemóvel */
  .player {
    width: 90%;
    right: 5%;
    left: 5%;
    bottom: 10px;
  }
}