/* -------------------- Variáveis para temas -------------------- */
:root {
  --cor-calculadora: rgba(255, 255, 255, 0.8);
  --cor-botoes: black;
  --cor-texto-botoes: white;
  --cor-resultado: white;
  --cor-texto-resultado: black;
  --gradiente-tema: linear-gradient(to right, #7b2cbf, #c8a2c8);
  --cor-titulo: black;
}

/* -------------------- Reset básico -------------------- */
* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

body {
  height: 100vh; 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  background: linear-gradient(#7b2cbf, #c8a2c8);
  font-family: Arial, sans-serif;
}

.container {
  display: flex; 
  flex-direction: column; 
  align-items: flex-end; 
  gap: 10px;
}

/* -------------------- Calculadora -------------------- */
.calculadora {
  background: var(--cor-calculadora); 
  color: var(--cor-texto-botoes); 
  padding: 20px; 
  border-radius: 15px; 
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  width: fit-content;
}

.calculadora h1 {
  color: var(--cor-titulo);
  text-align: center;
  margin-bottom: 10px;
}

.titulo-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* -------------------- Tela de resultado -------------------- */
#resultado {
  background-color: var(--cor-resultado); 
  width: 250px; 
  height: 50px; 
  margin: 5px 0; 
  font-size: 25px; 
  color: var(--cor-texto-resultado); 
  text-align: right; 
  padding: 5px; 
  border-radius: 8px;
  overflow-x: auto;
  transition: background 0.3s, color 0.3s;
}

/* -------------------- Botões principais -------------------- */
button {
  width: 60px; 
  height: 60px; 
  font-size: 20px; 
  border-radius: 10px; 
  margin: 2px; 
  cursor: pointer; 
  background-color: var(--cor-botoes); 
  border: none; 
  color: var(--cor-texto-botoes);
  transition: transform 0.1s, background-color 0.2s;
}

button:hover {
  background-color: darkgray; 
}

button:active {
  transform: scale(0.95);
  background-color: #555;
}

#igual {
  height: 130px; 
  font-size: 24px; 
}

#zero {
  width: 130px; 
  font-size: 22px; 
}

#apagar {
  font-size: 24px; 
  color: var(--cor-texto-botoes); 
  font-weight: bold; 
}

/* -------------------- Botões de tema -------------------- */
.temas {
  display: flex; 
  gap: 8px; 
}

.temas button {
  width: 25px; 
  height: 25px; 
  border-radius: 50%; 
  border: noe; 
  cursor: pointer; 
}

.temas button:nth-child(1) { background-color: black; }
.temas button:nth-child(2) { background-color: white; border: 1px solid gray; }
.temas button:nth-child(3) { background: linear-gradient(to right, #ff4d6d, #ffb3c6); }

/* -------------------- Botões científicos -------------------- */
#cientificos {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
}

#cientificos button {
  width: 60px;
  height: 50px;
  font-size: 16px;
  border-radius: 10px;
  transition: transform 0.1s;
}

#cientificos button:active {
  transform: scale(0.95);
}

/* -------------------- Botão de moeda -------------------- */
#moeda-btn {
  font-size: 28px;
  width: 60px;
  height: 60px;
  border-radius: 10px;
  cursor: pointer;
}

/* -------------------- Painel de conversão -------------------- */
#moeda-panel {
  display: none;
  background-color: #f0f0f0;
  padding: 10px;
  border-radius: 10px;
  width: fit-content;
  margin-top: 10px;
}

#moeda-panel select,
#moeda-panel input,
#moeda-panel button {
  padding: 5px;
  margin: 3px;
  font-size: 16px;
}

/* -------------------- Histórico -------------------- */
#historico {
  background: #eee;
  padding: 5px;
  border-radius: 5px;
  max-height: 100px;
  overflow-y: auto;
  font-size: 14px;
  margin-top: 10px;
  color: black !important; /* Garante texto preto sempre */
}

#historico p {
  margin: 2px 0;
  cursor: pointer;
  transition: background 0.2s;
  color: black !important; /* Texto preto sempre */
}

#historico p:hover {
  background: #ccc;
  border-radius: 3px;
  padding: 2px;
}

/* Garante que o histórico seja legível no tema preto */
body[style*="--cor-calculadora: #000000"] #historico,
body[style*="--cor-calculadora: #000000"] #historico p {
  color: black !important;
  background: #f0f0f0 !important;
}

/* Histórico no tema branco */
body[style*="--cor-calculadora: #ffffff"] #historico,
body[style*="--cor-calculadora: #ffffff"] #historico p {
  color: black !important;
  background: #eee !important;
}

/* Histórico no tema gradiente */
body[style*="gradient"] #historico,
body[style*="gradient"] #historico p {
  color: black !important;
  background: rgba(255, 255, 255, 0.9) !important;
}