.image-source-picker,
.image-source-picker * {
  box-sizing: border-box;
}

.image-source-picker {
  width: 100%;
  min-width: 0;
}

.image-source-picker > input[type="hidden"],
.image-source-upload-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.image-source-summary {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 1px solid #cddbd4;
  border-radius: 10px;
  background: #fff;
}

.image-source-preview {
  display: grid;
  width: 112px;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid #dce5e1;
  border-radius: 8px;
  background: #f3f6f4;
  color: #7d9188;
  font-size: 28px;
}

.image-source-preview img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
  background: #fff;
}

.image-source-preview img[hidden] {
  display: none !important;
}

.image-source-summary-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

.image-source-eyebrow {
  color: #60766d;
  font-size: 11px;
  font-weight: 700;
}

.image-source-summary-copy > strong,
.image-source-summary-copy > small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-source-summary-copy > strong {
  margin-top: 3px;
  color: #1d2d27;
  font-size: 14px;
}

.image-source-summary-copy > small {
  margin-top: 3px;
  color: #71827b;
  font-size: 11px;
  font-weight: 400;
}

.image-source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.image-source-picker button.image-source-action,
.image-source-picker button.image-library-close {
  appearance: none;
  min-width: 0;
  min-height: 34px;
  margin: 0;
  border: 1px solid #c7d5cf;
  border-radius: 7px;
  background: #fff;
  color: #234139;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}

.image-source-picker button.image-source-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  white-space: nowrap;
}

.image-source-picker button.image-source-action:hover:not(:disabled) {
  border-color: #78a995;
  background: #f5faf7;
}

.image-source-picker button.image-source-action--primary {
  border-color: #096c50;
  background: #096c50;
  color: #fff;
}

.image-source-picker button.image-source-action--primary:hover:not(:disabled) {
  border-color: #075b43;
  background: #075b43;
}

.image-source-picker button.image-source-action:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.image-source-action b {
  display: grid;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  place-items: center;
  border-radius: 9px;
  background: #e4eee9;
  color: #365b4d;
  font-size: 9px;
}

.product-identity-form-grid {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
}

.image-source-picker--product .image-source-summary {
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
}

.image-source-picker--product .image-source-preview {
  width: 96px;
}

.image-source-picker--product .image-source-summary .image-source-actions {
  display: grid;
  width: 100%;
}

.image-source-picker--product .image-source-summary .image-source-action {
  width: 100%;
}

.image-library-overlay[hidden] {
  display: none !important;
}

.image-library-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  padding: 24px;
  place-items: center;
}

.image-library-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(12, 30, 23, .58);
  cursor: default;
}

.image-library-dialog {
  position: relative;
  display: grid;
  width: min(920px, calc(100vw - 32px));
  height: min(720px, calc(100dvh - 32px));
  min-width: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(25, 57, 45, .1);
  border-radius: 12px;
  background: #f6f8f7;
  box-shadow: 0 28px 90px rgba(7, 35, 26, .28);
}

.image-library-header {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px 15px;
  border-bottom: 1px solid #dce5e1;
  background: #fff;
}

.image-library-header > div {
  min-width: 0;
}

.image-library-header span,
.image-library-header h3,
.image-library-header p {
  margin: 0;
}

.image-library-header span {
  color: #517065;
  font-size: 10px;
  font-weight: 700;
}

.image-library-header h3 {
  margin-top: 2px;
  color: #162820;
  font-size: 18px;
}

.image-library-header p {
  margin-top: 4px;
  color: #6b7c75;
  font-size: 11px;
}

.image-source-picker button.image-library-close {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  font-size: 16px;
}

.image-library-tools {
  display: grid;
  grid-template-columns:minmax(220px, 1fr) 220px auto;
  gap: 10px;
  align-items: end;
  padding: 12px 20px;
  border-bottom: 1px solid #dce5e1;
  background: #fbfcfb;
}

.image-library-search {
  position: relative;
  display: block;
}

.image-library-search i {
  position: absolute;
  left: 11px;
  top: 50%;
  color: #71847b;
  transform: translateY(-50%);
}

.image-source-picker .image-library-search input,
.image-source-picker .image-library-filter select {
  width: 100%;
  min-height: 38px;
  margin: 0;
  border: 1px solid #cbd8d2;
  border-radius: 7px;
  background: #fff;
  color: #263a32;
  font: inherit;
  font-size: 12px;
}

.image-source-picker .image-library-search input {
  padding: 8px 11px 8px 34px;
}

.image-library-filter {
  display: grid;
  gap: 4px;
}

.image-library-filter span {
  color: #64766e;
  font-size: 9px;
  font-weight: 700;
}

.image-source-picker .image-library-filter select {
  padding: 7px 30px 7px 10px;
}

.image-library-count {
  padding-bottom: 10px;
  color: #667a71;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.image-library-body {
  min-height: 0;
  overflow: auto;
  padding: 16px 20px 20px;
}

.image-library-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.image-source-picker button.image-library-card {
  appearance: none;
  display: grid;
  min-width: 0;
  margin: 0;
  padding: 7px;
  border: 1px solid #d5e0db;
  border-radius: 9px;
  background: #fff;
  color: #1c3028;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
  height: auto !important;
}

.image-source-picker button.image-library-card:hover {
  border-color: #8eb8a8;
}

.image-source-picker button.image-library-card.is-selected {
  border-color: #087553;
  background: #f2faf6;
  box-shadow: 0 0 0 2px rgba(8, 117, 83, .13);
}

.image-library-card-preview {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: #edf2ef;
}

.image-library-card-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.image-library-card-preview i {
  position: absolute;
  right: 7px;
  top: 7px;
  color: #087553;
  font-size: 18px;
  opacity: 0;
  filter: drop-shadow(0 1px 2px rgba(255, 255, 255, .9));
}

.image-library-card.is-selected .image-library-card-preview i {
  opacity: 1;
}

.image-library-card-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
  padding: 8px 2px 2px;
}

.image-library-card-copy strong,
.image-library-card-copy small,
.image-library-card-copy em {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-library-card-copy strong {
  font-size: 11px;
}

.image-library-card-copy small {
  color: #66766f;
  font-size: 10px;
  font-weight: 400;
}

.image-library-card-copy em {
  color: #819087;
  font-size: 9px;
  font-style: normal;
}

.image-library-empty {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  gap: 5px;
  color: #6f8078;
  text-align: center;
}

.image-library-empty[hidden] {
  display: none !important;
}

.image-library-empty i {
  font-size: 28px;
}

.image-library-empty strong {
  font-size: 13px;
}

.image-library-empty span {
  font-size: 11px;
}

.image-library-footer {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-top: 1px solid #dce5e1;
  background: #fff;
}

.image-library-footer > span {
  min-width: 0;
  overflow: hidden;
  color: #61756c;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-library-footer > div {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  min-width: max-content;
}

.image-library-footer [data-image-library-cancel] {
  flex: 0 0 auto;
  min-width: 82px;
}

.image-library-footer [data-image-library-confirm] {
  flex: 0 0 auto;
  width: auto !important;
  min-width: 156px !important;
  padding-inline: 16px !important;
  font-size: 12px !important;
}

.image-library-open {
  overflow: hidden;
}

@media (max-width: 760px) {
  .product-identity-form-grid {
    grid-template-columns: 1fr;
  }
  .image-library-overlay {
    padding: 0;
  }
  .image-library-dialog {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }
  .image-library-tools {
    grid-template-columns: minmax(0, 1fr) 160px;
  }
  .image-library-count {
    display: none;
  }
  .image-library-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 540px) {
  .image-source-summary,
  .image-source-picker--product .image-source-summary {
    grid-template-columns: 82px minmax(0, 1fr);
  }
  .image-source-preview,
  .image-source-picker--product .image-source-preview {
    width: 82px;
  }
  .image-source-actions {
    display: grid;
    width: 100%;
  }
  .image-source-picker .image-source-action {
    width: 100%;
  }
  .image-library-header p {
    display: none;
  }
  .image-library-tools {
    grid-template-columns: 1fr;
  }
  .image-library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .image-library-filter span {
    display: none;
  }
  .image-library-footer {
    align-items: stretch;
    flex-direction: column;
  }
  .image-library-footer > div,
  .image-library-footer .image-source-action {
    width: 100%;
  }
  .image-library-footer [data-image-library-confirm] {
    width: 100% !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-source-picker * {
    scroll-behavior: auto !important;
  }
}
