/* ------------------------------------------------------------------
   DamageBDD Nostr Wallet Connect modal
   Unified layout / spacing / scroll / button / QR styling
------------------------------------------------------------------ */

/* Page scroll lock. JS should add/remove nwc-modal-open on html/body. */
html.nwc-modal-open,
body.nwc-modal-open {
  overflow: hidden !important;
  height: 100%;
}

/* Chromium fallback if the class was not applied */
body:has(#nwc-modal.is-open) {
  overflow: hidden;
}

/* ------------------------------------------------------------------
   Overlay / shell
------------------------------------------------------------------ */

#nwc-modal .modal__overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow: hidden !important;
  overscroll-behavior: contain;
  background: rgba(0, 0, 0, 0.68);
}

.modal__container.nwc-modal,
.nwc-modal,
.nwc-modal * {
  box-sizing: border-box;
}

.modal__container.nwc-modal,
.nwc-modal {
  width: min(940px, calc(100vw - 48px)) !important;
  max-width: none !important;
  height: min(720px, calc(100dvh - 48px)) !important;
  max-height: none !important;

  display: flex !important;
  flex-direction: column !important;

  overflow: hidden !important;
  overscroll-behavior: contain;

  padding: 14px 16px 16px !important;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: #17182b;
  color: #eef2ff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52);

  scrollbar-width: none;
}

.nwc-modal::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ------------------------------------------------------------------
   Header
------------------------------------------------------------------ */

.nwc-modal-header {
  position: relative;
  flex: 0 0 auto;
  display: block !important;
  align-items: initial !important;
  justify-content: initial !important;
  text-align: left !important;

  margin: 0 !important;
  padding: 0 42px 10px 0 !important;

  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nwc-modal-header > div:empty {
  display: none !important;
}

.nwc-modal-header-copy {
  margin: 0;
}

.nwc-title {
  margin: 0;
  color: #f4f7ff;
  font-size: 0.98rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.nwc-subtitle {
  margin: 5px 0 0;
  max-width: 720px;
  color: #aab4d6;
  font-size: 0.84rem;
  line-height: 1.3;
}

/* Single close glyph only */
.nwc-close {
  position: absolute !important;
  top: -4px;
  right: -4px;

  display: inline-flex !important;
  align-items: center;
  justify-content: center;

  width: 32px;
  height: 32px;
  padding: 0;

  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #cfd7f6;

  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.9;
}

.modal__close.nwc-close::before,
.modal__close.nwc-close::after,
.nwc-close::before,
.nwc-close::after {
  content: none !important;
}

.nwc-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nwc-close:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(78, 140, 255, 0.22);
}

/* ------------------------------------------------------------------
   Status
------------------------------------------------------------------ */

.nwc-status {
  flex: 0 0 auto;
  min-height: 0;
  margin: 10px 0 8px !important;
  color: #cfe0ff;
  font-size: 0.86rem;
  line-height: 1.3;
}

.nwc-status:not(:empty) {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(78, 140, 255, 0.1);
  border: 1px solid rgba(78, 140, 255, 0.2);
}

.nwc-status.is-success {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.26);
}

.nwc-status.is-error {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.28);
}

/* ------------------------------------------------------------------
   Main scroll area
------------------------------------------------------------------ */

.nwc-modal-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto !important;
  overscroll-behavior: contain;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.nwc-modal-main::-webkit-scrollbar {
  width: 8px;
}

.nwc-modal-main::-webkit-scrollbar-track {
  background: transparent;
}

.nwc-modal-main::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

/* ------------------------------------------------------------------
   Grid / cards
------------------------------------------------------------------ */

.nwc-grid {
  min-height: 0;
  height: auto !important;

  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.nwc-card {
  min-width: 0;
  min-height: 0;

  padding: 14px !important;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);

  background: rgba(255, 255, 255, 0.035);
}

.nwc-config-card,
.nwc-result-card,
.nwc-revoke-card {
  overflow: visible;
}

.nwc-config-body,
.nwc-result-body,
.nwc-result-column {
  min-height: 0;
  overflow: visible;
}

.nwc-result-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ------------------------------------------------------------------
   Card headers / badges
------------------------------------------------------------------ */

.nwc-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px !important;
}

.nwc-card-header h3 {
  margin: 0 0 3px;
  color: #83bfff;
  font-size: 1rem;
  line-height: 1.2;
}

.nwc-card-header p {
  margin: 0;
  color: #aab4d6;
  font-size: 0.84rem;
  line-height: 1.3;
}

.nwc-card-header-compact {
  margin-bottom: 10px !important;
}

.nwc-step-badge {
  display: inline-grid;
  place-items: center;

  width: 24px;
  height: 24px;
  flex: 0 0 24px;

  border-radius: 999px;
  background: rgba(59, 130, 246, 0.22);
  color: #bfdbfe;

  font-size: 0.85rem;
  font-weight: 800;
}

.nwc-step-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
}

/* ------------------------------------------------------------------
   Fields
------------------------------------------------------------------ */

.nwc-field {
  margin-bottom: 12px !important;
}

.nwc-label {
  display: block;
  margin-bottom: 6px;
  color: #e5ebff;
  font-size: 0.9rem;
  font-weight: 700;
}

.nwc-help {
  margin-top: 6px;
  color: #9aa6cf;
  font-size: 0.78rem;
  line-height: 1.3;
}

.nwc-help.is-error,
#nwc-relay-count.is-error,
#nwc-relay-summary.is-error {
  color: #fcd34d;
}

.nwc-input,
.nwc-textarea {
  width: 100%;
  padding: 9px 11px;

  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 11px;
  outline: none;

  background: #0f1326;
  color: #f7f8ff;

  font: inherit;
  font-size: 0.9rem;
}

.nwc-input:focus,
.nwc-textarea:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.18);
}

.nwc-input-affix {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.nwc-input-affix span {
  color: #9aa6cf;
  font-size: 0.78rem;
}

.nwc-custom-relays {
  min-height: 58px;
  max-height: 76px;
  resize: vertical;
}

/* ------------------------------------------------------------------
   Relay chips
------------------------------------------------------------------ */

.nwc-relay-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  scrollbar-width: none;
}

.nwc-relay-chips::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.nwc-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  min-height: 36px;
  padding: 8px 11px;

  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);

  background: #10182f;
  color: #e5ebff;

  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;

  transition:
    border-color 120ms ease,
    background 120ms ease,
    transform 120ms ease;
}

.nwc-chip:hover {
  border-color: rgba(96, 165, 250, 0.45);
  background: #14203e;
}

.nwc-chip:has(input:checked) {
  border-color: rgba(96, 165, 250, 0.65);
  background: rgba(37, 99, 235, 0.24);
}

.nwc-chip input {
  margin: 0;
  accent-color: #3b82f6;
}

/* ------------------------------------------------------------------
   Limits / actions
------------------------------------------------------------------ */

.nwc-limits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.nwc-actions,
.nwc-inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.nwc-btn {
  min-height: 38px;
  padding: 9px 14px;

  border: 0;
  border-radius: 11px;

  font: inherit;
  font-weight: 800;

  cursor: pointer;
}

.nwc-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.nwc-btn-primary {
  background: #2563eb;
  color: #ffffff;
}

.nwc-btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.nwc-btn-secondary {
  background: #2b3150;
  color: #eef2ff;
}

.nwc-btn-secondary:hover:not(:disabled) {
  background: #363f66;
}

.nwc-btn-danger {
  background: #b91c1c;
  color: #ffffff;
}

.nwc-btn-danger:hover:not(:disabled) {
  background: #991b1b;
}

/* ------------------------------------------------------------------
   Empty/result/QR
------------------------------------------------------------------ */

.nwc-empty-state {
  display: flex;
  min-height: 220px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;

  padding: 18px;

  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 14px;

  color: #9aa6cf;
  text-align: center;
}

.nwc-empty-state[hidden],
.nwc-result-body[hidden] {
  display: none !important;
}

.nwc-empty-state p,
.nwc-empty-state strong {
  margin: 0;
}

.nwc-empty-icon {
  font-size: 2.1rem;
}

.nwc-qr-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  overflow: visible;
}

.nwc-qr {
  box-sizing: border-box;

  width: min(100%, 190px);
  max-width: 190px;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 10px;
  border-radius: 16px;
  background: #ffffff;
  overflow: hidden;
}

.nwc-qr canvas,
.nwc-qr img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

.nwc-uri-box,
.nwc-mono {
  font-family: ui-monospace, sfmono-regular, menlo, consolas, monospace;
}

.nwc-uri-box {
  max-height: 88px;
  resize: none;
  font-size: 0.82rem;
  line-height: 1.4;
}

.nwc-client-field {
  margin-top: 12px;
  margin-bottom: 0 !important;
}

/* ------------------------------------------------------------------
   Responsive / DevTools-docked
------------------------------------------------------------------ */

@media (max-width: 1180px) {
  .modal__container.nwc-modal,
  .nwc-modal {
    width: min(720px, calc(100vw - 36px)) !important;
    height: min(88dvh, 760px) !important;
  }

  .nwc-grid {
    grid-template-columns: 1fr;
  }

  .nwc-limits {
    grid-template-columns: 1fr;
  }

  .nwc-empty-state {
    min-height: 180px;
  }

  .nwc-qr {
    width: min(100%, 210px);
    max-width: 210px;
  }
}

@media (max-width: 640px) {
  #nwc-modal .modal__overlay {
    padding: 10px;
  }

  .modal__container.nwc-modal,
  .nwc-modal {
    width: calc(100vw - 20px) !important;
    height: calc(100dvh - 20px) !important;
    padding: 12px !important;
  }

  .nwc-modal-header {
    padding-right: 38px !important;
  }

  .nwc-title {
    font-size: 0.95rem;
  }

  .nwc-subtitle {
    font-size: 0.8rem;
  }

  .nwc-card {
    padding: 12px !important;
  }

  .nwc-chip {
    font-size: 0.84rem;
  }
}
