/* ══════════════════════════════════════════════════════════════
   TecladoAdaptativo — layout por zonas
   ══════════════════════════════════════════════════════════════ */

.teclado-adaptativo {
  --kbd-gap: 7px;
  display: flex;
  flex-direction: column;
  gap: var(--kbd-gap);
  width: fit-content;
  margin: 0 auto;
}

/* Zona principal: numpad | ops-col | struct-col */
.teclado-zona-principal {
  display: flex;
  gap: var(--kbd-gap);
  align-items: flex-start;
}

/* Numpad 3×4 — colunas fixas de 64px */
.teclado-numpad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: var(--kbd-gap);
  flex-shrink: 0;
}


/* Coluna de operadores básicos (posições fixas) */
.teclado-ops-col {
  display: flex;
  flex-direction: column;
  gap: var(--kbd-gap);
  flex-shrink: 0;
  width: 64px;
}

/* Operador ausente no perfil — ocupa espaço mas é invisível */
.tecla-invisivel {
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Zona de estruturais — grid auto-fill, itens com largura fixa, alinhados à esquerda */
.teclado-struct-col {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 72px));
  justify-content: start;
  align-content: start;
  gap: var(--kbd-gap);
}

/* Linha extra: ops estendidos + variáveis */
.teclado-linha-extra {
  display: flex;
  flex-wrap: wrap;
  gap: var(--kbd-gap);
}

/* Barra de navegação — flex com separador entre ← → e ⌫ ↵ */
.teclado-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--kbd-gap);
  align-items: stretch;
}

/* Todos os botões da nav podem encolher; os de acção têm mínimo */
.teclado-nav button {
  flex: 1;
  min-width: 0;
}

/* ⌫ e ↵ mantêm alvo de toque mínimo — setas encolhem primeiro */
.tecla-apagar,
.tecla-confirmar {
  min-width: 44px;
  flex-shrink: 0;
}

/* Separador visual entre ← ↑ ↓ → e ⌫ ↵ */
.teclado-nav-sep {
  width: 1.5px;
  background: #bfdbfe;
  border-radius: 1px;
  flex-shrink: 0;
  margin: 3px 0;
}

/* ── Estilos base de todos os botões do teclado adaptativo ── */
.teclado-adaptativo button,
.teclado-num button {
  border: 1.5px solid #bfdbfe;
  border-radius: 12px;
  padding: 11px 0;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  background: #dbeafe;
  color: #1e40af;
  user-select: none;
  transition: background 0.09s, box-shadow 0.09s, transform 0.07s;
  line-height: 1;
  font-family: system-ui, sans-serif;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.10);
  min-width: 0;
}

.teclado-adaptativo button:hover {
  background: #bfdbfe;
  box-shadow: 0 3px 7px rgba(37, 99, 235, 0.16);
}

.teclado-adaptativo button:active {
  background: #93c5fd;
  transform: scale(0.94);
  box-shadow: none;
}

/* Operadores: +  −  ×  ÷  =  (  )  … */
.tecla-op {
  color: #9a3412 !important;
  background: #fed7aa !important;
  border-color: #fdba74 !important;
  box-shadow: 0 2px 4px rgba(154, 52, 18, 0.10) !important;
}
.tecla-op:hover { background: #fdba74 !important; }
.tecla-op:active { background: #fb923c !important; }

/* Estruturais: x/y  xʸ  √x  … */
.tecla-estrutural {
  font-size: 13px !important;
  color: #065f46 !important;
  background: #d1fae5 !important;
  border-color: #a7f3d0 !important;
  box-shadow: 0 2px 4px rgba(6, 95, 70, 0.10) !important;
}
.tecla-estrutural:hover { background: #a7f3d0 !important; }
.tecla-estrutural:active { background: #6ee7b7 !important; }

/* Variáveis: x  y  n  … */
.tecla-var {
  color: #6b21a8 !important;
  font-style: italic !important;
  font-size: 18px !important;
  background: #f3e8ff !important;
  border-color: #d8b4fe !important;
  box-shadow: 0 2px 4px rgba(107, 33, 168, 0.10) !important;
}
.tecla-var:hover { background: #d8b4fe !important; }
.tecla-var:active { background: #c084fc !important; }

/* Apagar ⌫ */
.tecla-apagar {
  color: #991b1b !important;
  font-size: 16px !important;
  background: #fecaca !important;
  border-color: #fca5a5 !important;
  box-shadow: 0 2px 4px rgba(153, 27, 27, 0.10) !important;
}
.tecla-apagar:hover { background: #fca5a5 !important; }
.tecla-apagar:active { background: #f87171 !important; }

/* Barra de navegação ← ↑ ↓ → ↵ */
.tecla-nav {
  font-size: 16px !important;
  color: #1e3a8a !important;
  background: #eff6ff !important;
  border-color: #bfdbfe !important;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.08) !important;
  padding: 9px 0 !important;
}
.tecla-nav:hover { background: #dbeafe !important; }
.tecla-nav:active { background: #93c5fd !important; transform: scale(0.94); }

/* Confirmar ↵ — destaque ligeiro */
.tecla-confirmar {
  color: #065f46 !important;
  background: #a7f3d0 !important;
  border-color: #6ee7b7 !important;
  font-weight: 700 !important;
}
.tecla-confirmar:hover { background: #6ee7b7 !important; }

/* Botão numérico */
.tecla-num {
  /* herda o estilo base */
}

/* ══════════════════════════════════════════════════════════════
   TecladoMat legado — grelha 5 colunas (usado como wrapper)
   Manter por compatibilidade com páginas que ainda não migraram
   ══════════════════════════════════════════════════════════════ */
.teclado-mat {
  /* agora é alias de teclado-adaptativo, via wrapper Rust */
}

/* ══════════════════════════════════════════════════════════════
   TecladoNum — 4 colunas, numérico simples
   ══════════════════════════════════════════════════════════════ */
.teclado-num {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  max-width: 280px;
  margin: 0 auto;
}

.teclado-num button {
  border: 1.5px solid #bfdbfe;
  border-radius: 12px;
  padding: 13px 0;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  background: #dbeafe;
  color: #1e40af;
  user-select: none;
  transition: background 0.09s, box-shadow 0.09s, transform 0.07s;
  line-height: 1;
  font-family: system-ui, sans-serif;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.10);
}

.teclado-num button:hover { background: #bfdbfe; }
.teclado-num button:active { background: #93c5fd; transform: scale(0.94); }

@media (max-width: 480px) {
  .teclado-adaptativo {
    --kbd-gap: 5px;
    font-size: 15px;
  }
  .teclado-adaptativo button {
    font-size: 15px;
    padding: 10px 0;
    border-radius: 10px;
  }
  .teclado-numpad { grid-template-columns: repeat(3, 54px); }
  .teclado-ops-col { width: 54px; }
  .tecla-estrutural { font-size: 12px !important; }
}
