/* Visual ad-spot picker (/slots/new) */

/* This page doesn't load register.css (where optional-field styles are
   normally defined); restyled here to match exactly. */
.form-field__optional {
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
}

.form-field__hint {
  margin: -2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.slot-discount-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.slot-discount-fieldset legend {
  padding: 0;
  margin-bottom: 8px;
}

.slot-discount-choice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--text);
  cursor: pointer;
}

.slot-discount-choice input {
  margin-top: 2px;
}

.slot-discount-editor {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border, #e5e7eb);
}

.slot-discount-note {
  margin-top: 12px;
}

.slot-discount-tiers {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}

.slot-discount-tier {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.slot-discount-tier__caption {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.slot-discount-tier__remove {
  white-space: nowrap;
}

@media (max-width: 420px) {
  .slot-discount-tier {
    grid-template-columns: 1fr;
  }
}

.slot-picker-page {
  padding: 56px 0 90px;
  min-height: calc(100vh - var(--header-h));
}

.slot-picker-title {
  margin: 0 0 32px;
  text-align: center;
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* Step 1 ? URL entry */
.slot-picker-url-card {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px;
  display: grid;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.slot-picker-viewport-label {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.slot-picker-format-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.slot-picker-format-btn {
  padding: 14px 12px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.slot-picker-format-btn:hover {
  border-color: var(--purple);
}

.slot-picker-format-btn.is-active {
  color: #fff;
  background: var(--purple);
  border-color: var(--purple);
}

.slot-picker-format-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.slot-picker-device-target[hidden] {
  display: none;
}

.slot-picker-device-target {
  display: grid;
  gap: 10px;
  margin-bottom: 4px;
}

.slot-picker-viewport-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.slot-picker-viewport-toggle.is-sticky-devices {
  grid-template-columns: 1fr 1fr;
}

.slot-picker-viewport-toggle.is-sticky-devices .slot-picker-viewport-btn--both {
  grid-column: 1 / -1;
}

.slot-picker-viewport-btn {
  padding: 14px 12px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.slot-picker-viewport-btn:hover {
  border-color: var(--purple);
}

.slot-picker-viewport-btn.is-active {
  color: #fff;
  background: var(--purple);
  border-color: var(--purple);
}

.slot-picker-url-input:disabled,
.slot-picker-url-card .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.slot-picker-url-input {
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: var(--bg-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.slot-picker-url-input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.slot-picker-url-input--error,
.slot-picker-url-card .form-field__input--error {
  border-color: #dc2626;
}

.slot-picker-url-card .btn {
  margin-top: 6px;
  width: 100%;
}

.slot-picker-url-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.slot-picker-url-hint--warning {
  color: #dc2626;
  font-weight: 600;
}

/* Step 2/3 ? iframe + confirm panel */
.slot-picker-workspace[hidden] {
  display: none;
}

.slot-picker-workspace {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.slot-picker-frame-col {
  flex: 0 0 70%;
  min-width: 0;
}

/* Informational only ? no zoom detection, no blocking of slot creation. */
.slot-picker-zoom-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
}

.slot-picker-zoom-warning svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: #d97706;
}

.slot-picker-zoom-warning strong {
  font-weight: 700;
}

.slot-picker-frame-label {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.slot-sticky-preview-toggle[hidden] {
  display: none;
}

.slot-sticky-preview-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 10px;
  padding: 3px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.slot-sticky-preview-toggle__btn {
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.slot-sticky-preview-toggle__btn:hover {
  color: var(--text);
}

.slot-sticky-preview-toggle__btn.is-active {
  color: #fff;
  background: var(--purple);
}

.slot-picker-frame-wrap {
  position: relative;
  /* Pre-JS/loading-state fallback — applyPickerScale() (new.js) overrides
     this with the real computed height (900px true viewport * scale,
     floored at this same 500px) once the iframe is shown. */
  min-height: 500px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Sticky configurator: keep the page visible but block free-draw / Smart Snap
   interactions inside the iframe — geometry is synthetic, not drawn. */
.slot-picker-frame-wrap.is-sticky-mode .slot-picker-iframe {
  pointer-events: none;
}

.slot-sticky-preview {
  position: absolute;
  z-index: 4;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  color: #fff;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.92), rgba(91, 33, 182, 0.96));
  border-top: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 -6px 18px rgba(76, 29, 149, 0.28);
  pointer-events: none;
}

.slot-sticky-preview--desktop {
  border-radius: 0;
}

.slot-sticky-preview--mobile {
  border-radius: 0 0 14px 14px;
}

.slot-sticky-preview__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-picker-loading[hidden] {
  display: none;
}

.slot-picker-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

/* True width/height/transform are set inline by applyPickerScale() (new.js)
   ? always a real 1440x900 desktop viewport, visually scaled down to fit
   the wrapper. Positioning it here as absolute/top-left keeps its scaled
   footprint from affecting the wrapper's own layout size (that's driven by
   the JS-set height on .slot-picker-frame-wrap instead). */
.slot-picker-iframe {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  border: 0;
}

.slot-picker-iframe[hidden] {
  display: none;
}

/* Mobile mode ? the iframe renders at true 400x800 size with no transform
   (see applyMobilePreview() in new.js), so instead of the desktop
   top/left-anchored absolute box above, it's centered in the wrap and
   wrapped in a purely decorative "phone frame" border. */
.slot-picker-frame-wrap.is-mobile .slot-picker-iframe {
  position: static;
  border-radius: 22px;
  box-shadow: 0 0 0 8px #1f2430, 0 8px 24px rgba(0, 0, 0, 0.15);
}

.slot-picker-frame-wrap.is-mobile {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
}

/* Existing-placement reference overlays ? read-only, pointer-events: none,
   drawn by new.js over the iframe. Deliberately very low visual weight
   (opacity, thin dashed border, near-transparent fill) so they never read
   as "solid" or obscure the actual website while picking a new spot; the
   in-progress selection rectangle w.js draws inside the iframe stays its
   existing fully-opaque style, so the two are never visually ambiguous. */
.slot-picker-overlay {
  position: absolute;
  box-sizing: border-box;
  opacity: 0.25;
  border: 1.5px dashed var(--purple);
  background: rgba(124, 58, 237, 0.06);
  border-radius: 4px;
  pointer-events: none;
}

.slot-picker-overlap-warning {
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
}

.slot-picker-overlap-warning[hidden] {
  display: none;
}

.slot-picker-panel {
  flex: 0 0 30%;
  position: sticky;
  top: 24px;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.slot-picker-panel__waiting {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.slot-picker-panel__form {
  display: grid;
  gap: 16px;
}

.slot-picker-panel__form[hidden] {
  display: none;
}

.slot-picker-panel__format {
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--purple-dark);
  background: var(--purple-tint);
  border-radius: var(--radius-sm);
}

#pickDifferentBtn {
  width: 100%;
}

/* Error ? script not detected */
.slot-picker-error[hidden] {
  display: none;
}

.slot-picker-error {
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 32px;
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.slot-picker-error__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}

.slot-picker-error__text {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Slot Designer + Smart Snap panel (right column, sections A-G) */

.designer-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.designer-section:last-of-type {
  border-bottom: none;
}

.designer-section__title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.designer-section[hidden] {
  display: none;
}

.designer-sticky-position {
  display: grid;
  gap: 8px;
}

.designer-sticky-position-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font);
  text-align: left;
  background: var(--purple-tint);
  border: 1.5px solid var(--purple);
  border-radius: var(--radius-md);
  cursor: default;
}

.designer-sticky-position-btn__label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.designer-sticky-position-btn__hint {
  font-size: 12px;
  color: var(--text-muted);
}

.designer-size-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.designer-size-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  font-family: var(--font);
  text-align: left;
  background: var(--bg-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.designer-size-btn:hover {
  border-color: var(--purple);
}

.designer-size-btn.is-active {
  background: var(--purple-tint);
  border-color: var(--purple);
}

.designer-size-btn__dim {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.designer-size-btn__label {
  font-size: 11px;
  color: var(--text-muted);
}

.designer-status {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.designer-warning {
  margin: 8px 0 0;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
}

.designer-warning[hidden],
.designer-hint[hidden] {
  display: none;
}

.designer-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.designer-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.designer-mode-btn {
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.designer-mode-btn:hover {
  border-color: var(--purple);
}

.designer-mode-btn.is-active {
  color: #fff;
  background: var(--purple);
  border-color: var(--purple);
}

.smart-snap-list[hidden] {
  display: none;
}

.smart-snap-list {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.smart-snap-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.smart-snap-list__badge {
  flex-shrink: 0;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 999px;
  color: #fff;
}

.smart-snap-list__badge--best {
  background: #059669;
}

.smart-snap-list__badge--good {
  background: #7c3aed;
}

.smart-snap-list__badge--possible {
  background: #9ca3af;
}

.smart-snap-list__reasons {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.designer-field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.designer-locale-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  width: 100%;
  min-width: 0;
}

.locale-combobox {
  position: relative;
  width: 100%;
  min-width: 0;
}

.locale-combobox__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.locale-combobox__trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.locale-combobox__trigger.is-placeholder .locale-combobox__trigger-text {
  color: var(--text-muted);
  font-weight: 400;
}

.locale-combobox__chevron {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-muted);
  flex-shrink: 0;
}

.locale-combobox__panel {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  max-height: min(280px, 50vh);
}

.locale-combobox.is-open .locale-combobox__panel,
.locale-combobox__panel:not([hidden]) {
  display: flex;
}

.locale-combobox__panel[hidden] {
  display: none !important;
}

.locale-combobox__search {
  width: 100%;
  flex-shrink: 0;
}

.locale-combobox__list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 200px;
  min-height: 0;
}

.locale-combobox__option {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  white-space: normal;
  word-break: break-word;
}

.locale-combobox__option:hover,
.locale-combobox__option.is-active {
  background: rgba(124, 58, 237, 0.08);
  color: var(--text);
}

.locale-combobox__option.is-selected {
  background: rgba(124, 58, 237, 0.12);
  font-weight: 700;
}

.locale-combobox__option:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(124, 58, 237, 0.35);
}

.locale-combobox__empty {
  margin: 0;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.locale-combobox.is-open .locale-combobox__trigger {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.designer-field-row--checkbox {
  grid-template-columns: 1fr auto;
}

.designer-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.designer-field-value {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  min-width: 36px;
}

.designer-field-row input[type="color"] {
  width: 40px;
  height: 28px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.designer-field-row input[type="range"] {
  width: 100%;
}

.designer-image-upload {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.designer-actions {
  display: grid;
  gap: 8px;
}

.designer-placed-badge {
  font-size: 13px;
  font-weight: 700;
  color: #059669;
}

.designer-actions[hidden],
#placeBeforeHint[hidden] {
  display: none;
}

/* Smart Snap candidate overlays ? siblings of the iframe (never inside
   it), same positioning convention as .slot-picker-overlay, but
   interactive: pointer-events stay enabled and each one is a real
   <button> so it's keyboard-accessible and clickable without ever
   needing to reach into the cross-origin iframe underneath. */
.smart-snap-overlay {
  position: absolute;
  box-sizing: border-box;
  padding: 0;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.smart-snap-overlay--best {
  border: 2px solid #059669;
  background: rgba(5, 150, 105, 0.12);
}

.smart-snap-overlay--good {
  border: 2px dashed #7c3aed;
  background: rgba(124, 58, 237, 0.1);
}

.smart-snap-overlay--possible {
  border: 2px dotted #9ca3af;
  background: rgba(156, 163, 175, 0.1);
}

.smart-snap-overlay:hover,
.smart-snap-overlay.is-hovered {
  background: rgba(124, 58, 237, 0.25);
}

@media (max-width: 900px) {
  .slot-picker-workspace {
    flex-direction: column;
  }

  .slot-picker-frame-wrap,
  .slot-picker-panel {
    flex: 1 1 auto;
    width: 100%;
  }

  .slot-picker-panel {
    position: static;
  }

  .slot-picker-frame-wrap {
    min-height: 420px;
  }

  .slot-picker-iframe {
    height: 420px;
  }
}
