/* RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* BODY */
body {
  font-family: Arial, sans-serif;
}

/* BARRA FIXA TOPO */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;

    background: #2563eb;
    color: white;

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 0 15px;
    font-size: 14px;

    z-index: 999;
}

/* centro */
.topbar-center {
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* direita */
.topbar-right {
    display: flex;
    align-items: center;
}

/* botão logout */
.logout-btn {
    color: white;
    text-decoration: none;
    font-size: 18px;
    padding: 6px 10px;
    border-radius: 8px;
    transition: 0.2s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* espaçamento do conteúdo por causa da barra */
body {
    padding-top: 60px;
}

/* lados */
.topbar-left,
.topbar-right {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
}

/* mobile */
@media (max-width: 600px) {

    .topbar {
        font-size: 12px;
        height: 45px;
    }

    body {
        padding-top: 55px;
    }
}

/* CONTAINER */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;

  background: #fff;
  padding: 25px;
  border-radius: 15px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.15);

  width: 90%;
  max-width: 400px;
}

.scanner-wrapper {
    position: relative;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 4 / 3;
}

/* câmera isolada (SEM overlays dentro) */
#camera {
    width: 100%;
    height: 100%;
    border: 3px solid #333;
    border-radius: 12px;
    overflow: hidden;
    background: black;
}

/* vídeo sempre controlado pelo plugin */
#camera video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* UI externa acima da câmera */
#scan-ui {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

/* botão de som (interativo) */
#soundToggle {
    position: absolute;
    top: 10px;
    right: 10px;
    pointer-events: auto;
    font-size: 22px;
    cursor: pointer;
    z-index: 20;
}

/* linha de scan visual */
.scan-line {
    position: absolute;
    width: 100%;
    height: 3px;
    background: red;
    box-shadow: 0 0 10px red;
    animation: scan 2s infinite;
}

@keyframes scan {
    0% { top: 0; }
    50% { top: 100%; }
    100% { top: 0; }
}

/* TEXTO */
#codigo {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  text-align: center;
}

/* GRUPO */
.grupo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

/* INPUT */
input {
  padding: 10px;
  width: 80px;
  text-align: center;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #ccc;
}

/* ========================= */
/* BOTÕES (IMPORTANTE AQUI) */
/* ========================= */

.botoes {
  display: flex;
  gap: 10px;
  width: 100%;
}

.botoes a {
  flex: 1;
  text-decoration: none;
}

/* BOTÃO PADRÃO */
button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #007bff;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: 0.3s;
}

button:hover {
  background: #0056b3;
}

/* botão histórico (opcional destaque azul diferente) */
.botoes a button {
  background: #2563eb;
}

/* resultado */
#resultado {
  font-weight: bold;
  color: #333;
}

/* sair */
.sair {
  width: 100%;
}

.sair button {
  width: 100%;
  background: #111;
  padding: 14px;
}

/* ========================= */
/* MOBILE */
/* ========================= */
@media (max-width: 600px) {

  body {
    align-items: flex-start;
    padding-top: 20px;
  }

  .container {
    width: 95%;
    padding: 15px;
  }

  input {
    width: 100%;
    font-size: 18px;
  }

  .botoes {
    flex-direction: column;
  }

  button {
    width: 100%;
    font-size: 18px;
  }
}