/* ============================================================
   app.css — Layout vista principal ids.hfranklin.mx
   Layout: header → visor centrado → grid 2x2 → botón registrar
   ============================================================ */

/* ── HEADER ─────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 18px;
}

.header-brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--amber);
}
.main-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Dropdown de villa */
.villa-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}
.villa-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  white-space: nowrap;
}
.select-wrap {
  position: relative;
}
.select-wrap::after {
  content: "▾";
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--amber);
  font-size: 12px;
  pointer-events: none;
}
.villa-select {
  height: 34px;
  min-width: 140px;
  background: oklch(0.24 0.02 255 / 0.85);
  border: 1px solid var(--border-amber);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 0 28px 0 12px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.villa-select:focus { border-color: var(--amber-light); }
.villa-select option { background: #1e1e35; color: var(--text); }

/* Badge "Hab. 115" junto al select */
.hab-badge {
  font-size: 16px;
  font-weight: 800;
  color: var(--amber-light);
  min-width: 32px;
  letter-spacing: -0.02em;
}

/* ── MAIN SCROLL ────────────────────────────────────────── */
/* Ocupa todo el espacio entre header y bottom-bar, con scroll */
.main-scroll {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  bottom: var(--bottom-h);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 14px 16px;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── SECCIÓN VISOR ──────────────────────────────────────── */
.visor-section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  max-width: 560px;
}

/* Layout: [btn-captura fijo] + [visor flexible] en fila */
.visor-layout {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
}

/* Contenedor del video */
.visor-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  /* ratio ISO/IEC 7810: 85.6mm × 53.98mm ≈ 1.586 : 1 */
  aspect-ratio: 1.586 / 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

/* Video llena el contenedor */
.visor-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* SVG overlay ocupa todo el contenedor */
.visor-overlay-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Botón torch — flotante esquina superior derecha del visor */
.btn-torch {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 20;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-torch:active { transform: scale(0.9); }
.btn-torch.torch-on {
  background: oklch(0.66 0.1 58 / 0.4);
  border-color: var(--amber-light);
  box-shadow: 0 0 8px oklch(0.66 0.1 58 / 0.4);
}

/* Flash al disparar */
.flash {
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0s;
  border-radius: var(--radius-md);
}
.flash.activo {
  opacity: 0.7;
  transition: opacity 0.08s ease-out;
}

/* Fallback cuando no hay cámara */
.visor-fallback {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  aspect-ratio: 1.586 / 1;
  background: oklch(0.22 0.02 255 / 0.7);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.visor-fallback span { font-size: 11px; color: var(--text-dim); }

/* ── FILA INFERIOR: contador ──────────── */
.captura-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-top: 10px;
}

/* Contador */
.fotos-contador {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

/* Botón capturar — círculo a la izquierda del visor */
.btn-captura {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  align-self: center;
  border-radius: 50%;
  border: 2px solid var(--amber);
  background: oklch(0.24 0.02 255 / 0.9);
  color: var(--amber);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
  box-shadow: 0 0 0 3px oklch(0.66 0.1 58 / 0.1);
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.btn-captura:hover:not(:disabled) {
  background: oklch(0.66 0.1 58 / 0.15);
}
.btn-captura:active:not(:disabled) {
  transform: scale(0.91);
}
.btn-captura:disabled {
  border-color: oklch(0.35 0.02 255 / 0.5);
  color: oklch(0.38 0.02 255 / 0.6);
  box-shadow: none;
  cursor: not-allowed;
}

/* ── SECCIÓN GRID 2×2 ───────────────────────────────────── */
.fotos-section {
  width: 100%;
  max-width: 560px;
}

.fotos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  /* Altura total del grid = 2 filas de ratio credencial + gap */
  /* Cada celda tiene el mismo ratio que una credencial */
}

/* Slot individual — ratio credencial */
.foto-slot {
  position: relative;
  aspect-ratio: 1.586 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: oklch(0.20 0.02 255 / 0.7);
  transition: border-color 0.15s;
}
.foto-slot.requerida {
  border: 1px solid oklch(0.66 0.08 58 / 0.45);
}
.foto-slot.opcional {
  border: 1px dashed oklch(0.45 0.02 255 / 0.5);
}
.foto-slot-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  text-align: center;
  padding: 6px;
  pointer-events: none;
  user-select: none;
}
.foto-slot.requerida .foto-slot-label {
  color: oklch(0.66 0.08 58 / 0.7);
}
.foto-preview {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.btn-eliminar-foto {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  font-size: 11px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.btn-eliminar-foto:hover { background: rgba(180,40,40,0.8); }

/* ── BOTTOM BAR ────────────────────────────────────────── */
.bottom-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-h);
  padding: 10px 14px;
  background: oklch(0.17 0.015 255 / 0.96);
  border-top: 1px solid var(--border-amber);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.btn-registrar {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: var(--radius-md);
  background: var(--amber);
  color: #1a120a;
  font-size: 15px;
  font-weight: 800;
  font-family: inherit;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 14px oklch(0.66 0.1 58 / 0.3);
  -webkit-tap-highlight-color: transparent;
}
.btn-registrar:hover:not(:disabled) { background: var(--amber-light); }
.btn-registrar:active:not(:disabled) { transform: scale(0.995); }
.btn-registrar:disabled {
  background: oklch(0.26 0.02 255 / 0.7);
  color: var(--text-dim);
  box-shadow: none;
  cursor: not-allowed;
}

/* ── MENSAJE DE ERROR (envío fallido) ───────────────────── */
#error-envio {
  position: fixed;
  bottom: calc(var(--bottom-h) + 8px);
  left: 14px; right: 14px;
  z-index: 200;
}
