/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #000000;
  --surface:   #0a0a0a;
  --surface2:  #1a1a1a;
  --border:    rgba(255,255,255,0.15);
  --accent:    #ffffff;
  --accent2:   #e0e0e0;
  --success:   #4ade80;
  --danger:    #f87171;
  --warn:      #fbbf24;
  --text:      #ffffff;
  --muted:     #888888;
  --font-head: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius:    12px;
  --glow:      0 0 30px rgba(255,255,255,0.1);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(255,255,255,0.02) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 10% 80%, rgba(255,255,255,0.01) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ===== OVERLAYS ===== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.95);
  backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.overlay-card {
  text-align: center;
  padding: 56px 48px;
  border-radius: 24px;
  border: 1px solid var(--border);
  max-width: 420px;
  width: 90%;
  animation: slideUp 0.4s cubic-bezier(0.16,1,0.3,1);
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity:0; }
  to   { transform: translateY(0);    opacity:1; }
}

.overlay-card.denied {
  background: linear-gradient(135deg, #1a0000, #0a0a0a);
  border-color: rgba(255,61,113,0.3);
  box-shadow: 0 0 60px rgba(255,61,113,0.1);
}

.overlay-card.success {
  background: linear-gradient(135deg, #001a00, #0a0a0a);
  border-color: rgba(0,230,118,0.3);
  box-shadow: 0 0 60px rgba(0,230,118,0.1);
}

.overlay-card.already {
  background: linear-gradient(135deg, #1a1500, #0a0a0a);
  border-color: rgba(255,179,0,0.3);
  box-shadow: 0 0 60px rgba(255,179,0,0.1);
}

.denied-icon, .already-icon { font-size: 64px; margin-bottom: 20px; }

.overlay-card h1 { font-family: var(--font-head); font-size: 2rem; color: var(--danger); margin-bottom: 8px; }
.overlay-card h2 { font-family: var(--font-head); font-size: 1.8rem; color: var(--text); margin-top: 20px; }
.overlay-card p { color: var(--muted); margin-top: 10px; line-height: 1.6; }
.overlay-card small { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 14px; line-height: 1.7; }

.ip-display {
  margin-top: 20px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* Success ring */
.success-ring {
  width: 100px; height: 100px;
  border-radius: 50%;
  border: 3px solid var(--success);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  box-shadow: 0 0 30px rgba(0,230,118,0.3);
  animation: pulse-ring 2s ease infinite;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 20px rgba(0,230,118,0.3); }
  50%       { box-shadow: 0 0 50px rgba(0,230,118,0.6); }
}

.check { font-size: 48px; color: var(--success); }

.success-label {
  font-family: var(--font-head);
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--success);
  margin-top: 8px !important;
}

.time-stamp {
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--font-mono);
  padding: 8px 16px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  display: inline-block;
}

/* ===== LAYOUT ===== */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* ===== HEADER ===== */
header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(15,22,35,0.8);
  backdrop-filter: blur(12px);
  position: sticky; top: 0;
  z-index: 100;
}

.logo-mark {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.header-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
}

.tagline {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.admin-link {
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.admin-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(109, 40, 217, 0.4);
}

.date-display {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* ===== MAIN ===== */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px;
  gap: 32px;
  align-items: start;
}

/* ===== CAMERA ===== */
.camera-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.camera-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  box-shadow: var(--glow);
}

.camera-frame video,
.camera-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

canvas { pointer-events: none; }

/* Corner brackets */
.corner {
  position: absolute;
  width: 28px; height: 28px;
  z-index: 10;
  pointer-events: none;
}

.corner.tl { top: 16px; left: 16px; border-top: 2px solid var(--accent); border-left: 2px solid var(--accent); border-radius: 4px 0 0 0; }
.corner.tr { top: 16px; right: 16px; border-top: 2px solid var(--accent); border-right: 2px solid var(--accent); border-radius: 0 4px 0 0; }
.corner.bl { bottom: 16px; left: 16px; border-bottom: 2px solid var(--accent); border-left: 2px solid var(--accent); border-radius: 0 0 0 4px; }
.corner.br { bottom: 16px; right: 16px; border-bottom: 2px solid var(--accent); border-right: 2px solid var(--accent); border-radius: 0 0 4px 0; }

/* Scan line */
.scan-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 12px var(--accent);
  z-index: 9;
  animation: scanAnim 3s ease-in-out infinite;
  opacity: 0.6;
}

@keyframes scanAnim {
  0%   { top: 15%; }
  50%  { top: 80%; }
  100% { top: 15%; }
}

/* Status badge */
.status-badge {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(9,13,20,0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 16px;
  font-size: 0.78rem;
  white-space: nowrap;
  z-index: 20;
  transition: all 0.3s ease;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.3s ease;
}

.status-dot.active  { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: blink 1.2s ease infinite; }
.status-dot.success { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.error   { background: var(--danger);  box-shadow: 0 0 8px var(--danger);  }
.status-dot.warn    { background: var(--warn);    box-shadow: 0 0 8px var(--warn);    }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

.instruction-strip {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* ===== INFO PANEL ===== */
.info-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.info-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.info-value {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 500;
}

.info-value.ok   { color: var(--success); }
.info-value.warn { color: var(--warn); }
.info-value.err  { color: var(--danger); }

/* ===== LOG ===== */
.log-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  flex: 1;
}

.log-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  background: var(--surface2);
}

.log-body {
  padding: 12px;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
}

.log-body::-webkit-scrollbar { width: 4px; }
.log-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.log-entry {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.76rem;
  line-height: 1.5;
  background: rgba(255,255,255,0.03);
  border-left: 2px solid var(--border);
  animation: logIn 0.2s ease;
}

@keyframes logIn { from { opacity:0; transform:translateX(-4px); } to { opacity:1; transform:translateX(0); } }

.log-entry.init    { border-color: var(--muted); }
.log-entry.info    { border-color: var(--accent); color: var(--text); }
.log-entry.success { border-color: var(--success); color: var(--success); }
.log-entry.error   { border-color: var(--danger);  color: var(--danger); }
.log-entry.warn    { border-color: var(--warn);    color: var(--warn); }

.log-time {
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 2px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; padding: 20px; }
  .camera-frame { aspect-ratio: 1/1; }
  .info-row { flex-direction: row; }
  .info-card { flex: 1; flex-direction: column; align-items: flex-start; gap: 4px; }
}

@media (max-width: 500px) {
  header { padding: 14px 20px; }
  main { padding: 14px; gap: 16px; }
  .info-row { flex-direction: column; }
}

/* ===== FOOTER ===== */
.footer {
  position: fixed;
  bottom: 10px;
  right: 20px;
  color: rgba(232, 237, 245, 0.3);
  font-size: 0.75rem;
  font-family: var(--mono);
}

.footer a {
  color: rgba(0, 229, 255, 0.5);
  text-decoration: none;
  transition: color 0.2s;
}

.footer a:hover {
  color: var(--accent);
}
