/* ============================================================
   SHARED BACKDROP & LAYOUT
   ============================================================ */

/* Force hide TranslatePress standard dropdown overlays and ALD Automatic Language Detection popups */
.trp-switcher-dropdown-list,
[id^="trp-shortcode-dropdown"],
.trp-language-switcher .trp-dropdown,
.trp-language-switcher ul:not(#nlm-grid),
.mobile-header-lang-dropdown,
.niigma-desktop-lang-dropdown,
#trp_ald_modal_container,
#trp_ald_modal_popup,
.trp_ald_popup_container,
#trp_ald_container,
.trp-ald-popup-container {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.trp-shortcode-overlay,
.trp-shortcode-switcher,
.trp-current-language-item__wrapper,
.trp-language-item__current,
.mobile-header-lang-trigger,
.niigma-desktop-lang-trigger {
  cursor: pointer !important;
}

/* Unified Top-Right Close Button Across ALL Modal Popups */
#trp_ald_modal_popup .trp-ald-popup-close-tr,
#trp_ald_modal_popup #trp_ald_popup_close_tr,
#nlm-modal-container .nlm-btn-close,
#nlm-modal-container button.nlm-btn-close,
#nlm-mobile-sheet .nlm-sheet-close,
#nlm-mobile-sheet button.nlm-sheet-close,
#pbm-modal .pbm-modal-close,
#pbm-modal button.pbm-modal-close {
  position: absolute !important;
  top: 16px !important;
  right: 18px !important;
  font-size: 28px !important;
  line-height: 1 !important;
  font-weight: 300 !important;
  color: #9ca3af !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-radius: 0 !important;
  transform: none !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  cursor: pointer !important;
  z-index: 100000 !important;
  transition: color 0.15s ease !important;
  width: 32px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  padding: 0 !important;
  margin: 0 !important;
  text-decoration: none !important;
}

#trp_ald_modal_popup .trp-ald-popup-close-tr:hover,
#trp_ald_popup_close_tr:hover,
#nlm-modal-container .nlm-btn-close:hover,
#nlm-modal-container button.nlm-btn-close:hover,
#nlm-mobile-sheet .nlm-sheet-close:hover,
#nlm-mobile-sheet button.nlm-sheet-close:hover,
#pbm-modal .pbm-modal-close:hover,
#pbm-modal button.pbm-modal-close:hover {
  color: #d62c2f !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
  filter: none !important;
  transform: none !important;
}

/* Dim overlay backdrop */
#nlm-overlay-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 30, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99999999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
#nlm-overlay-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* ============================================================
   DESKTOP COMPACT MODAL (>= 768px)
   ============================================================ */
@media (min-width: 768px) {
  #nlm-modal-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -45%) scale(0.95);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
    width: min(720px, 94vw);
    padding: 24px;
    box-sizing: border-box;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  #nlm-overlay-backdrop.is-open #nlm-modal-container {
    transform: translate(-50%, -50%) scale(1);
  }

  #nlm-mobile-sheet {
    display: none !important;
  }
}

/* Header & Titles */
.nlm-header {
  margin-bottom: 20px;
  position: relative;
}
.nlm-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.nlm-header-icon svg {
  width: 20px;
  height: 20px;
  fill: #545b64;
}
.nlm-title {
  font-size: 19px;
  font-weight: 700;
  color: #16191f;
  margin: 0 0 4px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.nlm-subtitle {
  font-size: 13px;
  color: #545b64;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Hide desktop action controls per user request */
.nlm-actions {
  display: none !important;
}

/* Grid Layout */
.nlm-grid-scroll {
  max-height: 46vh;
  overflow-y: auto;
  margin-bottom: 20px;
  padding-right: 4px;
}
.nlm-grid-scroll::-webkit-scrollbar {
  width: 5px;
}
.nlm-grid-scroll::-webkit-scrollbar-thumb {
  background: #aab7c4;
  border-radius: 4px;
}
.nlm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* AWS Card (Compact Layout) */
.nlm-card {
  border: 1.5px solid #d5dbdb !important;
  border-radius: 8px !important;
  padding: 12px 16px !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  cursor: pointer !important;
  background: #ffffff !important;
  transition: border-color 0.15s, background 0.15s !important;
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 58px !important;
  min-height: 58px !important;
  max-height: 58px !important;
}
.nlm-card:hover {
  border-color: #007cba !important;
  background: #f7f9f9 !important;
}
.nlm-card.is-selected {
  border-color: #007cba !important;
  background: #f1faff !important;
  box-shadow: 0 0 0 1px #007cba !important;
}
.nlm-card.is-current {
  background: #fafafa !important;
  opacity: 0.85 !important;
}

/* Radio circle */
.nlm-radio {
  width: 16px;
  height: 16px;
  border: 2px solid #aab7c4;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #ffffff;
}
.nlm-card.is-selected .nlm-radio {
  border-color: #007cba;
}
.nlm-card.is-selected .nlm-radio::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #007cba;
  display: block;
}

/* Larger rounded flag styling */
.nlm-flag-img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 50%;
  border: 1.5px solid #d5dbdb;
  flex-shrink: 0;
}
.nlm-details {
  display: flex;
  align-items: center;
  flex-grow: 1;
  min-width: 0;
}
.nlm-name {
  font-size: 15px;
  font-weight: 600;
  color: #16191f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

/* Action controls */
.nlm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid #eaeded;
  padding-top: 16px;
}
.nlm-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.nlm-btn-primary {
  background: #007cba;
  color: #ffffff;
  border: none;
}
.nlm-btn-primary:hover {
  background: #006090;
}
.nlm-btn-primary:disabled {
  background: #eaeded;
  color: #aab7c4;
  cursor: not-allowed;
}
.nlm-btn-secondary {
  background: #ffffff;
  border: 1px solid #545b64;
  color: #545b64;
}
.nlm-btn-secondary:hover {
  background: #f7f9f9;
}

/* ============================================================
   MOBILE DROP-DOWN PANEL FROM TOP (< 768px)
   ============================================================ */
@media (max-width: 767px) {
  #nlm-modal-container {
    display: none !important;
  }

  #nlm-mobile-sheet {
    position: fixed;
    top: -100%;
    left: 0;
    width: 100%;
    background: #ffffff;
    border-radius: 0 0 18px 18px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    z-index: 99999999;
    box-sizing: border-box;
    transition: top 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 20px 20px 24px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
  }
  #nlm-overlay-backdrop.is-open #nlm-mobile-sheet {
    top: 0;
  }

  /* Remove handles as it drops from top */
  .nlm-sheet-handle {
    display: none !important;
  }

  .nlm-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
  }

  .nlm-sheet-title {
    font-size: 17px;
    font-weight: 700;
    color: #16191f;
  }

  /* List of items */
  .nlm-sheet-list {
    overflow-y: auto;
    flex-grow: 1;
    margin-bottom: 10px;
  }

  .nlm-sheet-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f2f4f4;
    text-decoration: none;
    color: #16191f;
    cursor: pointer;
    transition: background 0.15s;
  }
  .nlm-sheet-item:active {
    background: #f7f9f9;
  }

  .nlm-sheet-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  /* Round, bigger flag on mobile */
  .nlm-sheet-flag {
    width: 30px;
    height: 30px;
    object-fit: cover;
    border-radius: 50%;
    border: 1.5px solid #d5dbdb;
  }

  .nlm-sheet-info {
    display: flex;
    align-items: center;
  }

  .nlm-sheet-name {
    font-size: 16px;
    font-weight: 600;
    color: #16191f;
  }

  /* Checkmark circle */
  .nlm-sheet-check {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #aab7c4;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .nlm-sheet-item.is-selected .nlm-sheet-check {
    border-color: #007cba;
    background: #007cba;
  }

  .nlm-sheet-item.is-selected .nlm-sheet-check::after {
    content: "";
    width: 4px;
    height: 8px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
  }
}