/* ==========================================================================
   AR VIEW STYLES (css/ar-view.css)
   ========================================================================== */

#view-ar {
  overflow: hidden;
}

.ar-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.ar-camera-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.ar-overlay-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding-top: calc(var(--header-height) + max(30px, var(--sat)));
  padding-bottom: calc(var(--nav-height) + max(20px, var(--sab)));
  pointer-events: none;
}

.ar-overlay-ui>* {
  pointer-events: auto;
}

/* Scanner Frame - Área de Enfoque AR */
.scanner-frame {
  position: relative;
  width: 270px;
  height: 270px;
  border-radius: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  margin-top: 30px;
  box-shadow: inset 0 0 40px rgba(107, 201, 217, 0.15);
  border: 1px dashed rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.scanner-corner {
  position: absolute;
  width: 46px;
  height: 46px;
  border: 3.5px solid #6bc9d9;
  filter: drop-shadow(0 0 8px rgba(107, 201, 217, 0.8));
}

.scanner-corner.top-left {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 18px;
}

.scanner-corner.top-right {
  top: 0;
  right: 0;
  border-left: none;
  border-bottom: none;
  border-top-right-radius: 18px;
}

.scanner-corner.bottom-left {
  bottom: 0;
  left: 0;
  border-right: none;
  border-top: none;
  border-bottom-left-radius: 18px;
}

.scanner-corner.bottom-right {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 18px;
}

/* Línea Láser Animada de Escaneo */
.scanner-line {
  position: absolute;
  top: 0;
  left: 5%;
  width: 90%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #6bc9d9, #ffffff, #6bc9d9, transparent);
  box-shadow: 0 0 15px #6bc9d9, 0 0 25px rgba(107, 201, 217, 0.8);
  border-radius: 50%;
  animation: scan-beam 2.4s ease-in-out infinite alternate;
}

@keyframes scan-beam {
  0% {
    top: 6%;
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }

  100% {
    top: 92%;
    opacity: 0.4;
  }
}

/* Indicación de Instrucción con Alto Contraste y Vidrio Glass */
.scanner-hint {
  font-family: var(--font-epilogue);
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  background: rgba(17, 33, 66, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(107, 201, 217, 0.5);
  padding: 10px 18px;
  border-radius: 30px;
  text-align: center;
  position: absolute;
  bottom: -55px;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* AR Actions Bar */
.ar-action-bar {
  margin-bottom: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 40;
}

#btn-capture-kencalo {
  font-family: var(--font-epilogue);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 15px 46px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #182848 0%, #112142 100%);
  color: #FFFFFF;
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 10px 32px rgba(17, 33, 66, 0.45), 0 0 24px rgba(138, 92, 246, 0.35);
  cursor: pointer;
  transform-origin: center;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
  animation: captureBtnPulse 2.4s ease-in-out infinite alternate;
}

#btn-capture-kencalo:hover {
  transform: scale(1.04);
  box-shadow: 0 14px 38px rgba(17, 33, 66, 0.6), 0 0 32px rgba(138, 92, 246, 0.55);
}

#btn-capture-kencalo:active {
  transform: scale(0.96);
}

@keyframes captureBtnPulse {
  0% {
    box-shadow: 0 8px 24px rgba(17, 33, 66, 0.4), 0 0 16px rgba(138, 92, 246, 0.25);
  }
  100% {
    box-shadow: 0 14px 36px rgba(17, 33, 66, 0.6), 0 0 30px rgba(138, 92, 246, 0.55);
  }
}

/* Efectos visuales de destello y partículas de captura */
.capture-flash-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.9) 0%, rgba(220, 235, 255, 0.5) 50%, rgba(138, 92, 246, 0.2) 80%, transparent 100%);
  pointer-events: none;
  z-index: 9999;
  animation: captureFlashAnim 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes captureFlashAnim {
  0% { opacity: 0; transform: scale(0.92); }
  25% { opacity: 1; transform: scale(1.02); }
  100% { opacity: 0; transform: scale(1.08); }
}

.capture-sparkle-particle {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  user-select: none;
  font-family: monospace;
  line-height: 1;
  animation: captureSparkleFly 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes captureSparkleFly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0.1) rotate(var(--rot));
  }
}

.ar-action-bar.hidden,
.ar-action-bar.hidden * {
  opacity: 0;
  display: none !important;
  pointer-events: none !important;
}

/* Dev Simulation Bar (Oculto para usuarios finales) */
.dev-sim-bar {
  display: none !important;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-button);
  margin-bottom: 10px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
}

.dev-sim-bar.dev-active {
  display: flex !important;
}

.dev-label {
  font-size: 0.7rem;
  color: var(--text-dark);
  font-weight: 600;
}

.btn-sim {
  background: rgba(17, 33, 66, 0.08);
  border: 1px solid rgba(17, 33, 66, 0.2);
  color: var(--text-dark);
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: var(--radius-button);
  transition: all 0.2s ease;
}

.btn-sim:active {
  background: var(--accent-3);
  color: var(--text-light);
}

.btn-sim-reset {
  background: rgba(220, 53, 69, 0.12);
  border-color: rgba(220, 53, 69, 0.25);
  color: #c92a2a;
  font-weight: 600;
}

.btn-sim-reset:active {
  background: #c92a2a;
  color: #ffffff;
}

/* Tarjeta de Solicitud de Permiso de Cámara (Exact Figma Glass Effect) */
.ar-permission-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 26px;
  max-width: 360px;
  width: 90%;
  margin: auto;
  gap: 14px;
  --br-x1: 50%;
  --br-x2: 37%;
  --br-x3: 85%;
  --br-x4: 65%;
  --br-y1: 25%;
  --br-y2: 65%;
  --br-y3: 68%;
  --br-y4: 82%;
  border-radius: var(--br-x1) var(--br-x2) var(--br-x3) var(--br-x4) / var(--br-y1) var(--br-y2) var(--br-y3);
  background: var(--primary-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid var(--navy-dark);
  box-shadow:
    0 16px 40px -8px rgba(17, 33, 66, 0.14),
    inset 1px 1px 2px 0 rgba(255, 255, 255, 0.85),
    inset -1px -1px 3px 0 rgba(17, 33, 66, 0.1);
  z-index: 20;
  will-change: transform;
  transform: translateZ(0);
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.4s ease;
}

.ar-permission-card.hidden {
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
  visibility: hidden;
  display: none;
}

.camera-icon-wrapper {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(107, 201, 217, 0.2);
  border: 1px solid rgba(107, 201, 217, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 0 24px rgba(107, 201, 217, 0.25);
}

.ar-permission-card h3 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--accent-2);
  margin: 0;
}

.ar-permission-card p {
  font-size: 0.9rem;
  color: var(--text-dark);
  line-height: 1.45;
  margin: 0;
}

.ar-permission-error {
  font-size: 0.82rem;
  color: #dc3545;
  margin-top: 4px;
}

.scanner-frame.hidden {
  display: none !important;
}