/* Contractor name detail dialog (js/name_detail.js) — Label Review and Company Matcher. */
/* Pico makes every <dialog> a full-viewport flex box that centres its content vertically, with
   min-height: 100% overriding any max-height. A record taller than the screen then overflows above
   the top edge, where it cannot be scrolled to. Lay this one out as a plain centred box that scrolls. */
dialog.nd-dialog {
    width: min(920px, 94vw); max-height: 90vh; max-height: 90dvh; overflow: auto;
    padding: 1.25rem 1.5rem; border: 1px solid var(--avlu-border); border-radius: .6rem;
    background: var(--avlu-card); color: var(--avlu-text);
    inset: 0; margin: auto; min-width: 0; min-height: 0; height: fit-content;
}
dialog.nd-dialog[open] { display: block; }
dialog.nd-dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog.nd-dialog h2 { font-size: 1.05rem; margin: 0 0 .5rem; padding-right: 1.5rem; word-break: break-word; }
dialog.nd-dialog h3 {
    font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--avlu-text-muted); margin: 1rem 0 .4rem;
}
dialog.nd-dialog table { font-size: .78rem; width: 100%; margin: 0; }
dialog.nd-dialog td, dialog.nd-dialog th { padding: .25rem .4rem; vertical-align: top; }
/* Sticky so it stays reachable while a long record scrolls. */
dialog.nd-dialog .nd-close {
    position: sticky; top: 0; float: right; z-index: 1; margin: -.6rem -.8rem 0 0; padding: 0 .35rem;
    background: var(--avlu-card); border: none; border-radius: .3rem; font-size: 1.3rem; line-height: 1.4;
    cursor: pointer; color: var(--avlu-text-muted); width: auto; box-shadow: none;
}
dialog.nd-dialog .nd-labels { font-size: .85rem; margin: .25rem 0 .75rem; }
dialog.nd-dialog .nd-muted { color: var(--avlu-text-muted); }
dialog.nd-dialog .nd-legend { font-size: .7rem; margin: .2rem 0 0; }
dialog.nd-dialog .nd-scroll { overflow-x: auto; }
dialog.nd-dialog .nd-hash { font-family: var(--pico-font-family-monospace); font-size: .7rem; }
dialog.nd-dialog .nd-addr { font-size: .7rem; }
dialog.nd-dialog .nd-nowrap { white-space: nowrap; }
dialog.nd-dialog .nd-linkbtn {
    background: none; border: 1px solid var(--avlu-border); border-radius: .25rem; padding: .1rem .4rem;
    font-size: .7rem; cursor: pointer; color: var(--avlu-accent); margin: 0; width: auto;
}
dialog.nd-dialog .nd-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .4rem; }
dialog.nd-dialog .nd-kv > div {
    padding: .4rem .6rem; background: var(--avlu-surface); border: 1px solid var(--avlu-border);
    border-radius: .35rem; font-size: .8rem;
}
dialog.nd-dialog .nd-kv .k { font-size: .65rem; color: var(--avlu-text-muted); text-transform: uppercase; }
dialog.nd-dialog .nd-kv .v { font-weight: 600; font-variant-numeric: tabular-nums; }
dialog.nd-dialog .nd-chips { display: flex; flex-wrap: wrap; gap: .25rem; max-height: 11rem; overflow: auto; }
dialog.nd-dialog .nd-chip {
    font-family: var(--pico-font-family-monospace); font-size: .72rem; padding: .1rem .4rem; border-radius: .3rem;
    background: var(--avlu-surface); border: 1px solid var(--avlu-border); color: var(--avlu-text);
    text-decoration: none; white-space: nowrap;
}
dialog.nd-dialog .nd-chip small { margin-left: .3rem; font-size: .6rem; color: var(--avlu-text-muted); }
dialog.nd-dialog .nd-chip.winner { border-color: var(--avlu-accent); }
dialog.nd-dialog .nd-chip.dt { background: var(--avlu-accent-subtle); }
dialog.nd-dialog a.nd-chip:hover { color: var(--avlu-accent); }
dialog.nd-dialog a.nd-chip.dt:hover { cursor: copy; }

.nd-badge {
    display: inline-block; font-size: .65rem; font-weight: 700; padding: .15rem .45rem;
    border-radius: .7rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.nd-badge.human { background: #dbeafe; color: #1e40af; }
.nd-badge.company { background: #fef3c7; color: #92400e; }
.nd-badge.joint_venture { background: #d1fae5; color: #065f46; }
.nd-badge.ambiguous { background: #e5e7eb; color: #374151; }
[data-theme="dark"] .nd-badge.human { background: rgba(96, 165, 250, .2); color: #93c5fd; }
[data-theme="dark"] .nd-badge.company { background: rgba(251, 191, 36, .2); color: #fcd34d; }
[data-theme="dark"] .nd-badge.joint_venture { background: rgba(52, 211, 153, .2); color: #6ee7b7; }
[data-theme="dark"] .nd-badge.ambiguous { background: rgba(156, 163, 175, .2); color: #d1d5db; }

.nd-toast {
    position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%) translateY(1rem);
    max-width: min(640px, 92vw); padding: .6rem 1rem; border-radius: .4rem; font-size: .85rem;
    background: var(--avlu-card); color: var(--avlu-text); border: 1px solid var(--avlu-accent);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .2); opacity: 0; pointer-events: none;
    transition: opacity .2s, transform .2s; z-index: 1000;
}
.nd-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
