/* ============================================================
   QR-AR Studio — Design Tokens
   Paleta: noturno tecnológico, viewfinder de câmera
   Display: 'Space Grotesk' | Corpo: 'Inter' | Dados: 'JetBrains Mono'
============================================================ */
:root{
  --bg: #0a0d12;
  --bg-soft: #10141c;
  --surface: rgba(255,255,255,0.04);
  --surface-strong: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.09);
  --text: #e7ebf1;
  --text-muted: #8d97a8;
  --accent: #49f3d1;       /* ciano-menta — escaneamento */
  --accent-soft: rgba(73,243,209,0.14);
  --violet: #8b6bff;       /* segundo acento — AR / profundidade */
  --danger: #ff6b6b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 40px rgba(0,0,0,0.45);
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html,body{
  height:100%;
  background: radial-gradient(circle at 15% -10%, #131a24 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

::selection{ background: var(--accent-soft); color: var(--accent); }

a{ color: inherit; text-decoration:none; }
button{ font-family: inherit; cursor:pointer; border:none; background:none; color:inherit; }
input,select,textarea{ font-family: inherit; }

/* ---------- Layout shell ---------- */
.app-shell{
  display:grid;
  grid-template-columns: 248px 1fr;
  min-height:100vh;
}

@media (max-width: 880px){
  .app-shell{ grid-template-columns: 1fr; }
  .sidebar{ position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .3s ease; z-index: 50; }
  .sidebar.open{ transform: translateX(0); }
}

/* ---------- Sidebar ---------- */
.sidebar{
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 28px 18px;
  display:flex;
  flex-direction:column;
  gap: 30px;
  width: 248px;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.brand .dot{
  width:10px;height:10px;border-radius:50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.nav{ display:flex; flex-direction:column; gap:4px; }
.nav-item{
  display:flex; align-items:center; gap:10px;
  padding:10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover{ background: var(--surface); color: var(--text); }
.nav-item.active{ background: var(--accent-soft); color: var(--accent); }
.nav-item svg{ width:16px; height:16px; flex-shrink:0; }

.sidebar-foot{
  margin-top:auto;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height:1.6;
  border-top:1px solid var(--border);
  padding-top:14px;
}

/* ---------- Main area ---------- */
.main{
  padding: 28px 36px 60px;
  max-width: 1180px;
}

.topbar{
  display:flex; align-items:flex-end; justify-content:space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap:14px;
}

.topbar h1{
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
}
.topbar p{ color: var(--text-muted); font-size: 0.9rem; margin-top:4px; }

.menu-btn{ display:none; }
@media (max-width:880px){
  .menu-btn{ display:flex; align-items:center; gap:8px; color:var(--text-muted); font-size:0.8rem; }
}

/* ---------- Grid / cards ---------- */
.grid{
  display:grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 900px){ .grid{ grid-template-columns: 1fr; } }

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.card h2{
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.card .hint{ color: var(--text-muted); font-size: 0.8rem; margin-bottom: 18px; }

/* ---------- Form elements ---------- */
.field{ margin-bottom: 16px; }
.field label{
  display:block; font-size: 0.74rem; text-transform: uppercase; letter-spacing:.06em;
  color: var(--text-muted); margin-bottom:7px; font-family: var(--font-mono);
}
.field input[type=text],
.field input[type=url],
.field select{
  width:100%;
  background: var(--bg-soft);
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  color: var(--text);
  font-size: 0.88rem;
  transition: border-color .15s ease;
}
.field input:focus, .field select:focus{
  outline: none; border-color: var(--accent);
}

.tabs{ display:flex; gap:6px; margin-bottom:18px; background:var(--bg-soft); padding:4px; border-radius: var(--radius-sm); border:1px solid var(--border); }
.tab{
  flex:1; text-align:center; padding:9px 0; border-radius:7px;
  font-size:0.82rem; color: var(--text-muted); transition: all .15s ease;
}
.tab.active{ background: var(--surface-strong); color: var(--text); }

.dropzone{
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 28px 16px;
  text-align:center;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: border-color .15s ease, background .15s ease;
  cursor:pointer;
}
.dropzone:hover, .dropzone.drag{ border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dropzone svg{ width:26px; height:26px; margin-bottom:10px; opacity:.7; }

.preview-thumb{
  margin-top:14px; border-radius: var(--radius-sm); overflow:hidden;
  border:1px solid var(--border); max-height: 220px; display:flex; align-items:center; justify-content:center; background:#000;
}
.preview-thumb img, .preview-thumb video{ width:100%; max-height:220px; object-fit:contain; }

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem; font-weight: 600;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn-primary{ background: var(--accent); color: #06231d; box-shadow: 0 6px 22px rgba(73,243,209,0.25); }
.btn-primary:hover{ transform: translateY(-1px); }
.btn-ghost{ background: var(--surface-strong); border:1px solid var(--border); color: var(--text); }
.btn-ghost:hover{ border-color: var(--accent); }
.btn-row{ display:flex; gap:10px; margin-top: 6px; flex-wrap:wrap; }
.btn:disabled{ opacity:.4; cursor:not-allowed; transform:none; }

/* ---------- QR preview card (signature element) ---------- */
.qr-stage{
  position:relative;
  display:flex; align-items:center; justify-content:center;
  background: radial-gradient(circle at 50% 30%, #121826, #0a0d12 75%);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 30px;
  min-height: 320px;
}
.qr-frame{
  position:relative;
  background: #fff;
  padding: 16px;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 18px 50px rgba(0,0,0,.5);
}
#qrcode-canvas{ display:block; }
.qr-frame .corner{
  position:absolute; width:22px; height:22px;
  border-color: var(--accent);
  border-style: solid; border-width:0;
}
.qr-frame .corner.tl{ top:-9px; left:-9px; border-top-width:3px; border-left-width:3px; border-top-left-radius:6px; }
.qr-frame .corner.tr{ top:-9px; right:-9px; border-top-width:3px; border-right-width:3px; border-top-right-radius:6px; }
.qr-frame .corner.bl{ bottom:-9px; left:-9px; border-bottom-width:3px; border-left-width:3px; border-bottom-left-radius:6px; }
.qr-frame .corner.br{ bottom:-9px; right:-9px; border-bottom-width:3px; border-right-width:3px; border-bottom-right-radius:6px; }

.scan-line{
  position:absolute; left:16px; right:16px; height:2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  top:16px;
  animation: scan 2.6s ease-in-out infinite;
  opacity:.85;
  filter: drop-shadow(0 0 6px var(--accent));
}
@keyframes scan{
  0%,100%{ top:16px; }
  50%{ top: calc(100% - 18px); }
}

.qr-meta{ margin-top:18px; text-align:center; }
.qr-meta .id{ font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }
.qr-meta .url{ font-size:0.8rem; color: var(--accent); word-break: break-all; margin-top:4px; }

/* ---------- Library list ---------- */
.lib-list{ display:flex; flex-direction:column; gap:10px; margin-top:8px; }
.lib-item{
  display:flex; align-items:center; gap:12px;
  background: var(--bg-soft); border:1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.lib-item .thumb{ width:42px; height:42px; border-radius:7px; object-fit:cover; background:#000; flex-shrink:0; }
.lib-item .info{ flex:1; min-width:0; }
.lib-item .info .name{ font-size:0.84rem; }
.lib-item .info .meta{ font-size:0.7rem; color: var(--text-muted); font-family: var(--font-mono); }
.lib-item .actions{ display:flex; gap:6px; }
.icon-btn{ width:30px; height:30px; display:flex; align-items:center; justify-content:center; border-radius:7px; color: var(--text-muted); }
.icon-btn:hover{ background: var(--surface-strong); color: var(--text); }
.icon-btn svg{ width:15px; height:15px; }

.empty{ text-align:center; padding: 30px 10px; color: var(--text-muted); font-size:0.85rem; }

/* ---------- Toast ---------- */
.toast-wrap{ position: fixed; bottom: 20px; right: 20px; display:flex; flex-direction:column; gap:8px; z-index: 100; }
.toast{
  background: var(--surface-strong); border:1px solid var(--border); backdrop-filter: blur(12px);
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.84rem;
  box-shadow: var(--shadow); animation: rise .2s ease;
}
.toast.success{ border-color: var(--accent); }
.toast.error{ border-color: var(--danger); }
@keyframes rise{ from{ opacity:0; transform: translateY(8px);} to{ opacity:1; transform:none; } }

/* ---------- AR viewer page ---------- */
.ar-body{ background:#000; height:100%; overflow:hidden; }
.ar-stage{ position:fixed; inset:0; }
#ar-video{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
#ar-canvas{ position:absolute; inset:0; width:100%; height:100%; }
.ar-hud{
  position:absolute; top:0; left:0; right:0; padding: 18px;
  display:flex; justify-content:space-between; align-items:flex-start;
  font-family: var(--font-mono); font-size: 0.7rem; color: rgba(255,255,255,0.75);
  pointer-events:none;
}
.ar-status{
  position:absolute; bottom:24px; left:50%; transform: translateX(-50%);
  background: rgba(10,13,18,0.65); backdrop-filter: blur(10px);
  border:1px solid rgba(255,255,255,0.12); border-radius: 999px;
  padding: 10px 18px; font-size: 0.78rem; display:flex; align-items:center; gap:8px;
}
.ar-status .pulse{ width:8px; height:8px; border-radius:50%; background: var(--danger); }
.ar-status.locked .pulse{ background: var(--accent); box-shadow:0 0 8px var(--accent); }
.ar-back{
  position:absolute; top:18px; left:18px; pointer-events:all;
  width:38px; height:38px; border-radius:50%; background: rgba(10,13,18,0.6);
  border:1px solid rgba(255,255,255,0.12); display:flex; align-items:center; justify-content:center;
}
.ar-error{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  flex-direction:column; gap:14px; text-align:center; padding: 30px;
  color: var(--text-muted); font-size: 0.9rem;
}
