/* ==================================================================
   JUSTPIXEL SOFTWARE LIBRARY
   IMAGE RESIZER & CROPPER
   ================================================================== */
.jp-image-tool {
  display: grid;
  gap: var(--jp-space-4);
}

/* ==================================================================
   UPLOAD
   ================================================================== */
.jp-image-upload {
  position: relative;
  min-height: 260px;
  display: grid;
  place-items: center;
  border-style: dashed;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.jp-image-upload.is-dragging {
  border-color: var(--jp-primary);
  background: var(--jp-surface-soft);
}

.jp-image-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.jp-image-upload-content {
  display: grid;
  justify-items: center;
  gap: var(--jp-space-3);
  max-width: 520px;
  padding: var(--jp-space-5);
  text-align: center;
}

.jp-image-upload-content h2,
.jp-image-upload-content p {
  margin: 0;
}

.jp-image-upload-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid var(--jp-border);
  border-radius: var(--jp-radius-md);
  background: var(--jp-surface-soft);
  font-size: 1.75rem;
}

/* ==================================================================
   EDITOR LAYOUT
   ================================================================== */
.jp-image-editor {
  display: grid;
  grid-template-columns:
    minmax(0, 1.5fr)
    minmax(300px, 0.8fr);
  gap: var(--jp-space-4);
  align-items: start;
}

.jp-image-editor[hidden] {
  display: none;
}

/* ==================================================================
   IMAGE STAGE
   ================================================================== */
.jp-image-preview-panel {
  min-width: 0;
}

.jp-image-stage-wrap {
  display: flex;
  justify-content: center;
  padding: var(--jp-space-3);
  overflow: hidden;
  border-radius: var(--jp-radius-md);
  background: #111827;
}

.jp-image-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  user-select: none;
  touch-action: none;
}

.jp-image-source {
  display: block;
  max-width: 100%;
  max-height: min(62vh, 650px);
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

/* ==================================================================
   CROP SHADE
   ================================================================== */
.jp-image-crop-shade {
  position: absolute;
  z-index: 1;
  background: rgba(0, 0, 0, 0.56);
  pointer-events: none;
}

/* ==================================================================
   CROP BOX
   ================================================================== */
.jp-image-crop-box {
  position: absolute;
  z-index: 2;
  box-sizing: border-box;
  border: 2px solid #ffffff;
  cursor: move;
  touch-action: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.jp-image-crop-box::before,
.jp-image-crop-box::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.jp-image-crop-box::before {
  inset: 33.333% 0;
  border-top: 1px solid rgba(255, 255, 255, 0.42);
  border-bottom: 1px solid rgba(255, 255, 255, 0.42);
}

.jp-image-crop-box::after {
  inset: 0 33.333%;
  border-left: 1px solid rgba(255, 255, 255, 0.42);
  border-right: 1px solid rgba(255, 255, 255, 0.42);
}

/* ==================================================================
   CROP HANDLES
   ================================================================== */
.jp-image-crop-handle {
  position: absolute;
  z-index: 3;
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--jp-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.jp-image-crop-handle::before {
  content: "";
  position: absolute;
  inset: -12px;
}

.jp-image-crop-handle-nw {
  top: -9px;
  left: -9px;
  cursor: nwse-resize;
}

.jp-image-crop-handle-ne {
  top: -9px;
  right: -9px;
  cursor: nesw-resize;
}

.jp-image-crop-handle-sw {
  bottom: -9px;
  left: -9px;
  cursor: nesw-resize;
}

.jp-image-crop-handle-se {
  right: -9px;
  bottom: -9px;
  cursor: nwse-resize;
}

/* ==================================================================
   SETTINGS
   ================================================================== */
.jp-image-settings {
  display: grid;
  gap: var(--jp-space-4);
}

.jp-image-setting-group {
  display: grid;
  gap: var(--jp-space-2);
}

.jp-image-setting-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--jp-space-3);
}

.jp-image-setting-label {
  color: var(--jp-text);
  font-size: var(--jp-text-sm);
  font-weight: var(--jp-weight-semibold);
}

/* ==================================================================
   RATIO BUTTONS
   ================================================================== */
.jp-image-ratio-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--jp-space-2);
}

.jp-image-ratio-buttons .jp-tool-button {
  padding-inline: var(--jp-space-2);
}

/* ==================================================================
   DIMENSIONS
   ================================================================== */
.jp-image-dimensions {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    auto
    minmax(0, 1fr);
  align-items: end;
  gap: var(--jp-space-2);
}

.jp-image-dimensions label {
  display: grid;
  gap: var(--jp-space-1);
  color: var(--jp-text-soft);
  font-size: var(--jp-text-xs);
}

.jp-image-dimension-separator {
  padding-bottom: 0.7rem;
  color: var(--jp-text-soft);
}

.jp-image-number-field {
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--jp-border);
  border-radius: var(--jp-radius-sm);
  background: var(--jp-surface);
}

.jp-image-number-field input {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  outline: 0;
}

.jp-image-number-field span {
  padding-right: var(--jp-space-3);
  color: var(--jp-text-soft);
  font-size: var(--jp-text-xs);
}

/* ==================================================================
   ASPECT LOCK
   ================================================================== */
.jp-image-lock {
  display: inline-flex;
  align-items: center;
  gap: var(--jp-space-2);
  color: var(--jp-text-soft);
  font-size: var(--jp-text-xs);
  cursor: pointer;
}

/* ==================================================================
   RANGE
   ================================================================== */
.jp-image-settings input[type="range"] {
  width: 100%;
}

/* ==================================================================
   INFORMATION
   ================================================================== */
.jp-image-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--jp-space-2);
}

.jp-image-info-grid > div {
  display: grid;
  gap: var(--jp-space-1);
  min-width: 0;
  padding: var(--jp-space-3);
  border: 1px solid var(--jp-border);
  border-radius: var(--jp-radius-sm);
  background: var(--jp-surface-soft);
}

.jp-image-info-grid span {
  color: var(--jp-text-soft);
  font-size: var(--jp-text-xs);
}

.jp-image-info-grid strong {
  overflow-wrap: anywhere;
  font-family: var(--jp-font-mono);
  font-size: var(--jp-text-sm);
}

/* ==================================================================
   ACTIONS
   ================================================================== */
.jp-image-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--jp-space-2);
}

.jp-image-actions #imageDownloadButton {
  grid-column: 1 / -1;
}

.jp-image-status {
  min-height: 1.4em;
  color: var(--jp-text-soft);
  font-size: var(--jp-text-sm);
}

.jp-image-status.is-error {
  color: var(--jp-danger, #b42318);
}

.jp-image-status.is-success {
  color: var(--jp-success, #067647);
}

/* ==================================================================
   TABLET
   ================================================================== */
@media (max-width: 900px) {
  .jp-image-editor {
    grid-template-columns: 1fr;
  }

  .jp-image-preview-panel,
  .jp-image-settings {
    width: 100%;
  }

  .jp-image-stage-wrap {
    padding: var(--jp-space-2);
  }

  .jp-image-source {
    max-height: 58vh;
  }
}

/* ==================================================================
   MOBILE
   ================================================================== */
@media (max-width: 600px) {
  .jp-image-upload {
    min-height: 220px;
  }

  .jp-image-upload-content {
    padding: var(--jp-space-4) var(--jp-space-2);
  }

  .jp-image-ratio-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .jp-image-info-grid {
    grid-template-columns: 1fr;
  }

  .jp-image-source {
    max-height: 52vh;
  }

  .jp-image-crop-handle {
    width: 20px;
    height: 20px;
  }

  .jp-image-crop-handle-nw {
    top: -10px;
    left: -10px;
  }

  .jp-image-crop-handle-ne {
    top: -10px;
    right: -10px;
  }

  .jp-image-crop-handle-sw {
    bottom: -10px;
    left: -10px;
  }

  .jp-image-crop-handle-se {
    right: -10px;
    bottom: -10px;
  }
}

/* ==================================================================
   SMALL MOBILE
   ================================================================== */
@media (max-width: 400px) {
  .jp-image-dimensions {
    grid-template-columns: 1fr;
  }

  .jp-image-dimension-separator {
    display: none;
  }

  .jp-image-actions {
    grid-template-columns: 1fr;
  }

  .jp-image-actions #imageDownloadButton {
    grid-column: auto;
  }
}
