/* =========================================================
   NEW ITEM / NEW LEAD MODAL SCROLL FIX
   Paste near the BOTTOM of new_lead_form.css
   ========================================================= */

/* Full-screen modal overlay */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transform: none !important;
}

.modal.hidden {
  display: none !important;
}

.modal:not(.hidden) {
  display: flex;
}

/* Default modal content */
.modal-content {
  background: whitesmoke;
  width: min(75vw, 1050px);
  max-width: 95vw;
  max-height: 90vh;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
  position: relative;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
}

/* New item modal shell */
#newLeadModal .modal-content {
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
  padding: 0;
}

/* Modal title stays visible */
#newLeadModal .modal-content h2 {
  flex: 0 0 auto;
  margin: 0;
  padding: 28px 56px 18px 24px;
  text-align: center;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
}

/* Close button stays fixed inside the modal */
#newLeadModal #closeLeadModal {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
}

/* This is the actual scrollable area */
#newLeadFormContainer {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  padding: 0 24px 28px 24px;
  box-sizing: border-box;
  scrollbar-gutter: stable;
}

/* Make the form use normal flow inside the scroll area */
#gsCreateRecordForm {
  display: grid;
  gap: 12px;
  padding-bottom: 90px;
}

/* Keep the Create/Cancel buttons visible at the bottom of the modal */
#gsCreateRecordForm > div:last-child {
  position: sticky;
  bottom: 0;
  z-index: 15;
  background: whitesmoke;
  padding: 14px 0 4px;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
}

/* Do NOT let form wrappers break the modal scrolling */
#newLeadModal .modal-content,
#newLeadFormContainer,
#gsCreateRecordForm {
  overscroll-behavior: contain;
}

/* Mapbox field should fit inside the modal scroll area */
.gs-mapbox-address-host {
  width: 100%;
  position: relative;
  z-index: 30;
}

.gs-mapbox-address-host .mapboxgl-ctrl-geocoder {
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
}

.gs-mapbox-address-host .mapboxgl-ctrl-geocoder input[type="text"] {
  height: 42px;
  padding: 10px 44px 10px 48px !important;
  font-size: 14px;
  border-radius: 10px;
  color: #111827;
  box-sizing: border-box;
}

.gs-mapbox-address-host .mapboxgl-ctrl-geocoder--icon-search {
  top: 11px;
  left: 16px;
  width: 18px;
  height: 18px;
}

/* Mapbox suggestions should appear above fields but not disable modal scroll */
.gs-mapbox-address-host .suggestions-wrapper,
.gs-mapbox-address-host .suggestions {
  z-index: 999999 !important;
}

/* Mobile */
@media (max-width: 700px) {
  .modal {
    align-items: stretch;
    padding: 10px;
    box-sizing: border-box;
  }

  #newLeadModal .modal-content {
    width: 100%;
    height: calc(100vh - 20px);
    max-height: calc(100vh - 20px);
  }

  #newLeadModal .modal-content h2 {
    padding: 24px 52px 16px 16px;
    font-size: 30px;
  }

  #newLeadFormContainer {
    padding: 0 16px 24px 16px;
  }
}

.file-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.clear-file-btn {
  background: transparent;
  border: none;
  color: red;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  margin-left: -4px;
}

.clear-file-btn:hover {
  color: darkred;
}

/* =========================================================
   Assigned User Picker
   ========================================================= */

.gs-assigned-picker {
  width: 100%;
  display: grid;
  gap: 10px;
}

.gs-assigned-picker-status {
  font-size: 13px;
  font-weight: 700;
  color: #4b5563;
}

.gs-assigned-user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.gs-assigned-user-card {
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #ffffff;
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: 38px 1fr 24px;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.gs-assigned-user-card:hover {
  border-color: #ff6642;
  background: rgba(255, 102, 66, 0.06);
}

.gs-assigned-user-card.selected {
  border-color: #ff6642;
  background: rgba(255, 102, 66, 0.12);
}

.gs-assigned-picker-avatar {
  flex: 0 0 auto;
}

.gs-assigned-user-info {
  min-width: 0;
}

.gs-assigned-user-name {
  font-size: 14px;
  font-weight: 800;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-assigned-user-role {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
}

.gs-assigned-user-check {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ff6642;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  opacity: 0;
}

.gs-assigned-user-card.selected .gs-assigned-user-check {
  opacity: 1;
}