/* 
  Unicargo Leitor OCR - Custom Camera Overlay & Animations
  Este arquivo estende o design-system.css para adicionar os comportamentos específicos da câmera e OCR.
*/

.hidden {
  display: none !important;
}

/* --- ÁREA DO FEED DE VÍDEO (CÂMERA) --- */
.camera-controls {
  margin-bottom: 16px;
}

.camera-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background-color: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-top: 10px;
}

#webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- OVERLAY DO SCANNER (MIRA DE ESCANEAMENTO) --- */
.scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(12, 17, 33, 0.4); /* Fundo sutil Night Sky */
}

.scanner-box {
  width: 280px;
  height: 210px;
  border-radius: var(--radius-md);
  position: relative;
  box-shadow: 0 0 0 4000px rgba(12, 17, 33, 0.55); /* Borda escura do Night Sky */
  transition: all 0.3s ease;
  
  /* Gradientes para criar os 4 cantos de câmera (Brackets) */
  background:
    linear-gradient(to right, var(--primary) 4px, transparent 4px) 0 0,
    linear-gradient(to right, var(--primary) 4px, transparent 4px) 0 100%,
    linear-gradient(to left, var(--primary) 4px, transparent 4px) 100% 0,
    linear-gradient(to left, var(--primary) 4px, transparent 4px) 100% 100%,
    linear-gradient(to bottom, var(--primary) 4px, transparent 4px) 0 0,
    linear-gradient(to bottom, var(--primary) 4px, transparent 4px) 100% 0,
    linear-gradient(to top, var(--primary) 4px, transparent 4px) 0 100%,
    linear-gradient(to top, var(--primary) 4px, transparent 4px) 100% 100%;
  background-repeat: no-repeat;
  background-size: 20px 20px;
  
  /* Linha de borda bem sutil ao redor para guiar o usuário */
  outline: 1px solid rgba(255, 255, 255, 0.1);
  outline-offset: -1px;
}

.scanner-laser {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--secondary); /* Verde Avocado */
  box-shadow: 0 0 10px var(--secondary);
  animation: scanning 2.2s infinite ease-in-out; /* Um pouco mais lento para ficar mais suave */
}

.scanner-tip {
  color: #ffffff;
  font-size: 0.8rem;
  margin-top: 16px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  font-weight: 500;
  text-align: center;
}

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

/* --- CONTROLES DE DEPURAÇÃO DO CANVAS --- */
.debug-controls {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.debug-canvas {
  width: 100%;
  max-height: 100px;
  object-fit: contain;
  background-color: #1e293b;
  border-radius: var(--radius-md);
  margin-top: 8px;
  border: 1px solid var(--border);
}

/* --- CARD DE STATUS E SPINNER --- */
.status-card {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  background-color: var(--foreground); /* Fundo escuro do Night Sky */
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  text-align: center;
  box-shadow: var(--shadow-md);
  margin-top: 16px;
}

.status-card p {
  font-size: 0.9rem;
  font-weight: 500;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--secondary); /* Avocado indica loading */
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================
   ESTILOS DO MODO CÂMERA EM TELA CHEIA (PWA MOBILE EXPERIENCE)
   ========================================================== */

/* Trava a rolagem por trás no mobile */
body.camera-mode-active {
  overflow: hidden;
  height: 100vh;
  position: fixed;
  width: 100%;
}

/* Container de Vídeo em Tela Cheia */
body.camera-mode-active .camera-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  border-radius: 0;
  margin: 0;
  box-shadow: none;
}

body.camera-mode-active #webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Mira do Scanner Otimizada para Mobile */
body.camera-mode-active .scanner-box {
  width: 300px;
  height: 150px;
  background-size: 24px 24px; /* Brackets ligeiramente maiores no mobile */
}

/* Botão Fechar Flutuante (X) no Canto Superior Direito */
body.camera-mode-active #btn-stop-camera {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1002;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background-color: rgba(22, 31, 60, 0.8); /* Night Sky 500 */
  backdrop-filter: blur(10px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
}

body.camera-mode-active #btn-stop-camera .btn-text {
  display: none;
}

body.camera-mode-active #btn-stop-camera::before {
  content: "✕";
  font-size: 1.25rem;
  font-weight: bold;
  line-height: 1;
}

/* Barra de Status Flutuante (Com desfoque de fundo) */
body.camera-mode-active .status-card {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  width: 90%;
  max-width: 420px;
  background-color: rgba(22, 31, 60, 0.85); /* Night Sky 500 translúcido */
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-lg);
  color: #ffffff;
}

/* Controles de Contraste / Depuração Flutuantes */
body.camera-mode-active .debug-controls {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  width: 90%;
  max-width: 420px;
  background-color: rgba(20, 28, 55, 0.9); /* Night Sky 600 */
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-lg);
  color: #ffffff;
  margin-top: 0;
}

body.camera-mode-active .debug-controls label,
body.camera-mode-active .debug-controls .slider-container {
  color: rgba(255, 255, 255, 0.9);
}

body.camera-mode-active .debug-canvas {
  max-height: 80px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}


