/* ------------------------------------------------------------------
   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: var(--theme-backdrop, 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 var(--theme-border, rgba(255, 255, 255, 0.07));
  background: var(--theme-surface, #17182b);
  color: var(--theme-text, #eef2ff);
  box-shadow: 0 24px 70px var(--theme-shadow, 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 var(--theme-border, 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: var(--theme-text, #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: var(--theme-muted, #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: var(--theme-text, #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: var(--theme-accent-soft, rgba(255, 255, 255, 0.08));
  color: var(--theme-text, #ffffff);
}

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

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

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

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

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

.nwc-status.is-error {
  color: var(--theme-danger, #fecaca);
  background: var(--theme-danger-soft, rgba(239, 68, 68, 0.12));
  border-color: var(--theme-danger, 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: var(--theme-muted, 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: var(--theme-surface, 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 var(--theme-border, rgba(255, 255, 255, 0.08));

  background: var(--theme-surface, 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: var(--theme-text, #83bfff);
  font-size: 1rem;
  line-height: 1.2;
}

.nwc-card-header p {
  margin: 0;
  color: var(--theme-text, #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: var(--theme-surface-alt, rgba(59, 130, 246, 0.22));
  color: var(--theme-text, #bfdbfe);

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

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

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

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

.nwc-label {
  display: block;
  margin-bottom: 6px;
  color: var(--theme-muted, #e5ebff);
  font-size: 0.9rem;
  font-weight: 700;
}

.nwc-help {
  margin-top: 6px;
  color: var(--theme-muted, #9aa6cf);
  font-size: 0.78rem;
  line-height: 1.3;
}

.nwc-help.is-error,
#nwc-relay-count.is-error,
#nwc-relay-summary.is-error {
  color: var(--theme-warning, #fcd34d);
}

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

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

  background: var(--theme-input, #0f1326);
  color: var(--theme-text, #f7f8ff);

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

.nwc-input:focus,
.nwc-textarea:focus {
  border-color: var(--theme-focus, #60a5fa);
  box-shadow: 0 0 0 3px var(--theme-focus-glow, 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: var(--theme-muted, #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 var(--theme-border, rgba(255, 255, 255, 0.1));

  background: var(--theme-surface, #10182f);
  color: var(--theme-text, #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: var(--theme-link, rgba(96, 165, 250, 0.45));
  background: var(--theme-accent-soft, #14203e);
}

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

.nwc-chip input {
  margin: 0;
  accent-color: var(--theme-accent, #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: var(--theme-accent, #2563eb);
  color: var(--theme-on-accent, #ffffff);
}

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

.nwc-btn-secondary {
  background: var(--theme-surface, #2b3150);
  color: var(--theme-text, #eef2ff);
}

.nwc-btn-secondary:hover:not(:disabled) {
  background: var(--theme-accent-soft, #363f66);
}

.nwc-btn-danger {
  background: var(--theme-accent, #b91c1c);
  color: var(--theme-on-accent, #ffffff);
}

.nwc-btn-danger:hover:not(:disabled) {
  background: var(--theme-accent, #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 var(--theme-border, rgba(255, 255, 255, 0.14));
  border-radius: 14px;

  color: var(--theme-muted, #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: var(--theme-surface, #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;
  }
}
