@import url('https://fonts.googleapis.com/css2?family=Kumbh+Sans:wght@700&display=swap');

*{
    padding: 0px;
    margin: 0px;
    box-sizing: border-box;
    font-family: 'Kumbh Sans', sans-serif;
}

:root{
    --cor-body: #3B4664;
    --cor-resultado: #191F32;
    --cor-font-primaria:#FDFFFF;
    --cor-font-secundaria:#464e59;
    --cor-font-terciaria:#fff9ff;
    --cor-teclado: #252D44;
    --cor-teclas: #E9E3DC;
    --cor-teclas-hover: #ffffff;
    --cor-teclaEnter: #D13F30;
    --cor-teclaEnter-hover: #ec5949;
    --cor-teclaReset: #647298;
    --cor-teclaReset-hover: #8b9dce;
    --cor-box-shadow-teclas: #b4a398;
    --cor-box-shadow-reset: #424e73;
    --cor-box-shadow-enter: #883900;
    --cor-proxtema: #00decf;

    --cor-historico-bg: rgba(0,0,0,0.12);
    --cor-historico-border: #505a7a;
    --cor-historico-text: #ffffff;
    --cor-historico-hover: #7785b1;
}

body{
    min-height: 100vh;
    background-color: var(--cor-body);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.attribution {
    font-size: 11px;
    text-align: center;
    color: var(--cor-teclaReset-hover);
}
.attribution a {
    color: var(--cor-teclaEnter-hover);
}

#main{
    width: 350px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

header{
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--cor-font-primaria);
}

header #d_tema{
    display: flex;
    gap: 20px;
    padding: 5px;
    align-items: center;
}

#tema_1{
    width: 30px;
    height: 30px;
    background-color: var(--cor-teclaEnter);
    border-radius: 20px;
    transition-property: background-color, scale;
    transition-duration: 1s;
}

#tema_1:hover{
    background-color: var(--cor-proxtema);
    scale: 0.9;
}

#d_resultado{
    background-color: var(--cor-resultado);
    width: 100%;
    height: 80px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    padding-right: 10px;
}

#p_resultado{
    color: var(--cor-font-primaria);
    font-size: 32px;
    display: flex;
    justify-content: right;
    align-items: center;
    height: 48px;
    padding-right: 6px;
    word-break: break-all;
}

#telaAux{
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: right;
    height: 20px;
}

#aux{
    color: var(--cor-font-secundaria);
    padding-right: 6px;
}

#operação{
    color: var(--cor-font-secundaria);
    padding-right: 6px;
}

#d_teclado{
    width: 100%;
    min-height: 300px;
    border-radius: 8px;
    background-color: var(--cor-teclado);
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    align-content: center;
    -webkit-user-select:none;
    -moz-user-select:none;
    -ms-user-select:none;
    user-select:none;
}

.tecla{
    border-radius: 8px;
    background-color: var(--cor-teclas);
    color: var(--cor-font-secundaria);
    font-size: 20px;
    flex-shrink: 1;
    width: 65px;
    height: 40px;
    flex-grow: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0px 0px var(--cor-box-shadow-teclas);
    cursor: pointer;
    user-select: none;
}

.tecla:hover{
    background-color: var(--cor-teclas-hover);
}

#reset, #del{
    background-color: var(--cor-teclaReset);
    color: var(--cor-font-terciaria);
    box-shadow: 2px 2px 0px 0px var(--cor-box-shadow-reset);
}
#del > svg{
    width: 25px;
}

#reset:hover, #del:hover{
    background-color: var(--cor-teclaReset-hover);
}

#enter{
    background-color: var(--cor-teclaEnter);
    color: var(--cor-font-terciaria);
    box-shadow: 2px 2px 0px 0px var(--cor-box-shadow-enter);
}

#enter:hover{
    background-color: var(--cor-teclaEnter-hover);
    color: var(--cor-font-primaria);
}

#overlay_historico {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: flex-start;
  align-items: center;
  z-index: 9999;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px 0;
}

#vazio {
    font-size: 2rem;
    color: var(--cor-font-primaria);
    padding-top: 2rem;
}

#overlay_historico.show {
  display: flex;
}

.historico-item {
  width: 90%;
  max-width: 350px;
  color: var(--cor-historico-text);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.00));
  border: 1px solid var(--cor-historico-border);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  transition: border-color 0.3s ease, transform 0.12s ease;
  margin: 4px 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

.historico-item + .historico-item {
  margin-top: 2px;
}

.historico-item:hover {
  border-color: var(--cor-historico-hover);
  transform: translateY(-2px);
}

.historico-item p {
  margin: 0;
  font-size: 1.05rem;
  user-select: none;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: calc(100% - 44px);
  line-height: 1.3; 
  color: var(--cor-font-primaria);
}

.historico-item .btn-delete {
  background: transparent;
  border: none;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 8px;
  line-height: 0;
  border-radius: 4px;
}

.historico-item .btn-delete svg {
  width: 22px;
  height: 22px;
  fill: #fff;
  transition: transform 0.18s ease, fill 0.18s ease;
  pointer-events: none; 
}

.historico-item .btn-delete:hover svg {
  fill: #ff3b3b;
  transform: scale(1.15);
}

.historico-item.fade-out {
  opacity: 0;
  transform: translateX(10px) scale(0.98);
  transition: all 0.18s ease;
  pointer-events: none;
}

.historico-item.enter {
  opacity: 0;
  transform: translateY(6px);
  animation: enterAnim 180ms ease forwards;
}
@keyframes enterAnim {
  to { opacity: 1; transform: translateY(0); }
}

#overlay_historico::-webkit-scrollbar {
  width: 6px;
}
#overlay_historico::-webkit-scrollbar-thumb {
  background: #505a7a;
  border-radius: 3px;
}

#btn_historico {
  background: transparent;
  border: none;
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  margin-right: 0;
}
#btn_historico svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  color: var(--cor-font-primaria);
}

#header_left {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 420px) {
  #main { width: 92%; }
  .tecla { width: 60px; height: 44px; font-size: 18px; }
  #p_resultado { font-size: 28px; }
}

button:focus, .tecla:focus, .btn-delete:focus {
  outline: 2px solid rgba(255,255,255,0.12);
  outline-offset: 2px;
  border-radius: 6px;
}
