* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: #0d1117;
  color: #e2e8f0;
  min-height: 100vh;
  padding: 5rem 2rem 2rem 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

/* Container do Layout Dividido */
.dashboard-container {
  width: 100%;
  max-width: 950px;
  display: flex;
  flex-direction: row;
  gap: 2rem;
  align-items: stretch; /* Alinha os dois blocos para terem exatamente a mesma altura */
}

/* Calculadora Achatada e Estreita */
#conteudo_calculadora {
  background: #161b22;
  border: 1px solid #30363d;
  padding: 0.8rem;
  border-radius: 16px;
  flex: 1;
  max-width: 290px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);

  display: flex;
  flex-direction: column;
  justify-content: space-between; /* Distribui os elementos para preencher a altura do bloco */
}

/* Seção do Gráfico (Direita) */
.secao-grafico {
  background: #161b22;
  border: 1px solid #30363d;
  padding: 1.5rem;
  border-radius: 16px;
  flex: 2;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);

  display: flex;
  flex-direction: column;
}

/* Garante que o teclado estique para preencher o espaço se necessário */
.teclado-calculadora {
  display: flex;
  gap: 0.4rem;
  flex-grow: 1;
}

h2 {
  font-size: 1.1rem;
  color: #8b949e;
  margin-bottom: 1rem;
  text-align: center;
}

#visor {
  width: 100%;
  height: 50px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 10px;
  color: #58a6ff;
  font-size: 1.6rem;
  text-align: right;
  padding: 0 1rem;
  font-family: monospace;
  margin-bottom: 0.8rem;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.bloco-numeros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  flex: 1.3;
}

/* Grid de Operações 4x2 */
.bloco-operacoes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 0.35rem;
  flex: 1;
}

/* Botões Compactos */
button {
  padding: 0.45rem 0.6rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  background: #21262d;
  color: #c9d1d9;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 0 #121519;
}

button:hover {
  background: #30363d;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.35),
    0 2px 0 #161b22;
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #121519;
}

.btn-op {
  background: #1f6feb;
  color: white;
  box-shadow: 0 2px 0 #114594;
}
.btn-op:hover {
  background: #388bfd;
  box-shadow:
    0 3px 6px rgba(31, 111, 235, 0.25),
    0 2px 0 #114594;
}

.btn-clear {
  background: #da3633;
  color: white;
  box-shadow: 0 2px 0 #8c201e;
}
.btn-clear:hover {
  background: #f85149;
  box-shadow:
    0 3px 6px rgba(218, 54, 51, 0.25),
    0 2px 0 #8c201e;
}

.btn-backspace {
  background: #6e7681;
  color: white;
  box-shadow: 0 2px 0 #484f58;
}
.btn-backspace:hover {
  background: #8b949e;
  box-shadow:
    0 3px 6px rgba(110, 118, 129, 0.25),
    0 2px 0 #484f58;
}

.btn-igual {
  background: #238636;
  color: white;
  box-shadow: 0 2px 0 #145220;
}
.btn-igual:hover {
  background: #2ea043;
  box-shadow:
    0 3px 6px rgba(35, 134, 54, 0.25),
    0 2px 0 #145220;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
}

.btn-historico-toggle {
  position: fixed;
  top: 1rem;
  right: 2rem;
  z-index: 99;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 8px;
}

.sidebar-logs {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: #161b22;
  border-left: 1px solid #30363d;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.sidebar-logs.active {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #30363d;
  padding-bottom: 0.8rem;
  margin-bottom: 1rem;
}

.sidebar-header h2 {
  margin-bottom: 0;
  color: #8b949e;
}

.btn-fechar-sidebar {
  background: transparent;
  box-shadow: none;
  color: #8b949e;
  padding: 0.3rem 0.6rem;
}

#conteudo_logs {
  flex: 1;
  overflow-y: auto;
  font-size: 0.85rem;
  color: #c9d1d9;
  font-family: monospace;
}

#conteudo_logs p {
  border-bottom: 1px solid #21262d;
  padding-bottom: 4px;
  margin-bottom: 4px;
}

@media (max-width: 850px) {
  body {
    padding-top: 5rem;
  }
  .dashboard-container {
    flex-direction: column;
    align-items: center;
  }
  #conteudo_calculadora,
  .secao-grafico {
    max-width: 100%;
    width: 100%;
  }
  .sidebar-logs {
    width: 100%;
  }
}
