/*
 * Scoped styling for the /dashboard/embassy-world editor.
 * Every rule is nested under .ew-editor so this file can never leak into
 * the rest of the AdminLTE dashboard (unlike catalog-admin.css, which sets
 * global body/* rules and is only safe on the old, dedicated admin layout).
 *
 * catalog-admin.js generates elements with .admin-field / .admin-repeater /
 * .admin-object / .admin-button / .admin-icon-button / etc. regardless of
 * which page hosts it, so those class names are styled here to match
 * AdminLTE 3 (Bootstrap 4) instead of the old admin's own look.
 */

.ew-editor {
  --ew-border: #dee2e6;
  --ew-muted: #6c757d;
  --ew-text: #212529;
  --ew-primary: #007bff;
  --ew-danger: #dc3545;
  --ew-success: #28a745;
  color: var(--ew-text);
}

.ew-editor .card {
  margin-bottom: 20px;
}

/* Toolbar */
.ew-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--ew-border);
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.ew-public-link {
  font-weight: 600;
  text-decoration: none;
}
.ew-public-link:hover {
  text-decoration: underline;
}

.ew-unsaved {
  position: sticky;
  top: 0;
  z-index: 25;
  background: #fff3cd;
  border: 1px solid #ffeeba;
  color: #856404;
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 14px;
  font-weight: 600;
}

/* Section nav */
.ew-nav {
  display: flex;
  flex-direction: column;
}
.ew-nav__group {
  padding: 14px 14px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ew-muted);
}
.ew-nav__group:first-child {
  padding-top: 12px;
}
.ew-tab {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: #495057;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13.5px;
}
.ew-tab:hover {
  background: #f8f9fa;
}
.ew-tab.is-active {
  background: #e7f1ff;
  border-left-color: var(--ew-primary);
  color: #0056b3;
}
.ew-tab.is-active .ew-tab__label {
  font-weight: 700;
}
.ew-tab__label {
  line-height: 1.3;
}
.ew-tab__hint {
  font-size: 11px;
  color: var(--ew-muted);
  font-weight: 400;
  line-height: 1.3;
}
.ew-tab.is-active .ew-tab__hint {
  color: #4d7fb8;
}

.ew-version-row {
  font-size: 12px;
  color: var(--ew-muted);
  padding: 4px 0;
  border-bottom: 1px dashed var(--ew-border);
}
.ew-version-row:last-child {
  border-bottom: 0;
}

.ew-panel h4 {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 6px;
}
.ew-panel__intro {
  margin: 0 0 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ew-border);
  color: var(--ew-muted);
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 68ch;
}

/* Each top-level field group inside a tab (renderSection() /
   .admin-section-block from catalog-admin.js) becomes its own clearly
   bordered card, so several blocks that share one tab (e.g. "Оплата" or
   the formats builder) never visually blur into each other. */
.ew-editor .admin-section-block {
  border: 1px solid var(--ew-border);
  border-radius: 6px;
  background: #fff;
  padding: 18px 20px 20px;
  margin-bottom: 20px;
}
.ew-editor .admin-section-block:last-child {
  margin-bottom: 0;
}
.ew-editor .admin-section-block > h3 {
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e7f1ff;
  font-size: 14px;
  font-weight: 700;
  color: #0056b3;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* --- Generated field / repeater / object primitives ------------------- */

.ew-editor .admin-field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}
.ew-editor .admin-field > span {
  font-weight: 600;
  font-size: 13px;
  color: var(--ew-text);
}
.ew-editor .admin-field > small {
  color: var(--ew-muted);
  font-size: 12px;
}
.ew-editor .admin-field input,
.ew-editor .admin-field textarea,
.ew-editor .admin-field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  padding: 7px 11px;
  background: #fff;
  color: var(--ew-text);
  font-size: 14px;
}
.ew-editor .admin-field textarea {
  min-height: 100px;
  resize: vertical;
}
.ew-editor .admin-field input:focus,
.ew-editor .admin-field textarea:focus,
.ew-editor .admin-field select:focus {
  outline: 0;
  border-color: #80bdff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}
.ew-editor .admin-field.has-error input,
.ew-editor .admin-field.has-error textarea,
.ew-editor .admin-field.has-error select {
  border-color: var(--ew-danger);
}
.ew-editor .admin-error,
.ew-editor .admin-inline-error {
  color: var(--ew-danger) !important;
  font-size: 12px;
}
.ew-editor .admin-field--boolean {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 18px;
}
.ew-editor .admin-field--boolean input {
  width: 18px;
  height: 18px;
  min-height: 0;
}

.ew-editor .admin-object {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.ew-editor .admin-object > .admin-field--wide,
.ew-editor .admin-object > .admin-repeater,
.ew-editor .admin-object > .admin-object-wrap {
  grid-column: 1 / -1;
}
.ew-editor .admin-object-wrap {
  border: 1px solid var(--ew-border);
  background: #f8f9fa;
  border-radius: 4px;
  padding: 14px;
}
.ew-editor .admin-object-wrap > h4 {
  margin: 0 0 12px;
  font-size: 13.5px;
  font-weight: 700;
  color: #495057;
  border: 0;
  padding: 0;
}

.ew-editor .admin-repeater {
  border: 1px solid var(--ew-border);
  border-radius: 4px;
  background: #f8f9fa;
  padding: 12px;
  margin-bottom: 16px;
}
.ew-editor .admin-repeater__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.ew-editor .admin-repeater__header h4 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 13.5px;
}
.ew-editor .admin-repeater__item {
  background: #fff;
  border: 1px solid var(--ew-border);
  border-radius: 4px;
  margin-top: 8px;
}
.ew-editor .admin-repeater__item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--ew-border);
  padding: 7px 10px;
  background: #fbfbfc;
}
.ew-editor .admin-repeater__item-head strong {
  font-size: 12px;
  color: var(--ew-muted);
  font-weight: 600;
}
.ew-editor .admin-repeater__tools {
  display: flex;
  gap: 4px;
}
.ew-editor .admin-repeater__body {
  padding: 12px;
}
.ew-editor .admin-repeater__empty {
  color: var(--ew-muted);
  font-size: 13px;
  padding: 10px 2px;
}
.ew-editor .admin-repeater__help {
  display: block;
  margin: -4px 0 10px;
  color: var(--ew-muted);
  font-size: 12px;
  line-height: 1.4;
}

.ew-editor .admin-image-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.ew-editor .admin-image-preview img {
  width: 90px;
  height: 58px;
  object-fit: cover;
  border: 1px solid var(--ew-border);
  border-radius: 3px;
  background: #eef0f3;
}
.ew-editor .admin-image-preview code {
  font-size: 11px;
  color: var(--ew-muted);
  overflow-wrap: anywhere;
}

/* Buttons generated by the JS engine (add row / duplicate / delete / etc.) */
.ew-editor .admin-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #ced4da;
  background: #fff;
  color: var(--ew-text);
  border-radius: 4px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.ew-editor .admin-button:hover {
  background: #f8f9fa;
}
.ew-editor .admin-button--primary {
  background: var(--ew-primary);
  border-color: var(--ew-primary);
  color: #fff;
}
.ew-editor .admin-button--primary:hover {
  background: #0069d9;
}
.ew-editor .admin-button--dark {
  background: #343a40;
  border-color: #343a40;
  color: #fff;
}
.ew-editor .admin-button--danger {
  background: var(--ew-danger);
  border-color: var(--ew-danger);
  color: #fff;
}
.ew-editor .admin-button--small {
  padding: 4px 10px;
  font-size: 12px;
}
.ew-editor .admin-icon-button {
  width: 28px;
  height: 28px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  color: #495057;
}
.ew-editor .admin-icon-button:hover {
  background: #f1f3f5;
}
.ew-editor .admin-icon-button--danger {
  color: var(--ew-danger);
}

/* Media / icon upload strips */



.ew-editor .admin-icon-upload,
.ew-editor .admin-media-upload {
  display: grid;
  grid-template-columns: none;
  gap: 12px;
  align-items: end;
  border: 1px solid #bcdcfa;
  background: #f0f7ff;
  border-radius: 4px;
  padding: 14px;
  margin-bottom: 18px;
}
.ew-editor .admin-icon-upload > div:first-child {
  grid-column: 1 / -1;
}
.ew-editor .admin-icon-upload p {
  margin: 4px 0 0;
  color: var(--ew-muted);
  font-size: 13px;
}
.ew-editor .admin-icon-upload .admin-field {
  margin: 0;
}
.ew-editor .admin-location-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* Dedicated single-purpose photo widget embedded directly inside a
   block's own tab (hero image, master-plan, smart-apartment, OG image,
   gallery, district scheme). Green accent marks "this uploads straight
   into this block" so it reads differently from the general-purpose
   media-library uploader on the Gallery tab. */
.ew-editor .admin-media-upload--block {
  border-color: #b7e3c4;
  background: #f2fbf5;
}
.ew-editor .admin-media-upload--block strong {
  color: #1c7a3d;
}
.ew-editor .admin-media-upload--general {
  margin-bottom: 18px;
}

/* "Current photos" gallery shown above every upload widget — what's
   already in this block, each with its own Delete button. */
.ew-editor .admin-photo-block {
  margin-bottom: 18px;
}
.ew-editor .admin-current-photos {
  border: 1px solid var(--ew-border);
  border-radius: 4px;
  background: #fbfbfc;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.ew-editor .admin-current-photos > strong {
  display: block;
  font-size: 12.5px;
  margin-bottom: 10px;
}
.ew-editor .admin-current-photos__empty {
  margin: 0;
  font-size: 13px;
}
.ew-editor .admin-current-photos__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.ew-editor .admin-current-photos figure {
  margin: 0;
  border: 1px solid var(--ew-border);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.ew-editor .admin-current-photos img {
  width: 100%;
  height: 86px;
  object-fit: cover;
  display: block;
}
.ew-editor .admin-current-photos__missing {
  width: 100%;
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f3f5;
  color: var(--ew-muted);
  font-size: 11px;
  text-align: center;
  padding: 4px;
}
.ew-editor .admin-current-photos figcaption {
  font-size: 10px;
  color: var(--ew-muted);
  padding: 4px 6px;
  overflow-wrap: anywhere;
}
.ew-editor .admin-current-photos__position {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e7f1ff;
  color: #0056b3;
  font-weight: 700;
}
.ew-editor .admin-current-photos figure form {
  padding: 0 6px 6px;
}
.ew-editor .admin-current-photos figure .admin-button {
  width: 100%;
  justify-content: center;
}

.ew-editor .admin-media-library {
  margin-bottom: 18px;
}
.ew-editor .admin-media-library header {
  margin-bottom: 8px;
}
.ew-editor .admin-media-library__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.ew-editor .admin-media-library figure {
  margin: 0;
  border: 1px solid var(--ew-border);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.ew-editor .admin-media-library figure form {
  padding: 0 6px 6px;
}
.ew-editor .admin-media-library figure .admin-button {
  width: 100%;
  justify-content: center;
}
.ew-editor .admin-media-library img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  display: block;
}
.ew-editor .admin-media-library figcaption {
  font-size: 10px;
  color: var(--ew-muted);
  padding: 4px 6px;
  overflow-wrap: anywhere;
}

/* Mini catalog search (top/similar properties) */
.ew-editor .admin-catalog-search {
  border: 1px solid #bcdcfa;
  background: #f0f7ff;
  border-radius: 4px;
  padding: 14px;
  margin-bottom: 18px;
}
.ew-editor .admin-catalog-search p {
  margin: 4px 0 0;
  color: var(--ew-muted);
  font-size: 13px;
}
.ew-editor .admin-catalog-search__controls {
  display: grid;
  grid-template-columns: 1fr 210px;
  gap: 10px;
  margin-top: 12px;
}
.ew-editor .admin-catalog-search input,
.ew-editor .admin-catalog-search select {
  min-height: 38px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  padding: 7px 10px;
  background: #fff;
}
.ew-editor .admin-catalog-results {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}
.ew-editor .admin-catalog-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--ew-border);
  border-radius: 4px;
  padding: 9px 10px;
}
.ew-editor .admin-catalog-result small {
  display: block;
  color: var(--ew-muted);
  margin-top: 3px;
}
.ew-editor .admin-catalog-selection {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ew-border);
}
.ew-editor .admin-catalog-selection__items {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}
.ew-editor .admin-catalog-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--ew-border);
  border-radius: 4px;
  background: #fff;
}
.ew-editor .admin-catalog-selected small,
.ew-editor .admin-catalog-selection__empty {
  display: block;
  margin-top: 3px;
  color: var(--ew-muted);
}

@media (max-width: 767px) {
  .ew-editor .admin-object,
  .ew-editor .admin-icon-upload,
  .ew-editor .admin-media-upload,
  .ew-editor .admin-location-upload-grid,
  .ew-editor .admin-catalog-search__controls {
    grid-template-columns: 1fr;
  }
}