/* Universal Form Cropper — Single-surface state UI (v3)
   This CSS matches the new shortcode markup (dropzone contains crop/saved UI).
   Replace: /assets/css/ufc-widget.css
*/

.ufc-widget{
  --ufc-radius: 18px;
  --ufc-radius-sm: 14px;

  --ufc-border: rgba(15, 23, 42, .10);
  --ufc-border-2: rgba(15, 23, 42, .16);

  --ufc-text: rgba(15, 23, 42, .92);
  --ufc-muted: rgba(15, 23, 42, .62);

  --ufc-surface: rgba(255,255,255,.72);
  --ufc-surface-2: rgba(248,250,252,.70);

  --ufc-accent: #2563eb;   /* blue-600 */
  --ufc-accent-2: #7c3aed; /* violet-600 */
  --ufc-focus: rgba(37, 99, 235, .35);

  --ufc-shadow: 0 1px 5px rgba(2, 6, 23, .12);
  --ufc-shadow-soft: 0 1px 2px rgba(2, 6, 23, .10);

  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ufc-text);

  background:
    radial-gradient(900px 420px at 18% -10%, rgba(37,99,235,.16), transparent 55%),
    radial-gradient(760px 380px at 110% 0%, rgba(124,58,237,.13), transparent 55%),
    linear-gradient(180deg, var(--ufc-surface), var(--ufc-surface-2));

  border: 1px solid var(--ufc-border);
  border-radius: var(--ufc-radius);
  box-shadow: var(--ufc-shadow);
  padding: 14px;
  max-width: 465px;
  box-sizing: border-box;

  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.ufc-widget *{ box-sizing: border-box; }

.ufc-label{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  font-weight: 800;
  letter-spacing: .2px;
  font-size: 13px;
  margin: 0 0 10px 2px;
  color: var(--ufc-text);
}

/* Status */
.ufc-status{
  margin: 10px 2px 0;
  font-size: 12px;
  color: var(--ufc-muted);
  min-height: 16px;
  display: block;
}

/* ------------------------------------------
   Dropzone surface (single area)
------------------------------------------ */

.ufc-dropzone{
  outline: none;
}

.ufc-dropzone:focus{
  outline: 2px solid var(--ufc-focus);
  outline-offset: 2px;
  border-radius: var(--ufc-radius);
}

/* The actual “surface” */
.ufc-dropzone-inner{
  position: relative;
  border: 1px dashed var(--ufc-border-2);
  background: rgba(255,255,255,.55);
  border-radius: var(--ufc-radius);
  padding: 14px;
  box-shadow: var(--ufc-shadow-soft);
  min-height: 225px; /* enough for crop + controls */
  overflow: hidden;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease, background .12s ease;
}

.ufc-dropzone.is-dragover .ufc-dropzone-inner{
  border-color: rgba(37,99,235,.55);
  background: rgba(37,99,235,.06);
  box-shadow: 0 12px 30px rgba(37,99,235,.12);
  transform: translateY(-1px);
}

/* Center hint in idle */
.ufc-dropzone-hint{
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  padding: 18px;
}

.ufc-dropzone-title{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .2px;
  color: var(--ufc-text);
}

.ufc-dropzone-sub{
  font-size: 12px;
  font-weight: 700;
  opacity: .78;
  color: var(--ufc-muted);
}

/* Native file input:
   - In idle, it covers the surface so click anywhere opens picker.
   - In other states we disable pointer events (so it won’t block drag/zoom). */
.ufc-file-input{
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.ufc-widget[data-state="editing"] .ufc-file-input,
.ufc-widget[data-state="saved"] .ufc-file-input{
  pointer-events: none;
}

/* ------------------------------------------
   Action icons (top-right)
------------------------------------------ */

.ufc-actions{
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  z-index: 5;
}

/* Honor [hidden] attribute */
.ufc-actions [hidden]{ display:none !important; }

.ufc-action{
  /* Hard reset to avoid theme/Elementor button styles leaking in */
  all: unset;

  width: 34px;
  height: 34px;
  box-sizing: border-box;

  -webkit-appearance: none;
  appearance: none;
  font-size: 0;
  line-height: 0;
  border-radius: 999px;
  border: 1px solid rgba(2,6,23,.10);
  background: rgba(255,255,255,.70);
  color: rgba(15,23,42,.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(2,6,23,.10);
  transition: transform .12s ease, filter .12s ease, background .12s ease;
}

.ufc-action:hover{ transform: translateY(-1px); filter: brightness(1.03); }
.ufc-action:active{ transform: translateY(0); filter: brightness(.98); }
.ufc-action:focus{ outline: 2px solid var(--ufc-focus); outline-offset: 2px; }

/* ---------- Icon system (SVG as CSS mask) ----------
   Put the SVG files in: /assets/icons/
   - ufc-trash.svg
   - ufc-edit.svg
*/
.ufc-icon{
  pointer-events: none;
  width: 18px;
  height: 18px;
  display: block;
  background-color: currentColor; /* icon inherits button color */
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-mode: alpha;
  mask-mode: alpha;
}


.ufc-icon-delete{
  -webkit-mask-image: var(--ufc-icon-delete, url("../icons/ufc-trash.svg"));
  mask-image: var(--ufc-icon-delete, url("../icons/ufc-trash.svg"));
}

.ufc-icon-edit{
  -webkit-mask-image: var(--ufc-icon-edit, url("../icons/ufc-edit.svg"));
  mask-image: var(--ufc-icon-edit, url("../icons/ufc-edit.svg"));
}

/* Optional defaults (you can override hover in your own CSS) */
.ufc-action-delete,.ufc-action-edit{color: #000 !important;background: #fff !important;}
.ufc-action-delete:hover,.ufc-action-edit:hover{ color: #ff0000 !important;background: #eee !important;filter: brightness(1.02); }

/* Fallback if mask isn't supported */
@supports not ((-webkit-mask-image: url("")) or (mask-image: url(""))){
  .ufc-icon{ display:none; }
  .ufc-action-delete::before{ content:"×"; font-weight:900; font-size:18px; line-height:1; }
  .ufc-action-edit::before{ content:"✎"; font-weight:900; font-size:16px; line-height:1; }
}


/* ------------------------------------------
   Editing UI (crop + preview + controls)
------------------------------------------ */

.ufc-crop-wrap[hidden],
.ufc-saved-wrap[hidden]{ display:none !important; }

/* When crop wrap is visible, it becomes the main content */
.ufc-crop-wrap{
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 150px;
  grid-template-areas:
    "crop preview"
    "controls controls";
  gap: 12px;
  align-items: start;
  padding-top: 6px;
}

/* Crop box (size is set by JS using cropBoxPx) */
.ufc-crop-box{
  grid-area: crop;
  position: relative;
  overflow: hidden;
  border-radius: var(--ufc-radius-sm);
  border: 1px solid rgba(2,6,23,.10);
  background: rgba(2,6,23,.06);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
  touch-action: none;
}

/* composition grid */
.ufc-crop-box::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    linear-gradient(to right, rgba(2,6,23,.10) 1px, transparent 1px) 33.333% 0/33.333% 100%,
    linear-gradient(to right, rgba(2,6,23,.10) 1px, transparent 1px) 66.666% 0/33.333% 100%,
    linear-gradient(to bottom, rgba(2,6,23,.10) 1px, transparent 1px) 0 33.333%/100% 33.333%,
    linear-gradient(to bottom, rgba(2,6,23,.10) 1px, transparent 1px) 0 66.666%/100% 33.333%;
  opacity: .18;
}

.ufc-crop-img{
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

/* Elementor/theme reset: do NOT constrain the crop image element (prevents tiny/top-left rendering) */
.ufc-widget .ufc-crop-box img.ufc-crop-img{
  max-width: none !important;
  max-height: none !important;
  width: auto !important;
  height: auto !important;
  display: block !important;
}


/* Preview */
.ufc-preview{
  grid-area: preview;
  border-radius: var(--ufc-radius-sm);
  border: 1px solid rgba(2,6,23,.10);
  background: rgba(255,255,255,.55);
  padding: 10px;
}

.ufc-preview-title{
  font-size: 11px;
  letter-spacing: .2px;
  color: var(--ufc-muted);
  margin: 0 0 8px;
  font-weight: 800;
}

.ufc-preview-canvas{
  display:block;
  width: 100%;
  height: auto;
  border-radius: 999px;
  border: 1px solid rgba(2,6,23,.10);
  background: rgba(2,6,23,.06);
}

/* Controls */
.ufc-controls{
  grid-area: controls;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.ufc-zoom-label{
  display:flex;
  align-items:center;
  gap: 10px;
  font-size: 12px;
  color: var(--ufc-muted);
  font-weight: 800;
}

.ufc-zoom{
  width: 220px;
  -webkit-appearance:none;
  appearance:none;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(37,99,235,.75), rgba(124,58,237,.75));
  border: 1px solid rgba(2,6,23,.10);
  box-shadow: inset 0 1px 2px rgba(2,6,23,.15);
  outline:none;
}

.ufc-zoom::-webkit-slider-thumb{
  -webkit-appearance:none;
  appearance:none;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid rgba(2,6,23,.22);
  box-shadow: 0 10px 22px rgba(2,6,23,.18);
  cursor:pointer;
}

.ufc-zoom::-moz-range-thumb{
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid rgba(2,6,23,.22);
  box-shadow: 0 10px 22px rgba(2,6,23,.18);
  cursor:pointer;
}

/* Save button (icon + label) */
.ufc-save-crop{
  border: 1px solid rgba(2,6,23,.10);
  background: linear-gradient(180deg, rgba(37,99,235,.18), rgba(124,58,237,.14));
  color: var(--ufc-text);
  padding: 10px 14px;
  border-radius: 14px;
  cursor:pointer;
  font-weight: 900;
  letter-spacing: .2px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
  box-shadow: 0 10px 22px rgba(37,99,235,.10);
}

.ufc-save-crop:hover{ transform: translateY(-1px); filter: brightness(1.03); }
.ufc-save-crop:active{ transform: translateY(0); filter: brightness(.98); }
.ufc-save-crop:disabled{ opacity:.55; cursor:not-allowed; transform:none; box-shadow:none; }

/* ------------------------------------------
   Saved UI
------------------------------------------ */

.ufc-saved-wrap{
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  z-index: 2;
  padding: 18px;
}

.ufc-saved-thumb{
  width: 180px;
  height: 180px;
  border-radius: var(--ufc-radius-sm);
  border: 1px solid rgba(2,6,23,.10);
  background: rgba(2,6,23,.06);
  box-shadow: 0 16px 30px rgba(2,6,23,.12);
  background-size: cover;
  background-position: center;
}

.ufc-saved-text{
  font-weight: 900;
  letter-spacing: .2px;
  color: var(--ufc-text);
}

/* ------------------------------------------
   State rules (drives the “single-surface” feeling)
------------------------------------------ */

/* Idle: show hint, hide editing/saved content (they also use [hidden] as safety). */
.ufc-widget[data-state="idle"] .ufc-dropzone-hint{ display:flex; }

/* Editing: hide hint */
.ufc-widget[data-state="editing"] .ufc-dropzone-hint{ display:none; }

/* Saved: hide hint */
.ufc-widget[data-state="saved"] .ufc-dropzone-hint{ display:none; }

/* ------------------------------------------
   Responsive
------------------------------------------ */

@media (max-width: 640px){
  .ufc-dropzone-inner{ min-height: 360px; }

  .ufc-crop-wrap{
    grid-template-columns: 1fr;
    grid-template-areas:
      "crop"
      "preview"
      "controls";
  }

  .ufc-preview{
    max-width: 220px;
  }

  .ufc-zoom{ width: 100%; }
  .ufc-controls{ align-items: stretch; }
  .ufc-zoom-label{ justify-content: space-between; width: 100%; }
}

/* Dark mode */
@media (prefers-color-scheme: dark){
  .ufc-widget{
    --ufc-border: rgba(255,255,255,.10);
    --ufc-border-2: rgba(255,255,255,.18);
    --ufc-text: rgba(255,255,255,.92);
    --ufc-muted: rgba(255,255,255,.68);
    --ufc-surface: rgba(11,18,32,.86);
    --ufc-surface-2: rgba(11,18,32,.76);
    --ufc-shadow: 0 28px 70px rgba(0,0,0,.55);
    --ufc-shadow-soft: 0 14px 30px rgba(0,0,0,.40);
  }

  .ufc-dropzone-inner,
  .ufc-preview{
    background: rgba(255,255,255,.04);
  }

  .ufc-action{
    background: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.18);
    color: rgba(255,255,255,.92);
  }

  .ufc-saved-thumb{
    background: rgba(255,255,255,.04);
    border-color: rgba(255,255,255,.18);
  }

  .ufc-save-crop{
    border-color: rgba(255,255,255,.18);
  }
}


/* Ensure the icon buttons never get stretched by theme defaults */
.ufc-widget button.ufc-action{
  min-width: 34px;
  min-height: 34px;
}
