/* REGAB live patch: Auftrag bearbeiten modal — visual refresh v1 */

.modal-backdrop:has(.project-edit-modal) {
  padding: 12px;
  background: rgba(3, 13, 22, 0.52);
  backdrop-filter: blur(4px);
  overscroll-behavior: contain;
  touch-action: none;
}

.project-edit-modal {
  width: min(1280px, calc(100vw - 24px));
  max-height: min(96vh, 1080px);
  padding: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: var(--detail-text, #25384a);
  background: var(--detail-bg, #fff);
  border: 1px solid var(--detail-border, #dfe7ee);
  border-radius: 18px;
  box-shadow: 0 28px 90px rgba(2, 8, 16, 0.28);
}

.project-edit-modal .modal-head {
  margin: 0;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--detail-border, #e8eef4);
  background: var(--detail-bg, #fff);
}

.project-edit-modal .modal-head .eyebrow {
  display: inline-flex;
  align-items: center;
  margin-bottom: 6px;
  padding: 4px 10px;
  color: var(--detail-accent, #3977ed);
  background: var(--detail-info-bg, #eef5ff);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.project-edit-modal .modal-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.2;
}

.project-edit-modal .modal-head p {
  margin: 0;
  max-width: 62ch;
  color: var(--detail-muted, #6f7f91);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.project-edit-modal .modal-head .icon-button {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--detail-border, #dbe3ea);
  background: var(--detail-bg-soft, #f8fafc);
}

.project-edit-layout {
  counter-reset: regab-edit-section;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px 24px 20px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.project-edit-modal .edit-block {
  margin: 0;
  padding: 16px 18px 18px;
  background: var(--detail-bg-soft, #fbfdff);
  border: 1px solid var(--detail-border, #e2e9f0);
  border-radius: 16px;
  box-shadow: inset 3px 0 0 var(--detail-accent, #3977ed);
}

.project-edit-modal .edit-block h3 {
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--detail-text, #25384a);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.3;
}

.project-edit-modal .edit-block:not(.edit-advanced) h3::before {
  counter-increment: regab-edit-section;
  content: counter(regab-edit-section, decimal-leading-zero);
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--detail-accent, #3977ed);
  background: var(--detail-info-bg, #eaf2ff);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 900;
}

.project-edit-modal .regab-edit-section-hint {
  display: block;
  margin: 0 0 14px 38px;
  color: var(--detail-muted, #738397);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.project-edit-modal .regab-edit-status-note {
  display: block;
  margin-top: 4px;
  color: var(--detail-muted, #718294);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

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

.project-edit-modal .document-form-grid label,
.project-edit-modal .document-form-grid .field {
  display: grid;
  gap: 7px;
  align-content: start;
  color: var(--detail-muted, #4a5b6c);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.project-edit-modal .document-form-grid .field-label {
  color: var(--detail-muted, #4a5b6c);
  font-size: 10px;
  font-weight: 800;
}

.project-edit-modal .document-form-grid input,
.project-edit-modal .document-form-grid select,
.project-edit-modal .document-form-grid textarea {
  width: 100%;
  margin: 0;
  padding: 0 12px;
  color: var(--detail-text, #25384a);
  background: var(--detail-bg, #fff);
  border: 1px solid var(--detail-border, #dbe3ea);
  border-radius: 9px;
  outline: 0;
  font: 12px "DM Sans", system-ui, sans-serif;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.project-edit-modal .document-form-grid input,
.project-edit-modal .document-form-grid select {
  height: 42px;
}

.project-edit-modal .document-form-grid textarea {
  min-height: 96px;
  padding-top: 11px;
  resize: vertical;
}

.project-edit-modal .document-form-grid input:focus,
.project-edit-modal .document-form-grid select:focus,
.project-edit-modal .document-form-grid textarea:focus {
  border-color: var(--detail-accent, #77a3f1);
  box-shadow: 0 0 0 3px rgba(57, 119, 237, 0.14);
}

.project-edit-modal .document-form-grid .span-2 {
  grid-column: 1 / -1;
}

.project-edit-modal .suggest-field {
  position: relative;
  z-index: 1;
}

.project-edit-modal .edit-block:nth-child(3) .suggest-field:focus-within {
  z-index: 4;
}

.project-edit-modal .form-suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  max-height: 240px;
  overflow: auto;
  background: var(--detail-bg, #fff);
  border: 1px solid var(--detail-border, #dbe6f2);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(20, 39, 59, 0.16);
}

.project-edit-modal .form-suggestions button {
  min-height: 42px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  color: var(--detail-text, #24384b);
  background: var(--detail-bg, #fff);
  border: 0;
  border-bottom: 1px solid var(--detail-border, #eef2f5);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.project-edit-modal .form-suggestions button:last-child {
  border-bottom: 0;
}

.project-edit-modal .form-suggestions button:hover,
.project-edit-modal .form-suggestions button.is-active {
  background: var(--detail-info-bg, #eef5ff);
}

.project-edit-modal .edit-advanced {
  box-shadow: inset 3px 0 0 var(--detail-border-strong, #b8c9dc);
}

.project-edit-modal .edit-advanced summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--detail-accent, #3977ed);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
}

.project-edit-modal .edit-advanced summary::-webkit-details-marker {
  display: none;
}

.project-edit-modal .edit-advanced summary::before {
  content: "+";
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--detail-accent, #3977ed);
  background: var(--detail-info-bg, #eaf2ff);
  border-radius: 8px;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.project-edit-modal .edit-advanced[open] summary::before {
  content: "−";
}

.project-edit-modal .edit-advanced .document-form-grid {
  margin-top: 14px;
}

.project-edit-modal .modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 0;
  padding: 14px 24px 18px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  background: color-mix(in srgb, var(--detail-bg, #fff) 88%, transparent);
  border-top: 1px solid var(--detail-border, #e8eef4);
  backdrop-filter: blur(8px);
}

.project-edit-modal .modal-actions .secondary-button,
.project-edit-modal .modal-actions .primary-button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}

.project-edit-modal .modal-actions .primary-button {
  box-shadow: 0 8px 22px rgba(57, 119, 237, 0.22);
}

.project-edit-modal .regab-edit-location-picker {
  margin-top: 4px;
  background: var(--detail-bg, #fff);
  border-color: var(--detail-border, #dbe6f2);
}

.project-edit-modal .regab-edit-location-picker strong {
  color: var(--detail-text, #26384a);
  font-size: 13px;
}

.project-edit-modal .regab-edit-location-picker span {
  color: var(--detail-muted, #738294);
}

.project-edit-modal .location-map {
  width: 100%;
  height: 280px;
  overflow: hidden;
  border: 1px solid var(--detail-border, #dbe5ee);
  border-radius: 12px;
  background: #edf2f7;
}

.project-edit-modal .map-coordinate-choice {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--detail-info-bg, #eef5ff);
  border: 1px solid #c7daf9;
  border-radius: 12px;
}

.project-edit-modal .map-coordinate-choice.is-active {
  background: #edf8f2;
  border-color: #cdebdc;
}

.project-edit-modal .map-coordinate-choice > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.project-edit-modal .map-coordinate-choice strong {
  color: var(--detail-text, #25384a);
  font-size: 12px;
}

.project-edit-modal .map-coordinate-choice span {
  color: var(--detail-muted, #526477);
  font-size: 11px;
  font-weight: 700;
  word-break: break-word;
}

.project-edit-modal .map-coordinate-choice small {
  color: var(--detail-muted, #64748b);
  font-size: 11px;
  line-height: 1.4;
}

.project-edit-modal .map-coordinate-choice > div:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.project-edit-modal .regab-edit-location-status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.project-edit-modal .regab-edit-location-status[data-tone="info"] {
  color: #315f93;
  background: #edf4ff;
  border: 1px solid #cfe0fb;
}

.project-edit-modal .regab-edit-location-status[data-tone="success"] {
  color: #245f49;
  background: #edf8f2;
  border: 1px solid #cdebdc;
}

.project-edit-modal .regab-edit-location-status[data-tone="warn"] {
  color: #8a4b00;
  background: #fff7ed;
  border: 1px solid #f0c27a;
}

.project-edit-modal .regab-edit-location-status[data-tone="error"] {
  color: #9f1239;
  background: #fff1f2;
  border: 1px solid #fecdd3;
}

.project-edit-modal .map-address-suggestion {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #315f4c;
  background: #edf8f2;
  border: 1px solid #cdebdc;
  border-radius: 12px;
}

.project-edit-modal .map-address-suggestion.is-loading {
  background: #edf4ff;
  border-color: #cfe0fb;
  color: #315f93;
}

.project-edit-modal .map-address-suggestion > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.project-edit-modal .map-address-suggestion strong {
  color: #245f49;
  font-size: 12px;
}

.project-edit-modal .map-address-suggestion span {
  color: #517464;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
}

.project-edit-modal .map-address-suggestion small {
  color: #64748b;
  font-size: 11px;
  line-height: 1.4;
}

.project-edit-modal .map-address-suggestion > div:last-child {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Dark mode */
html.theme-dark .modal-backdrop:has(.project-edit-modal),
body.theme-dark .modal-backdrop:has(.project-edit-modal) {
  background: rgba(2, 8, 16, 0.72);
}

html.theme-dark .project-edit-modal,
body.theme-dark .project-edit-modal {
  color: var(--detail-text, #edf6ff);
  background: var(--detail-bg, #10283d);
  border-color: var(--detail-border, #244b70);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

html.theme-dark .project-edit-modal .modal-head,
body.theme-dark .project-edit-modal .modal-head {
  background: var(--detail-bg, #10283d);
  border-bottom-color: var(--detail-border, #244b70);
}

html.theme-dark .project-edit-modal .modal-head .eyebrow,
body.theme-dark .project-edit-modal .modal-head .eyebrow {
  color: #9ec0ff;
  background: rgba(57, 119, 237, 0.16);
}

html.theme-dark .project-edit-modal .modal-head p,
body.theme-dark .project-edit-modal .modal-head p,
html.theme-dark .project-edit-modal .regab-edit-section-hint,
body.theme-dark .project-edit-modal .regab-edit-section-hint {
  color: var(--detail-muted, #a7b8cc);
}

html.theme-dark .project-edit-modal .modal-head .icon-button,
body.theme-dark .project-edit-modal .modal-head .icon-button {
  color: var(--detail-text, #edf6ff);
  background: var(--detail-bg-soft, #0a1c2b);
  border-color: var(--detail-border, #244b70);
}

html.theme-dark .project-edit-modal .edit-block,
body.theme-dark .project-edit-modal .edit-block {
  background: var(--detail-bg-soft, #0c1f31);
  border-color: var(--detail-border, #244b70);
}

html.theme-dark .project-edit-modal .edit-block h3,
body.theme-dark .project-edit-modal .edit-block h3 {
  color: var(--detail-text, #edf6ff);
}

html.theme-dark .project-edit-modal .edit-block:not(.edit-advanced) h3::before,
body.theme-dark .project-edit-modal .edit-block:not(.edit-advanced) h3::before,
html.theme-dark .project-edit-modal .edit-advanced summary::before,
body.theme-dark .project-edit-modal .edit-advanced summary::before {
  color: #9ec0ff;
  background: rgba(57, 119, 237, 0.18);
}

html.theme-dark .project-edit-modal .document-form-grid label,
body.theme-dark .project-edit-modal .document-form-grid label,
html.theme-dark .project-edit-modal .document-form-grid .field-label,
body.theme-dark .project-edit-modal .document-form-grid .field-label {
  color: var(--detail-muted, #a7b8cc);
}

html.theme-dark .project-edit-modal .document-form-grid input,
html.theme-dark .project-edit-modal .document-form-grid select,
html.theme-dark .project-edit-modal .document-form-grid textarea,
body.theme-dark .project-edit-modal .document-form-grid input,
body.theme-dark .project-edit-modal .document-form-grid select,
body.theme-dark .project-edit-modal .document-form-grid textarea {
  color: var(--detail-text, #edf6ff);
  background: var(--detail-bg, #071827);
  border-color: var(--detail-border, #346a9e);
}

html.theme-dark .project-edit-modal .document-form-grid input:focus,
html.theme-dark .project-edit-modal .document-form-grid select:focus,
html.theme-dark .project-edit-modal .document-form-grid textarea:focus,
body.theme-dark .project-edit-modal .document-form-grid input:focus,
body.theme-dark .project-edit-modal .document-form-grid select:focus,
body.theme-dark .project-edit-modal .document-form-grid textarea:focus {
  border-color: #5b95ff;
  box-shadow: 0 0 0 3px rgba(91, 149, 255, 0.18);
}

html.theme-dark .project-edit-modal .form-suggestions,
body.theme-dark .project-edit-modal .form-suggestions {
  background: var(--detail-bg, #10283d);
  border-color: var(--detail-border, #346a9e);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

html.theme-dark .project-edit-modal .form-suggestions button,
body.theme-dark .project-edit-modal .form-suggestions button {
  color: var(--detail-text, #edf6ff);
  background: var(--detail-bg, #10283d);
  border-bottom-color: var(--detail-border, #244b70);
}

html.theme-dark .project-edit-modal .form-suggestions button:hover,
html.theme-dark .project-edit-modal .form-suggestions button.is-active,
body.theme-dark .project-edit-modal .form-suggestions button:hover,
body.theme-dark .project-edit-modal .form-suggestions button.is-active {
  background: rgba(57, 119, 237, 0.14);
}

html.theme-dark .project-edit-modal .edit-advanced summary,
body.theme-dark .project-edit-modal .edit-advanced summary {
  color: #9ec0ff;
}

html.theme-dark .project-edit-modal .modal-actions,
body.theme-dark .project-edit-modal .modal-actions {
  background: color-mix(in srgb, var(--detail-bg, #10283d) 90%, transparent);
  border-top-color: var(--detail-border, #244b70);
}

html.theme-dark .project-edit-modal .regab-edit-location-picker,
body.theme-dark .project-edit-modal .regab-edit-location-picker {
  background: var(--detail-bg-soft, #0c1f31);
  border-color: var(--detail-border, #244b70);
}

html.theme-dark .project-edit-modal .location-map,
body.theme-dark .project-edit-modal .location-map {
  border-color: var(--detail-border, #346a9e);
  background: #071827;
}

html.theme-dark .project-edit-modal .map-coordinate-choice,
body.theme-dark .project-edit-modal .map-coordinate-choice {
  background: rgba(57, 119, 237, 0.12);
  border-color: var(--detail-border, #346a9e);
}

html.theme-dark .project-edit-modal .map-coordinate-choice.is-active,
body.theme-dark .project-edit-modal .map-coordinate-choice.is-active {
  background: rgba(52, 194, 122, 0.12);
  border-color: #2f855a;
}

@media (max-width: 768px) {
  .modal-backdrop:has(.project-edit-modal) {
    padding: 8px;
  }

  .project-edit-modal {
    width: 100%;
    max-height: calc(100vh - 16px);
    border-radius: 14px;
  }

  .project-edit-modal .modal-head,
  .project-edit-layout,
  .project-edit-modal .modal-actions {
    padding-left: 16px;
    padding-right: 16px;
  }

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

  .project-edit-modal .document-form-grid .span-2 {
    grid-column: auto;
  }

  .project-edit-modal .regab-edit-section-hint {
    margin-left: 0;
  }

  .project-edit-modal .modal-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .project-edit-modal .modal-actions .secondary-button,
  .project-edit-modal .modal-actions .primary-button {
    width: 100%;
  }

  .project-edit-modal .map-coordinate-choice {
    flex-direction: column;
    align-items: stretch;
  }

  .project-edit-modal .map-coordinate-choice > div:last-child {
    justify-content: stretch;
  }

  .project-edit-modal .map-coordinate-choice > div:last-child .secondary-button {
    width: 100%;
  }

  .project-edit-modal .map-address-suggestion {
    flex-direction: column;
    align-items: stretch;
  }

  .project-edit-modal .map-address-suggestion > div:last-child .secondary-button {
    width: 100%;
  }
}
