/* MOSAP profile photo crop dialog */

.mosap-crop-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: min(92vw, 720px);
  width: min(92vw, 720px);
  max-height: min(92vh, 680px);
  box-shadow: 0 20px 60px rgba(17, 24, 39, 0.25);
  background: #fff;
  color: #1a1a2e;
  z-index: 100050;
}

.mosap-crop-dialog::backdrop {
  background: rgba(26, 26, 46, 0.55);
}

.mosap-crop-dialog__form {
  display: flex;
  flex-direction: column;
  max-width: min(920px, 96vw);
  min-height: 0;
  overflow: hidden;
}

.mosap-crop-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #581c58, #702470);
  color: #fff;
  flex-shrink: 0;
}

.mosap-crop-dialog__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.mosap-crop-dialog__dismiss {
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.mosap-crop-dialog__dismiss:hover,
.mosap-crop-dialog__dismiss:focus {
  background: rgba(255, 255, 255, 0.28);
  outline: none;
}

.mosap-crop-dialog__body {
  display: flex;
  flex-direction: column;
  padding: 10px 16px 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.mosap-crop-dialog__err {
  margin: 0 0 10px;
  flex-shrink: 0;
  font-size: 13px;
  color: #b91c1c;
}

.mosap-crop-dialog__err:not([hidden]) {
  display: block;
}

.mosap-crop-dialog__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 240px;
  max-height: min(62vh, 600px);
  border-radius: 12px;
  overflow: visible;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  background-color: #9a9a9a;
  background-image:
    linear-gradient(45deg, #c4c4c4 25%, transparent 25%),
    linear-gradient(-45deg, #c4c4c4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c4c4c4 75%),
    linear-gradient(-45deg, transparent 75%, #c4c4c4 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-clip: padding-box;
  box-sizing: border-box;
  touch-action: none;
}

.mosap-crop-dialog__img {
  position: relative;
  z-index: 0;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  user-select: none;
  pointer-events: none;
  object-fit: contain;
}

.mosap-crop-dialog__overlay[hidden] {
  display: none !important;
}

.mosap-crop-dialog__overlay {
  position: absolute;
  z-index: 2;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move;
  box-sizing: border-box;
  touch-action: none;
  display: block;
}

.mosap-crop-dialog__handle {
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid #702470;
  position: absolute;
  border-radius: 50%;
  box-sizing: border-box;
  touch-action: none;
  z-index: 3;
}

.mosap-crop-dialog__handle--tl {
  left: 6px;
  top: 6px;
  cursor: nwse-resize;
}

.mosap-crop-dialog__handle--tr {
  right: 6px;
  top: 6px;
  cursor: nesw-resize;
}

.mosap-crop-dialog__handle--bl {
  left: 6px;
  bottom: 6px;
  cursor: nesw-resize;
}

.mosap-crop-dialog__handle--br {
  right: 6px;
  bottom: 6px;
  cursor: nwse-resize;
}

@media (pointer: coarse) {
  .mosap-crop-dialog__handle {
    width: 24px;
    height: 24px;
    border-width: 3px;
  }
  .mosap-crop-dialog__handle--tl { left: 4px; top: 4px; }
  .mosap-crop-dialog__handle--tr { right: 4px; top: 4px; }
  .mosap-crop-dialog__handle--bl { left: 4px; bottom: 4px; }
  .mosap-crop-dialog__handle--br { right: 4px; bottom: 4px; }
}

.mosap-crop-dialog__footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(88, 28, 88, 0.12);
  background: #fafafa;
}

.mosap-crop-dialog__hint {
  flex: 1 1 200px;
  margin: 0;
  font-size: 13px;
  color: #64748b;
  line-height: 1.4;
}

.mosap-crop-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.mosap-crop-dialog__btn {
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}

.mosap-crop-dialog__btn--ghost {
  background: #fff;
  border-color: rgba(88, 28, 88, 0.2);
  color: #581c58;
}

.mosap-crop-dialog__btn--ghost:hover,
.mosap-crop-dialog__btn--ghost:focus {
  border-color: rgba(112, 36, 112, 0.4);
  outline: none;
}

.mosap-crop-dialog__btn--primary {
  background: linear-gradient(135deg, #581c58, #702470);
  color: #fff;
  box-shadow: 0 4px 14px rgba(88, 28, 88, 0.25);
}

.mosap-crop-dialog__btn--primary:hover,
.mosap-crop-dialog__btn--primary:focus {
  outline: none;
  filter: brightness(1.05);
}

/* Shared mobile camera capture (profile + signup) */
.mosap-camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.72);
}
.mosap-camera-overlay.is-open { display: flex; }
.mosap-camera-dialog {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.mosap-camera-head {
  padding: 14px 16px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, rgba(88, 28, 88, 1), rgba(112, 36, 112, 1));
}
.mosap-camera-video-wrap {
  position: relative;
  background: #111;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}
.mosap-camera-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);
}
.mosap-camera-err {
  margin: 0;
  padding: 10px 16px 0;
  color: #b91c1c;
  font-size: 13px;
  min-height: 0;
}
.mosap-camera-err:not(:empty) { min-height: 1.2em; }
.mosap-camera-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fafafa;
}
.mosap-camera-actions button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 900;
  cursor: pointer;
}
.mosap-camera-actions .mosap-camera-cancel {
  background: rgba(88, 28, 88, 0.08);
  color: rgba(88, 28, 88, 1);
}
.mosap-camera-actions .mosap-camera-gallery {
  color: #475569;
  background: rgba(100, 116, 139, 0.1);
  margin-right: auto;
}
.mosap-camera-actions .mosap-camera-snap {
  background: linear-gradient(135deg, rgba(88, 28, 88, 1), rgba(112, 36, 112, 1));
  color: #fff;
}

.mosap-photo-file-input {
  position: fixed !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}
