/* =========================================================
   048 CODE BARRAS
   Visual completo do leitor de códigos pela câmera
   ========================================================= */

.botao-leitor {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 48px;
  margin-top: 5px;
  padding: 11px 14px;
  background: #202429;
  border: 1px solid #343a40;
  border-radius: 5px;
  color: #ffffff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.2s;
}

.botao-leitor span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: #b5121b;
  border-radius: 4px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 900;
}

.botao-leitor:hover {
  background: #b5121b;
  border-color: #b5121b;
  transform: translateY(-1px);
}

.botao-leitor:hover span {
  background: #ffffff;
  color: #b5121b;
}

.botao-leitor:focus-visible {
  outline: 3px solid rgba(181, 18, 27, 0.28);
  outline-offset: 2px;
}

.informacao-leitor {
  margin: 7px 2px 18px;
  color: #747a81;
  font-size: 0.73rem;
  line-height: 1.45;
}

/* Fundo da janela */

.janela-leitor {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
  background: rgba(4, 6, 8, 0.88);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.janela-leitor.aberta {
  display: flex;
}

/* Caixa principal */

.conteudo-leitor {
  width: min(100%, 620px);
  overflow: hidden;
  background: #15181b;
  border: 1px solid #34383d;
  border-radius: 10px;
  box-shadow:
    0 25px 70px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.03);
  color: #ffffff;
}

.cabecalho-leitor {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  padding: 19px 20px 16px;
  background:
    linear-gradient(
      135deg,
      rgba(181, 18, 27, 0.24),
      transparent 54%
    ),
    #191c20;
  border-bottom: 1px solid #34383d;
}

.identificacao-leitor {
  display: block;
  margin-bottom: 5px;
  color: #e02833;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.17em;
}

.cabecalho-leitor h2 {
  margin: 0;
  color: #ffffff;
  font-size: 1.12rem;
  line-height: 1.3;
}

.botao-fechar-leitor {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0 0 3px;
  background: #292d32;
  border: 1px solid #3d4248;
  border-radius: 5px;
  color: #ffffff;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: 1.7rem;
  line-height: 1;
}

.botao-fechar-leitor:hover {
  background: #b5121b;
  border-color: #b5121b;
}

/* Área de vídeo */

.area-camera {
  position: relative;
  width: 100%;
  min-height: 340px;
  overflow: hidden;
  background:
    radial-gradient(
      circle at center,
      #252a2f,
      #090a0c 72%
    );
}

#video-leitor {
  display: block;
  width: 100%;
  height: min(58vh, 430px);
  min-height: 340px;
  background: #050607;
  object-fit: cover;
}

.mira-leitor {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(82%, 450px);
  height: 160px;
  pointer-events: none;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0.25),
    0 0 22px rgba(181, 18, 27, 0.35);
  transform: translate(-50%, -50%);
}

.mira-leitor::before,
.mira-leitor::after {
  position: absolute;
  top: -3px;
  width: 36px;
  height: 36px;
  border-top: 5px solid #e31c27;
  content: "";
}

.mira-leitor::before {
  left: -3px;
  border-left: 5px solid #e31c27;
  border-radius: 8px 0 0;
}

.mira-leitor::after {
  right: -3px;
  border-right: 5px solid #e31c27;
  border-radius: 0 8px 0 0;
}

.mira-leitor span::before,
.mira-leitor span::after {
  position: absolute;
  bottom: -3px;
  width: 36px;
  height: 36px;
  border-bottom: 5px solid #e31c27;
  content: "";
}

.mira-leitor span::before {
  left: -3px;
  border-left: 5px solid #e31c27;
  border-radius: 0 0 0 8px;
}

.mira-leitor span::after {
  right: -3px;
  border-right: 5px solid #e31c27;
  border-radius: 0 0 8px;
}

/* Linha vermelha animada */

.mira-leitor span {
  position: absolute;
  top: 12px;
  right: 10px;
  bottom: 12px;
  left: 10px;
  display: block;
}

.mira-leitor span {
  background:
    linear-gradient(
      to bottom,
      transparent 0,
      transparent 48%,
      rgba(227, 28, 39, 0.25) 49%,
      #e31c27 50%,
      rgba(227, 28, 39, 0.25) 51%,
      transparent 52%,
      transparent 100%
    );
  background-size: 100% 200%;
  animation: movimentar-linha-leitor 2.1s linear infinite;
}

@keyframes movimentar-linha-leitor {
  from {
    background-position: 0 -100%;
  }

  to {
    background-position: 0 100%;
  }
}

.camera-carregando {
  position: absolute;
  top: 20px;
  left: 50%;
  padding: 9px 13px;
  background: rgba(12, 14, 16, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%);
}

.camera-carregando.oculto {
  display: none;
}

/* Informações e botões */

.situacao-leitor {
  min-height: 43px;
  margin: 0;
  padding: 13px 20px;
  background: #1a1d21;
  border-top: 1px solid #30343a;
  border-bottom: 1px solid #30343a;
  color: #d4d7da;
  font-size: 0.81rem;
  line-height: 1.45;
  text-align: center;
}

.situacao-leitor.sucesso {
  background: rgba(26, 117, 66, 0.2);
  border-color: rgba(42, 190, 105, 0.36);
  color: #72e5a3;
}

.situacao-leitor.erro {
  background: rgba(181, 18, 27, 0.18);
  border-color: rgba(226, 29, 42, 0.38);
  color: #ff8c94;
}

.acoes-leitor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 15px 20px 10px;
}

.acoes-leitor button {
  min-height: 44px;
  padding: 9px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 800;
}

.botao-trocar-camera {
  background: #b5121b;
  border: 1px solid #b5121b;
  color: #ffffff;
}

.botao-trocar-camera:hover {
  background: #d01823;
  border-color: #d01823;
}

.botao-cancelar-leitura {
  background: transparent;
  border: 1px solid #555b62;
  color: #ffffff;
}

.botao-cancelar-leitura:hover {
  background: #292d32;
}

.selecionar-imagem-codigo {
  display: block;
  margin: 3px 20px 12px;
  padding: 12px;
  background: #202429;
  border: 1px dashed #5b6168;
  border-radius: 5px;
  color: #dadddf;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
}

.selecionar-imagem-codigo:hover {
  border-color: #e01c28;
  color: #ffffff;
}

.selecionar-imagem-codigo input {
  display: none;
}

.aviso-camera {
  margin: 0;
  padding: 0 20px 17px;
  color: #8f959c;
  font-size: 0.7rem;
  line-height: 1.45;
  text-align: center;
}

/* Impede movimentação da página enquanto a câmera está aberta */

body.leitor-aberto {
  overflow: hidden;
}

/* Celulares */

@media (max-width: 620px) {
  .janela-leitor {
    align-items: stretch;
    padding: 0;
  }

  .conteudo-leitor {
    width: 100%;
    min-height: 100%;
    border: 0;
    border-radius: 0;
  }

  .cabecalho-leitor {
    padding:
      max(15px, env(safe-area-inset-top))
      15px
      14px;
  }

  .cabecalho-leitor h2 {
    font-size: 1rem;
  }

  .area-camera {
    min-height: 310px;
  }

  #video-leitor {
    height: 52vh;
    min-height: 310px;
    max-height: 510px;
  }

  .mira-leitor {
    width: 88%;
    height: 145px;
  }

  .situacao-leitor {
    padding: 11px 15px;
  }

  .acoes-leitor {
    padding: 12px 15px 9px;
  }

  .selecionar-imagem-codigo {
    margin-right: 15px;
    margin-left: 15px;
  }

  .aviso-camera {
    padding-right: 15px;
    padding-bottom:
      max(15px, env(safe-area-inset-bottom));
    padding-left: 15px;
  }
}

/* Telas pequenas na horizontal */

@media (max-height: 560px) and (orientation: landscape) {
  .janela-leitor {
    align-items: flex-start;
  }

  .conteudo-leitor {
    width: min(100%, 760px);
  }

  #video-leitor,
  .area-camera {
    min-height: 230px;
    height: 230px;
  }

  .mira-leitor {
    height: 115px;
  }
}

/* Acessibilidade: reduz animações */

@media (prefers-reduced-motion: reduce) {
  .botao-leitor {
    transition: none;
  }

  .mira-leitor span {
    animation: none;
    background-position: center;
  }
}

/* Não mostrar o leitor durante impressão */

@media print {
  .botao-leitor,
  .informacao-leitor,
  .janela-leitor {
    display: none !important;
  }
}