/* ============================================
   Wall Cropper — cropper UI styles.
   Ported from the FR /recadrage/ reference.
   Selectors scoped under .wall-cropper to avoid global collisions.
   Modal namespace renamed .dpi-modal → .app-modal so both the
   DPI warning and the iOS canvas-limit warning share the same CSS.
   ============================================ */

.wall-cropper {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
  font-size: 15px;
  line-height: 1.5;
}

.wall-cropper h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 2.2rem;
  margin: 0 0 .5rem;
  color: var(--color-text);
  letter-spacing: 0.3px;
}
.wall-cropper .subtitle {
  color: var(--color-text-muted);
  margin: 0 0 1.5rem;
  font-size: 1rem;
}
.wall-cropper .intro {
  margin-bottom: 2rem;
  font-size: .95rem;
  color: var(--color-text);
}
.wall-cropper .intro p { margin: 0 0 .6rem; }

.wall-cropper .cropper-note {
  font-size: .85rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-left: 3px solid var(--color-border);
  padding: .5rem .8rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}

.wall-cropper .prefix-row {
  display: flex;
  gap: .7rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.wall-cropper .prefix-row label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.wall-cropper input[type="text"] {
  background: white;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: .55rem .7rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .95rem;
  flex: 1;
  min-width: 200px;
  outline: none;
  transition: border-color 0.15s;
}
.wall-cropper input[type="text"]:focus {
  border-color: var(--color-primary);
}

/* Dropzone */
.wall-cropper .dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2.25rem 1.25rem;
  text-align: center;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--color-surface);
  margin-bottom: 1.5rem;
  user-select: none;
}
.wall-cropper .dropzone:hover,
.wall-cropper .dropzone.dragover {
  border-color: var(--color-primary);
  background: rgba(217, 110, 60, 0.09);
}
.wall-cropper .dropzone p { margin: 0; font-size: .95rem; }

.wall-cropper .link {
  background: none;
  border: none;
  color: var(--color-primary-dark);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
}
.wall-cropper .link:hover { color: var(--color-primary); }

/* Empty state */
.wall-cropper .empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: .9rem;
  padding: 1.5rem 0;
  font-style: italic;
}

/* Image card */
.wall-cropper .card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  margin-bottom: 1.2rem;
  box-shadow: var(--shadow-sm);
}
.wall-cropper .card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .8rem;
  margin-bottom: .9rem;
}
.wall-cropper .card-title {
  flex: 1;
  min-width: 0;
}
.wall-cropper .filename {
  font-weight: 600;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wall-cropper .meta {
  font-size: .8rem;
  color: var(--color-text-muted);
  margin-top: .15rem;
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

.wall-cropper .badge-warn {
  display: inline-block;
  background: var(--color-warning-bg);
  color: #8a5a1a;
  border: 1px solid var(--color-warning-border);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: .72rem;
  font-weight: 600;
}

.wall-cropper .cropper-upscayl-cta {
  margin: -.25rem 0 .9rem;
  font-size: .85rem;
  color: var(--color-text-muted);
  background: var(--color-warning-bg);
  border-left: 3px solid var(--color-warning-border);
  padding: .55rem .8rem;
  border-radius: var(--radius);
}
.wall-cropper .cropper-upscayl-cta a {
  color: var(--color-primary-dark);
  font-weight: 600;
}

/* Remove (×) button */
.wall-cropper .remove-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.wall-cropper .remove-btn:hover {
  color: #b03030;
  border-color: #b03030;
  background: #fdf0f0;
}

/* Preview area */
.wall-cropper .preview-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 100%;
}
.wall-cropper .preview-img {
  display: block;
  max-width: 100%;
}
.wall-cropper .crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.wall-cropper .crop-overlay.active { pointer-events: auto; }
.wall-cropper .crop-overlay .crop-rect-handle { cursor: grab; }
.wall-cropper .crop-overlay.dragging .crop-rect-handle { cursor: grabbing; }

/* Controls (orientation / sizes / manual crop) */
.wall-cropper .controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: .8rem 0 .3rem;
  align-items: center;
}
.wall-cropper .controls-row + .controls-row { margin-top: .3rem; }
.wall-cropper .label-tag {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-muted);
  margin-right: .25rem;
  font-weight: 700;
}

.wall-cropper button.toggle,
.wall-cropper button.size-btn,
.wall-cropper button.orient-btn {
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid #c9c3b5;
  padding: .4rem .75rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.wall-cropper button.size-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  padding: .35rem .6rem;
  min-width: 56px;
}
.wall-cropper button.size-btn .dims {
  font-size: .62rem;
  font-weight: 400;
  opacity: 0.75;
  margin-top: 1px;
  letter-spacing: 0.2px;
}
.wall-cropper button.size-btn.active .dims { opacity: 0.95; }
.wall-cropper button.toggle:hover,
.wall-cropper button.size-btn:hover,
.wall-cropper button.orient-btn:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}
.wall-cropper button.toggle.active,
.wall-cropper button.size-btn.active,
.wall-cropper button.orient-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  font-weight: 600;
}
.wall-cropper button.toggle.active:hover,
.wall-cropper button.size-btn.active:hover,
.wall-cropper button.orient-btn.active:hover {
  background: var(--color-primary-dark);
  color: white;
  border-color: var(--color-primary-dark);
}

.wall-cropper select {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: .4rem .55rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .82rem;
  cursor: pointer;
  outline: none;
}
.wall-cropper select:focus { border-color: var(--color-primary); }
.wall-cropper select:disabled { cursor: not-allowed; }

.wall-cropper button.generate-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: .7rem 1.3rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: .9rem;
  transition: background 0.15s;
  letter-spacing: 0.2px;
}
.wall-cropper button.generate-btn:hover { background: var(--color-primary-dark); }
.wall-cropper button.generate-btn:disabled { opacity: 0.6; cursor: wait; }

.wall-cropper button.download-btn,
.wall-cropper a.download-btn {
  background: transparent;
  color: var(--color-primary-dark);
  border: 1px solid var(--color-primary);
  padding: .3rem .65rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.12s, color 0.12s;
}
.wall-cropper button.download-btn:hover,
.wall-cropper a.download-btn:hover {
  background: var(--color-primary);
  color: white;
}

.wall-cropper button.download-all {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: .8rem;
  transition: background 0.15s;
}
.wall-cropper button.download-all:hover { background: var(--color-primary-dark); }
.wall-cropper button.download-all:disabled { opacity: 0.7; cursor: wait; }

.wall-cropper .results {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
}
.wall-cropper .result-tile {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .55rem;
  text-align: center;
  font-size: .72rem;
}
.wall-cropper .result-tile img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  background: #f0ede5;
  display: block;
  margin: 0 auto .4rem;
}
.wall-cropper .result-label {
  font-weight: 600;
  color: var(--color-text);
  font-size: .8rem;
}
.wall-cropper .result-dims {
  color: var(--color-text-muted);
  font-size: .68rem;
  margin-bottom: .4rem;
}

/* Always-visible "no frame" advice */
.wall-cropper .cropper-advice {
  background: #fef9e7;
  border-left: 3px solid var(--color-warning-border);
  padding: .65rem .9rem;
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--color-text);
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

/* Collapsible "Recommended sizes" */
.wall-cropper .sizes-collapsible {
  margin-bottom: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}
.wall-cropper .sizes-collapsible__toggle {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  color: var(--color-text);
  padding: .8rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.wall-cropper .sizes-collapsible__toggle::after {
  content: '▾';
  font-size: .9rem;
  color: var(--color-text-muted);
  transition: transform .15s;
}
.wall-cropper .sizes-collapsible[data-open="true"] .sizes-collapsible__toggle::after {
  transform: rotate(180deg);
}
.wall-cropper .sizes-collapsible__panel {
  padding: 0 1rem 1rem;
  font-size: .9rem;
  line-height: 1.55;
  border-top: 1px solid var(--color-border);
}
.wall-cropper .sizes-collapsible[data-open="false"] .sizes-collapsible__panel { display: none; }
.wall-cropper .sizes-collapsible__intro { margin: .75rem 0; }
.wall-cropper .sizes-collapsible__table {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .3rem .9rem;
  margin: .5rem 0 1rem;
  font-size: .88rem;
}
.wall-cropper .sizes-collapsible__table div { font-variant-numeric: tabular-nums; }
.wall-cropper .sizes-collapsible__table strong { font-weight: 600; color: var(--color-primary-dark); }
.wall-cropper .sizes-collapsible__tip { margin: .5rem 0; font-size: .88rem; color: var(--color-text); }

/* Per-tile DPI warning badge */
.wall-cropper .dpi-tile-warning {
  display: block;
  margin-top: .35rem;
  font-size: .68rem;
  color: #8a5a1a;
  font-weight: 600;
  line-height: 1.3;
}

/* ============================================
   App-wide modal (DPI warning + iOS warning share this namespace).
   Intentionally NOT scoped under .wall-cropper so it can render
   full-viewport regardless of layout container.
   ============================================ */
.app-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  font-family: var(--font-sans);
}
.app-modal[hidden] { display: none; }
.app-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
}
.app-modal__box {
  position: relative;
  z-index: 1;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  max-height: 90vh;
  overflow-y: auto;
}
.app-modal__title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.35rem;
  margin: 0 0 .75rem;
  color: var(--color-text);
}
.app-modal__body {
  font-size: .95rem;
  line-height: 1.5;
  color: var(--color-text);
}
.app-modal__body p { margin: .5rem 0; }
.app-modal__body a { color: var(--color-primary-dark); font-weight: 600; }
.app-modal__list {
  list-style: none;
  padding: .6rem .9rem;
  margin: .6rem 0;
  background: var(--color-warning-bg);
  border-left: 3px solid var(--color-warning-border);
  border-radius: var(--radius);
  font-size: .9rem;
}
.app-modal__list li { margin: .2rem 0; font-variant-numeric: tabular-nums; }
.app-modal__list li strong { color: var(--color-text); }
.app-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.app-modal__btn {
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.app-modal__btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.app-modal__btn--secondary:hover { border-color: var(--color-text-muted); }
.app-modal__btn--primary {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}
.app-modal__btn--primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}
