/* camera_scanner_html — the form's rules, kept here because the Anvil server
 * strips a template <style> body.
 *
 * Every rule is scoped :where(.cs-root), the private class on the form's root.
 * :where() adds no specificity, so which rule wins is unchanged. The root rule
 * itself is absent on purpose: the div this root replaces (Anvil's
 * .anvil-html-templated-panel wrapper) carried no declarations, and these are
 * mounted components rather than screens, so no position/flex/min-height is
 * added either.
 *
 * .cs-scanner-container is a CHILD of the root, not the root, so its rule stays
 * a scoped rule.
 *
 * pxSpin comes from the shared dependency's injected theme. The fade-in is
 * declared here (csFadeIn) because not every host's theme carries pxFadeIn.
 */

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

:where(.cs-root) .cs-scanner-container {
  font-family: var(--px-font);
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 12px auto;
  overflow: hidden;
  border-radius: 8px;
}

:where(.cs-root) .cs-scanner-video {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: cover;
  background: #000;
  border-radius: 8px;
  display: block;
}

@media (max-width: 600px) {
  :where(.cs-root) .cs-scanner-video {
    max-height: 300px;
  }
  :where(.cs-root) .cs-scanner-frame {
    width: 200px;
    height: 200px;
  }
}

:where(.cs-root) .cs-scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

:where(.cs-root) .cs-scanner-frame {
  width: 350px;
  height: 350px;
  border: 2px solid #4CAF50;
  border-radius: 8px;
  position: relative;
}

:where(.cs-root) .cs-scanner-frame::before,
:where(.cs-root) .cs-scanner-frame::after {
  content: '';
  position: absolute;
  width: 30px;
  height: 30px;
  border: 3px solid #4CAF50;
}

:where(.cs-root) .cs-scanner-frame::before {
  top: -3px;
  left: -3px;
  border-right: none;
  border-bottom: none;
}

:where(.cs-root) .cs-scanner-frame::after {
  bottom: -3px;
  right: -3px;
  border-left: none;
  border-top: none;
}

:where(.cs-root) .cs-scanner-status {
  text-align: center;
  padding: 10px;
  margin-top: 10px;
  border-radius: 4px;
  font-weight: 500;
}

:where(.cs-root) .cs-scanner-status.scanning {
  background: var(--px-info-bg);
  color: var(--px-info-text);
}

:where(.cs-root) .cs-scanner-status.success {
  background: var(--px-success-bg);
  color: var(--px-success-text);
}

:where(.cs-root) .cs-scanner-status.error {
  background: var(--px-danger-bg);
  color: var(--px-danger-text);
}

:where(.cs-root) .cs-success-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--px-toast-success-bg) 65%, transparent);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 8px;
  animation: csFadeIn 0.3s ease-in;
}

:where(.cs-root) .cs-scanner-video.cs-cooldown-blur {
  filter: blur(8px);
  transition: filter 0.2s ease;
}

:where(.cs-root) .cs-success-overlay.show {
  display: flex;
}

:where(.cs-root) .cs-success-message {
  text-align: center;
  color: var(--px-toast-success-text);
}

:where(.cs-root) .cs-success-message .icon {
  font-size: 120px;
  margin-bottom: 20px;
}

:where(.cs-root) .cs-success-message .text {
  font-size: 48px;
  font-weight: bold;
}

:where(.cs-root) .cs-failure-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(198, 40, 40, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 8px;
  animation: csFadeIn 0.3s ease-in;
}

:where(.cs-root) .cs-failure-overlay.show {
  display: flex;
}

:where(.cs-root) .cs-failure-message {
  text-align: center;
  color: white;
}

:where(.cs-root) .cs-failure-message .icon {
  font-size: 120px;
  margin-bottom: 20px;
}

:where(.cs-root) .cs-failure-message .text {
  font-size: 48px;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

:where(.cs-root) .cs-processing-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--px-toast-warning-bg);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  border-radius: 8px;
}

:where(.cs-root) .cs-processing-overlay.show {
  display: flex;
}

:where(.cs-root) .cs-processing-message {
  text-align: center;
  color: var(--px-toast-warning-text);
}

:where(.cs-root) .cs-processing-message .spinner {
  width: 60px;
  height: 60px;
  border: 6px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top: 6px solid currentColor;
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: pxSpin 1s linear infinite;
}

:where(.cs-root) .cs-processing-message .text {
  font-size: 36px;
  font-weight: bold;
}
