/* Shared modal window and form styles. */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.55);
}

body.modal-open {
  overflow: hidden;
}

.modal {
  width: 520px;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.1));
  border-radius: var(--border-radius, 14px);
  background: var(--bg-elevated, #1c1c1e);
  color: var(--text-main, rgba(245, 245, 247, 0.95));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), 0 0 0 0.5px rgba(255, 255, 255, 0.04) inset;
}

.modal-header {
  position: relative;
  padding: 14px 16px 12px;
}

.modal-header::after,
.modal-footer::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  height: 1px;
  background: var(--border-soft, rgba(255, 255, 255, 0.1));
}

.modal-header::after {
  bottom: 0;
}

.modal-title {
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: 0;
}

.modal-subtitle {
  margin-top: 4px;
  color: rgba(161, 161, 170, 0.85);
  font-size: 11px;
  line-height: 1.3;
}

.modal-body {
  min-height: 0;
  padding: 14px 16px;
  overflow-y: auto;
}

.modal-form {
  display: grid;
  gap: 12px;
}

.modal-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.modal-field {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.modal-label {
  letter-spacing: 0;
}

.modal-input.input {
  height: 32px;
}

.inventory-product-kiz-control {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(235, 235, 245, 0.84);
  font-size: 12px;
  cursor: pointer;
}

.modal--photo-select-open {
  overflow: visible;
}

.modal--photo-select-open .modal-body {
  overflow: visible;
}

.inventory-product-main-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: start;
  column-gap: 12px;
}

.inventory-product-name-field {
  min-width: 0;
  gap: 8px;
}

.inventory-product-name-label {
  gap: 4px;
}

.inventory-product-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.brand-select__value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.brand-select__value--placeholder {
  color: rgba(235, 235, 245, 0.58);
}

.brand-select .marketplace-select__button:disabled {
  cursor: default;
  opacity: 0.65;
}

.marketplace-select__item.brand-select__item {
  grid-template-columns: minmax(0, 1fr) 16px;
}

.brand-select__menu {
  min-width: 100%;
  width: max-content;
  max-width: min(320px, calc(100vw - 48px));
}

.photo-select {
  position: relative;
  width: 72px;
}

.photo-select__button {
  position: relative;
  width: 72px;
  height: 88px;
  display: block;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  overflow: hidden;
}

.photo-select__edit-mark {
  position: absolute;
  top: 0px;
  right: 0px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: rgba(245, 245, 247, 0.92);
  background: rgba(28, 28, 30, 0.78);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
  pointer-events: none;
}

.photo-select__edit-mark .ui-icon {
  width: 13px;
  height: 13px;
}

.photo-select__button:hover,
.photo-select__button:focus-visible {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.photo-select__preview {
  width: 100%;
  height: 100%;
  display: block;
  background: rgba(255, 255, 255, 0.08) center / cover no-repeat;
}

.photo-select__preview--empty {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
}

.photo-select__menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 10px);
  left: 0;
  width: min(420px, calc(100vw - 48px));
  max-width: calc(100vw - 48px);
  max-height: 220px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(28, 28, 30, 0.96);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}

.photo-select__item {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 7px 5px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-main, rgba(245, 245, 247, 0.95));
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.photo-select__item:hover,
.photo-select__item[aria-current="true"] {
  background: rgba(255, 255, 255, 0.08);
}

.photo-select__item-img {
  width: 56px;
  height: 72px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08) center / cover no-repeat;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.photo-select__item-img--empty {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
}

.photo-select__item-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: rgba(245, 245, 247, 0.96);
}

.marketplace-select {
  position: relative;
  min-width: 0;
}

.marketplace-select__button {
  appearance: none;
  width: 100%;
  min-width: 0;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 28px 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main, rgba(245, 245, 247, 0.95));
  cursor: pointer;
  position: relative;
}

.marketplace-select__button::after {
  content: "";
  position: absolute;
  right: 8px;
  width: 16px;
  height: 16px;
  background: var(--caret-down);
  background-size: 16px 16px;
}

.marketplace-select--open .marketplace-select__button::after {
  background: var(--caret-up);
  background-size: 16px 16px;
}

.marketplace-select__button:hover,
.marketplace-select__button:focus-visible {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.marketplace-select__value {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.marketplace-select__logos {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.marketplace-select__logo-wrap {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.marketplace-select__logo-wrap--universal {
  color: rgba(245, 245, 247, 0.9);
  font-size: 11px;
  font-weight: 700;
}

.marketplace-select__logo {
  width: 16px;
  height: 16px;
  display: block;
  object-fit: contain;
}

.marketplace-select__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.marketplace-select__menu {
  position: absolute;
  z-index: 11;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 180px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(28, 28, 30, 0.96);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}

.marketplace-select__item {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-main, rgba(245, 245, 247, 0.95));
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.marketplace-select__item:hover,
.marketplace-select__item[aria-current="true"] {
  background: rgba(255, 255, 255, 0.08);
}

.marketplace-select__universal-mark {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(245, 245, 247, 0.9);
  font-size: 11px;
  font-weight: 700;
}

.marketplace-select__item-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.marketplace-select__check::before {
  content: "";
}

.marketplace-select__item[aria-current="true"] .marketplace-select__check::before {
  content: "✓";
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.modal-check {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 8px;
  color: rgba(235, 235, 245, 0.82);
  font-size: 12px;
  cursor: pointer;
}

.modal-error {
  color: var(--danger);
  font-size: 11px;
  line-height: 1.35;
}

.modal-field-hint {
  color: rgba(161, 161, 170, 0.86);
  font-size: 11px;
  line-height: 1.25;
}

.modal-field-hint--error {
  color: var(--danger);
}

.modal-footer {
  position: relative;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
}

.modal-footer::before {
  top: 0;
}

.modal-footer .btn {
  min-width: 90px;
  min-height: 30px;
}

@media (max-width: 560px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 12px;
  }

  .modal {
    max-height: calc(100vh - 24px);
  }

  .modal-form-grid {
    grid-template-columns: 1fr;
  }

  .modal-input.input,
  .marketplace-card-link__search,
  .photo-select__menu input,
  .marketplace-select__menu input {
    font-size: 16px;
  }
}
