/* Driver Solution — Captura de documento desde la cámara
   Modal a pantalla completa con guías de encuadre + paso de revisión.
   Se usa desde driver-lex.html y driver-docs.html. */

.dc-modal {
  position: fixed;
  inset: 0;
  margin: 0;
  /* 100% (no 100vw): 100vw incluye el ancho de la barra de scroll y desbordaba
     ~15px provocando scroll horizontal en móvil. `inset:0` ya fija el tamaño al
     viewport del modal fixed. */
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  padding: 0;
  border: 0;
  background: #000;
  color: #fff;
  z-index: 11000;
}

.dc-modal::backdrop {
  background: #000;
}

.dc-modal[hidden] {
  display: none;
}

.dc-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.dc-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* Imagen congelada que se revisa antes de aceptar. `contain` para verla entera. */
.dc-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.dc-preview[hidden] { display: none; }
.dc-video[hidden] { display: none; }

.dc-canvas {
  display: none;
}

/* Destello blanco al disparar (feedback de captura) */
.dc-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

/* Marco de encuadre centrado, proporción documento A4 vertical (1 : 1.41).
   En orientación landscape se invierte vía media query. */
.dc-guides {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.dc-guides[hidden] { display: none; }

.dc-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(84vw, 50vh);
  aspect-ratio: 1 / 1.414;
  border: 2px dashed rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

@media (orientation: landscape) {
  .dc-frame {
    width: min(72vw, 74vh);
    aspect-ratio: 1.414 / 1;
  }
}

/* Esquinas reforzadas estilo cámara profesional */
.dc-corner {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 4px solid #38bdf8;
}
.dc-corner--tl { top: -2px; left: -2px; border-right: none; border-bottom: none; border-top-left-radius: 10px; }
.dc-corner--tr { top: -2px; right: -2px; border-left: none; border-bottom: none; border-top-right-radius: 10px; }
.dc-corner--bl { bottom: -2px; left: -2px; border-right: none; border-top: none; border-bottom-left-radius: 10px; }
.dc-corner--br { bottom: -2px; right: -2px; border-left: none; border-top: none; border-bottom-right-radius: 10px; }

/* Barra superior: pista de ayuda + linterna. Vive en la zona oscura de arriba,
   sin solaparse con el marco. */
.dc-topbar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}

.dc-hint {
  margin: 0;
  padding: 9px 15px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 14px;
  max-width: min(80vw, 420px);
}
.dc-hint[hidden] { display: none; }

/* Botón circular (linterna) */
.dc-iconbtn {
  pointer-events: auto;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.dc-iconbtn[hidden] { display: none; }
.dc-iconbtn .ds-ico { width: 22px; height: 22px; stroke: currentColor; }
.dc-iconbtn:hover,
.dc-iconbtn:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.7);
}
.dc-iconbtn.is-on {
  background: #fbbf24;
  border-color: #fbbf24;
  color: #1a1500;
}
.dc-iconbtn.is-on .ds-ico { fill: currentColor; }

/* Contador de páginas capturadas */
.dc-pagecount {
  position: absolute;
  left: 50%;
  bottom: calc(104px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: rgba(56, 189, 248, 0.92);
  color: #04263a;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.dc-pagecount[hidden] { display: none; }

.dc-error {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 18px 22px;
  font-size: 0.95rem;
  text-align: center;
  background: rgba(220, 38, 38, 0.92);
  border-radius: 12px;
  max-width: 86vw;
  line-height: 1.45;
}
.dc-error[hidden] { display: none; }

.dc-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
}
.dc-actions[hidden] { display: none; }
.dc-actions--review { flex-wrap: wrap; }

/* Sobreescribe `.ds-btn--ghost` para que sea legible sobre el fondo negro del modal */
.dc-modal .ds-btn--ghost {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.45);
  background: transparent;
}
.dc-modal .ds-btn--ghost:hover,
.dc-modal .ds-btn--ghost:focus-visible {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.7);
}
.dc-modal .ds-btn--ghost .ds-ico {
  stroke: #ffffff;
}

.dc-shutter {
  /* Variante grande del primario para el botón "Capturar"/"Usar" */
  min-width: 168px;
}

@media (max-width: 480px) {
  .dc-actions {
    gap: 10px;
  }
  .dc-actions--review {
    gap: 8px;
  }
  .dc-shutter {
    min-width: 124px;
  }
  .dc-actions--review .ds-btn {
    flex: 1 1 auto;
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
  }
}
