@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap");

:root {
  --primary-green: #8bc34a;
  --dark-green: #689f38;
  --dark-gray: #424242;
  --light-gray: #f5f5f5;
  --white: #ffffff;
  --card-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Roboto", sans-serif;
  background-color: var(--light-gray);
  color: var(--dark-gray);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

header {
  padding: 1.5rem;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#logo {
  width: 100%;
  max-width: 400px;
  height: auto;
}

.container {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 0 1rem 2rem 1rem;
  width: 100%;
  max-width: 1200px;
}

.panel {
  background-color: var(--white);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.video-section {
  flex-basis: 60%;
}

/* --- NEW VIDEO WRAPPER STYLES --- */
.video-wrapper {
  position: relative;
  width: 640px;
  height: 480px;
  margin: 0 auto;
  background-color: #000;
  border-radius: 8px;
  overflow: hidden; /* Ensures rounded corners clip the video */
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.video-feed, .overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Ensure the canvas is on top for drawing boxes */
.overlay-canvas {
  z-index: 10;
  pointer-events: none; /* Let clicks pass through */
}

#btn {
  padding: 0.8rem 1.5rem;
  margin-top: 1.5rem;
  border: none;
  border-radius: 5px;
  background-color: var(--primary-green);
  color: var(--white);
  font-weight: 700;
  font-size: 1.2em;
  width: 12rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#btn:hover:not(:disabled) {
  background-color: var(--dark-green);
}

#btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

.results-section {
  flex-basis: 40%;
  justify-content: center;
  text-align: center;
}

.results-section h1 {
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

#result {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-green);
  min-height: 50px;
}

#loading {
  width: 40px;
  height: 40px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid var(--primary-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

/* --- QR CODE STYLES --- */
.qr {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#qr {
  width: 350px;  /* Fixed small width */
  height: 350px; /* Fixed small height */
  object-fit: contain; /* Ensures image doesn't stretch */
  background-color: white; 
  padding: 10px;
}

.qr h3 {
  font-size: 1rem;
  margin-top: 10px;
  text-align: center;
  color: #333;
  font-weight: 400;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .container {
    flex-direction: column;
    align-items: center;
  }
  .panel {
    width: 100%;
    max-width: 640px;
  }
  /* Responsive adjustments for mobile video */
  .video-wrapper {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }
}