/* ========================================================================
   GLIVE Solutions — UI Kit (Dark • Black/Red)
   File: assets/css/main.css
   Font: Inter (Google Fonts)
   ======================================================================== */

/* Google Fonts */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap");

/* --------------------------- Reset / Base ------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body, h1, h2, h3, h4, h5, h6, p,
ul, ol, li, figure, blockquote, dl, dd {
  margin: 0;
  padding: 0;
}

html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  line-height: 1.5;
  background: #0b0c0f; /* preto base */
  color: #e9eef3;
}

img, video { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: #070707; }
a { color: #ff4d4d; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Focus visível e acessível */
:focus-visible {
  outline: 2px solid #ff4d4d;
  outline-offset: 2px;
}

/* Scrollbar discreta */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #1f2430; border-radius: 8px; }
*::-webkit-scrollbar-track { background: #0b0c0f; }

/* --------------------------- Tokens de Cor ------------------------------ */
:root {
  --bg-0: #0b0c0f;
  --bg-1: #0f1117;
  --bg-2: #151923;
  --line-1: #212838;
  --muted: #9db0c0;

  --red: #ff4d4d;         /* primária */
  --red-600: #e23b3b;
  --red-700: #c92f2f;

  --accent: #ff4d4d;
  --brand: #ff4d4d;
}

/* --------------------------- Layout Básico ------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, #0f1117 0%, #0b0c0f 100%);
  border-bottom: 1px solid var(--line-1);
}

.navbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .3px;
}
.brand::before {
  content: "";
  width: 10px; height: 10px; border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 14px var(--brand);
}

.nav {
  display: flex; gap: 10px; list-style: none; flex-wrap: wrap;
}
.nav a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
}
.nav a.active {
  background: #161b24;
  border-color: var(--line-1);
  text-decoration: none;
}

.site-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

.section { display: grid; gap: 16px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
}
.section-actions { display: flex; gap: 10px; }

/* Rodapé */
.site-footer {
  border-top: 1px solid var(--line-1);
  margin-top: 28px;
  padding: 16px 20px;
  text-align: center;
  color: var(--muted);
}

/* --------------------------- Componentes -------------------------------- */

/* Cards */
.card { background: var(--bg-1); border: 1px solid var(--line-1); border-radius: 14px; }
.card-body { padding: 16px; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-1); background: #151923; color: #e9eef3;
  text-decoration: none; transition: transform .06s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { background: #1a1f2a; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--red); border-color: var(--red-600); color: #fff; }
.btn.primary:hover { background: var(--red-600); border-color: var(--red-700); }

/* Formulários */
.form { display: grid; gap: 14px; }
.form .row { display: grid; gap: 10px; }
.form .row.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .form .row.two { grid-template-columns: 1fr; } }

label { display: grid; gap: 6px; font-weight: 600; }
input[type="text"],
input[type="date"],
input[type="search"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-1);
  background: var(--bg-2);
  color: #e9eef3;
}
textarea { resize: vertical; min-height: 92px; }

input::placeholder, textarea::placeholder { color: #7c8ea0; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Tabelas */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: 12px;
  overflow: hidden;
}
.table th, .table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-1);
  text-align: left;
}
.table thead th {
  background: #121722;
  font-weight: 700;
}
.table tbody tr:hover { background: #12151d; }
.table .actions { display: inline-flex; gap: 8px; align-items: center; }
.inline-form { display: inline; }

/* Estado vazio */
.empty-state {
  padding: 18px;
  border: 1px dashed var(--line-1);
  border-radius: 12px;
  color: var(--muted);
}

/* Links “ordenar” com setas */
.sort-arrow { font-size: .9em; opacity: .8; margin-left: 6px; }

/* --------------------------- Scanner (Products) -------------------------- */
.barcode-input-group {
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* Container do scanner */
#scanArea {
  position: relative;
  margin-top: 12px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line-1);
  border-radius: 12px;
}

/* Vídeo e canvas injetados pelo Quagga */
#scanArea video,
#scanArea canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: transparent;
  border-radius: 12px;
  will-read-frequently: true;
}

/* Overlay do scanner */
#scanArea #quaggaOverlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border-radius: 12px;
}

/* Status */
#scanArea #detectionStatus {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
}

/* Controles (câmera/lanterna) */
#scanArea .scanner-actions {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: auto;
}

/* Fallback para browsers sem aspect-ratio */
@supports not (aspect-ratio: 1) {
  #scanArea {
    height: 0;
    padding-bottom: 56.25%; /* 16:9 */
  }
  #scanArea > * {
    position: absolute;
    inset: 0;
  }
}

/* Mobile */
@media (max-width: 720px) {
  #scanArea {
    max-height: 60vh;
  }
}

/* --------------------------- Utilitários -------------------------------- */
.muted { color: var(--muted); }
.hide { display: none !important; }
.center { text-align: center; }
.right { text-align: right; }

/* ========== Responsive Tables (mobile) ========== */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-scroll > .table {
  min-width: 720px;
}

/* Filtro (badge + botão limpar) */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #161b24;
  border: 1px solid var(--line-1);
  color: #e9eef3;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Botão outline */
.btn.outline {
  background: transparent;
  border-color: var(--red);
  color: var(--red);
}
.btn.outline:hover {
  background: rgba(255, 77, 77, 0.1);
}

/* Mobile tweaks */
@media (max-width: 720px) {
  .navbar { padding: 10px 14px; }
  .site-main { padding: 14px; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .table th, .table td { padding: 10px 12px; }
}

/* ====== Barcodes (lista de equipamentos) ====== */
.table-equipments .barcode-cell { text-align: center; vertical-align: middle; }

.barcode-wrap {
  display: inline-block;
  background: #fff;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid #e5e7eb1a;
}

.barcode-text { margin-top: 4px; font-size: 12px; }

.barcode-wrap svg { display: block; }

@media print {
  body { background: #fff; color: #000; }
  .barcode-wrap { background: #fff !important; }
}
