/* Metadata profile editor, shared by the Catalog and the Datasets Library.
   Every color comes from the design tokens. Warning and success use the namespaced semantic
   tokens because FluentUI injects bare warning and success tokens that win the cascade. */

.pe {
    display: flex;
    flex: 1;
    min-height: 0;
    min-width: 0;
    height: 100%;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-secondary);
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}

/* The resets use :where() so they carry no specificity and every pe-* class below wins over them. */
:where(.pe) *, :where(.pe) *::before, :where(.pe) *::after { box-sizing: border-box; }
:where(.pe) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:where(.pe) button:disabled { cursor: default; }
:where(.pe) input, :where(.pe) select, :where(.pe) textarea { font: inherit; color: var(--text-primary); }
.pe :focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 1px; }

.pe-mono { font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); font-size: 12px; }
.pe-muted { color: var(--text-muted); font-weight: 400; }
.pe-nowrap { white-space: nowrap; font-size: 12.5px; }
.pe-ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-break { word-break: break-all; }
.pe-min0 { min-width: 0; }
.pe-block { display: block; }
.pe-push { margin-left: auto; }
.pe-grow { flex: 1; }
.pe-self-start { align-self: flex-start; }
.pe-indent { padding: 0 10px; }
.pe-fill { width: 100%; justify-content: flex-start; }
.pe-scroll { flex: 1; min-height: 0; overflow: auto; }

/* Shapes rail */
.pe-shapes { width: 200px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--border-subtle); background: var(--surface-card); }
.pe-pane-head {
    flex: none; height: 44px; display: flex; align-items: center; padding: 0 14px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted);
}
.pe-shapes-list { flex: 1; min-height: 0; overflow: auto; padding: 8px 0; display: flex; flex-direction: column; gap: 2px; }
.pe-shape-item {
    display: flex; align-items: center; gap: 8px; width: calc(100% - 12px); margin: 0 6px; padding: 7px 10px;
    border-radius: 6px; color: var(--text-tertiary); text-align: left;
}
.pe-shape-item:hover { background: var(--neutral-bg); color: var(--text-primary); }
.pe-shape-item.selected { background: var(--accent-bg); color: var(--brand-accent-soft); font-weight: 600; }
.pe-shape-more { color: var(--text-muted); font-size: 12.5px; }
.pe-shape-name { flex: 1; min-width: 0; }
.pe-count {
    font-size: 11px; font-weight: 600; color: var(--text-muted); background: var(--neutral-bg);
    border-radius: 10px; padding: 0 7px; line-height: 18px;
}
.pe-shape-item.selected .pe-count, .pe-tab.active .pe-count { color: var(--brand-accent-soft); }
.pe-shapes-foot { flex: none; padding: 10px; border-top: 1px solid var(--border-subtle); }

/* Shape tabs (narrow hosts) */
.pe-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pe-tabs { flex: none; display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--border-subtle); overflow-x: auto; }
.pe-tab {
    display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; white-space: nowrap;
    border-bottom: 2px solid transparent !important; color: var(--text-muted); font-weight: 600;
}
.pe-tab:hover { color: var(--text-primary); }
.pe-tab.active { color: var(--text-primary); border-bottom-color: var(--brand-accent) !important; }
.pe-tab-more { font-weight: 400; }
.pe-body { flex: 1; min-height: 0; display: flex; }

/* Property list */
.pe-properties { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pe-toolbar { flex: none; display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 44px; border-bottom: 1px solid var(--border-subtle); }
.pe-search {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px;
    border-radius: 6px; background: var(--surface-input); border: 1px solid var(--border-subtle); color: var(--text-muted);
}
.pe-search input, .pe-dialog-body .pe-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text-primary); font: inherit; }
.pe-search:focus-within { border-color: var(--brand-accent); }
.pe-property-groups { padding: 4px 8px 12px; }
.pe-group-head {
    display: flex; align-items: center; gap: 8px; padding: 10px 6px 4px;
    font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted);
}
.pe-group-count { font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 12px; }

.pe .fluent-sortable-list.pe-sortable,
.pe-dialog-body .fluent-sortable-list.pe-sortable {
    --fluent-sortable-list-border-color: transparent;
    --fluent-sortable-list-item-background-color: transparent;
    --fluent-sortable-list-item-border-color: transparent;
    --fluent-sortable-list-padding: 0;
    --fluent-sortable-list-item-spacing: 0;
    background: transparent;
    border: 0;
    padding: 0;
}
.pe .fluent-sortable-list.pe-sortable > * { padding: 0; }
/* FluentSortableList gives its grab handle a filled box; the editor's handles are bare glyphs. */
.pe .pe-sortable .sortable-grab { background: transparent !important; border: 0 !important; height: auto !important; }

.pe-prop-row {
    display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 4px; width: 100%;
    padding: 0 0 0 4px; border-radius: 6px; border: 1px solid transparent;
}
.pe-prop-row:hover { background: var(--neutral-bg); }
.pe-prop-row.selected { background: var(--accent-bg); border-color: color-mix(in srgb, var(--brand-accent) 35%, transparent); }
.pe-prop-select {
    display: grid; grid-template-columns: minmax(0, 1fr) 150px 108px 28px; align-items: center; gap: 10px;
    width: 100%; padding: 7px 10px 7px 4px; text-align: left;
}
.pe-handle { color: var(--text-muted); opacity: .6; display: flex; justify-content: center; cursor: grab; }
.pe-prop-main { min-width: 0; display: flex; flex-direction: column; }
.pe-prop-label { font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-prop-iri { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-kind { color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.pe-flag { display: flex; justify-content: center; color: var(--text-muted); }

.pe-badge {
    display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px;
    font-size: 11px; font-weight: 600; letter-spacing: .3px; white-space: nowrap;
}
.pe-badge-info { background: var(--info-bg); color: var(--brand-accent-soft); }
.pe-badge-neutral { background: var(--neutral-bg); color: var(--text-tertiary); }
.pe-badge-success { background: var(--success-bg); color: var(--sem-success); }
.pe-badge-warning { background: var(--warning-bg); color: var(--sem-warning); }

.pe-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.pe-dot-warning { background: var(--sem-warning); }
.pe-dot-danger { background: var(--danger); }
.pe-dot-info { background: var(--sem-info); }
.pe-dot-neutral { background: var(--text-muted); }

.pe-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }

.pe-empty { display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; text-align: center; padding: 32px 16px; color: var(--text-muted); }

/* Inspector */
.pe-inspector { width: 380px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--border-subtle); background: var(--surface-card); min-height: 0; }
.pe-inspector-empty { justify-content: center; }
.pe-insp-head { flex: none; display: flex; align-items: flex-start; gap: 6px; padding: 14px 16px 12px; border-bottom: 1px solid var(--border-subtle); }
.pe-insp-heading { flex: 1; min-width: 0; }
.pe-insp-title { font-size: 16px; font-weight: 600; color: var(--text-primary); line-height: 1.25; }
.pe-insp-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 16px 16px; }

.pe-section { padding: 14px 0 6px; border-bottom: 1px solid var(--border-subtle); }
.pe-section:last-child { border-bottom: 0; }
.pe-section-title { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.pe-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.pe-field > label, .pe-lbl { font-size: 12px; font-weight: 600; color: var(--text-tertiary); }
.pe-hint { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.pe-error { font-size: 12px; color: var(--danger); line-height: 1.4; }

.pe-input, .pe-textarea {
    width: 100%; border-radius: 6px; background: var(--surface-input); border: 1px solid var(--border-subtle);
    color: var(--text-primary); outline: 0;
}
.pe-input { height: 32px; padding: 0 10px; }
.pe-input-sm { height: 26px; padding: 0 8px; }
.pe-textarea { min-height: 64px; padding: 7px 10px; resize: vertical; line-height: 1.4; }
.pe-input:focus, .pe-textarea:focus { border-color: var(--brand-accent); }
.pe-input:disabled, .pe-textarea:disabled { color: var(--text-tertiary); background: var(--surface-inset); }
.pe-input::placeholder, .pe-textarea::placeholder { color: var(--text-muted); }
.pe-select {
    appearance: none; -webkit-appearance: none; padding-right: 28px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
.pe-select option { background: var(--surface-card); color: var(--text-primary); }

/* A text box with suggestions (ProfileComboBox): the select's arrow and the StyledSelect popover. */
.pe-combo { position: relative; }
.pe-combo-input { padding-right: 28px; }
.pe-combo-toggle {
    position: absolute; top: 0; right: 0; width: 28px; height: 32px; padding: 0; border: 0; cursor: pointer;
    background-color: transparent;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
/* Shown as a popover in the top layer and placed under the box by profileEditor.js. */
.pe-combo-list {
    position: fixed; inset: auto; margin: 0; padding: 5px; list-style: none;
    max-height: 260px; overflow: auto; border-radius: 9px; background: var(--surface-card); border: 1px solid var(--border-subtle);
    box-shadow: 0 16px 44px rgba(0, 0, 0, .35);
}
.pe-combo-option { padding: 8px 11px; border-radius: 6px; font-size: 13px; color: var(--text-primary); cursor: pointer; }
.pe-combo-option:hover, .pe-combo-option.active { background: var(--neutral-bg); }

.pe-lang-stack { display: flex; flex-direction: column; gap: 6px; }
.pe-lang-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 8px; align-items: center; }
.pe-lang-row-top { align-items: flex-start; }
.pe-lang-row-top .pe-lang-tag { padding-top: 8px; }
.pe-lang-tag { font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--text-muted); text-align: center; }

.pe-seg { display: flex; padding: 2px; border-radius: 7px; background: var(--surface-track); border: 1px solid var(--border-subtle); width: 100%; }
.pe-seg-btn { flex: 1; height: 26px; border-radius: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-muted) !important; }
.pe-seg-btn:hover:not(:disabled) { color: var(--text-primary) !important; }
.pe-seg-btn.active { background: var(--brand-primary) !important; color: var(--on-gradient-dark, #fff) !important; }

.pe-switch-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 12px; }
.pe-switch {
    position: relative; width: 34px; height: 18px; border-radius: 9px; flex: none;
    background: var(--surface-track) !important; border: 1px solid var(--border-strong) !important; transition: background .15s;
}
.pe-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-muted); transition: left .15s, background .15s; }
.pe-switch.on { background: var(--brand-primary) !important; border-color: var(--brand-primary) !important; }
.pe-switch.on::after { left: 18px; background: #fff; }
.pe-switch:disabled { opacity: .6; }

.pe-vocab-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 10px;
    border-radius: 6px; background: var(--surface-card-elev); border: 1px solid var(--border-subtle);
}
.pe-vocab-title { font-weight: 600; color: var(--text-primary); }
.pe-vocab-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pe-check { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 12px; }
.pe-check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand-primary); }
.pe-check-label { font-weight: 600; color: var(--text-tertiary); }

.pe-list-value { display: grid; grid-template-columns: 16px minmax(0, 1fr) 28px; gap: 8px; align-items: center; margin-bottom: 6px; }
.pe-row-actions { display: flex; align-items: center; gap: 10px; margin-top: 2px; }

/* The DCTAP columns panel */
/* Capped so a long constraint scrolls inside the panel instead of squeezing the details above it. */
.pe-dctap { flex: none; max-height: 34%; overflow-y: auto; border-top: 1px solid var(--border-subtle); padding: 0 16px 8px; background: var(--surface-card-elev); }
.pe-disclosure { display: flex !important; align-items: center; gap: 6px; width: 100%; padding: 10px 0 !important; font-size: 12.5px; font-weight: 600; color: var(--text-tertiary) !important; text-align: left; }
.pe-kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 4px 10px; margin: 0 0 10px; }
.pe-kv dt { color: var(--text-muted); }
.pe-kv dd { margin: 0; color: var(--text-tertiary); word-break: break-all; }

/* Buttons that are plain elements (rows, icons); page and dialog actions use FluentButton. */
.pe-btn {
    display: inline-flex !important; align-items: center; gap: 6px; height: 32px; padding: 0 12px !important; border-radius: 6px;
    border: 1px solid var(--border-strong) !important; background: var(--surface-input) !important; color: var(--text-primary) !important;
    font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.pe-btn:hover:not(:disabled) { background: var(--surface-card-elev) !important; }
.pe-btn:disabled { opacity: .55; }
.pe-btn-sm { height: 28px; padding: 0 10px !important; font-size: 12.5px; }
.pe-btn-subtle { border-color: transparent !important; background: transparent !important; color: var(--text-tertiary) !important; }
.pe-btn-subtle:hover:not(:disabled) { background: var(--neutral-bg) !important; color: var(--text-primary) !important; }
.pe-btn-selected { background: var(--accent-bg) !important; color: var(--brand-accent-soft) !important; }
.pe-icon-btn {
    display: inline-flex !important; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none;
    border-radius: 6px; color: var(--text-tertiary) !important;
}
.pe-icon-btn:hover:not(:disabled) { background: var(--neutral-bg) !important; color: var(--text-primary) !important; }
.pe-danger { color: var(--danger) !important; }
.pe-link { color: var(--brand-accent-soft) !important; text-align: left; }
.pe-link:hover { text-decoration: underline; }

/* Profile details */
.pe-details { flex: 1; min-width: 0; overflow: auto; }
.pe-details-inner { max-width: 620px; padding: 6px 22px 22px; }
.pe-issue-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pe-issue-list li { display: flex; align-items: baseline; gap: 8px; }

/* Dialogs */
.pe-dialog-body { color: var(--text-secondary); font-size: 13px; line-height: 1.45; }
:where(.pe-dialog-body) *, :where(.pe-dialog-body) *::before, :where(.pe-dialog-body) *::after { box-sizing: border-box; }
:where(.pe-dialog-body) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:where(.pe-dialog-body) input, :where(.pe-dialog-body) textarea { font: inherit; color: var(--text-primary); }
.pe-dialog-head { display: flex; align-items: center; gap: 10px; width: 100%; color: var(--text-tertiary); }
.pe-dialog-heading { flex: 1; min-width: 0; }
.pe-dialog-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.pe-dialog-sub { font-size: 12.5px; color: var(--text-muted); font-weight: 400; }
.pe-dialog-sub strong { color: var(--text-tertiary); }

.pe-group-label { padding: 10px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); }
.pe-pick-row {
    display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px;
    border-radius: 6px; text-align: left; width: 100%; color: inherit; cursor: pointer;
}
.pe-pick-row-wide { grid-template-columns: minmax(0, 1fr) auto; }
.pe-pick-row:hover:not(:disabled) { background: var(--neutral-bg); }
.pe-pick-row.active { background: var(--accent-bg); }
.pe-pick-row:disabled { opacity: .55; cursor: default; }
.pe-pick-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand-primary); }
.pe-pick-text { min-width: 0; display: flex; flex-direction: column; }
.pe-pick-title { font-weight: 600; color: var(--text-primary); }
.pe-pick-meta { font-size: 12px; color: var(--text-muted); }
.pe-inline-iri { font-weight: 400; margin-left: 6px; }

.pe-vocab-chooser { flex: 1; display: flex; gap: 16px; min-height: 0; }
.pe-vocab-list { flex: 1 1 400px; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.pe-vocab-list .pe-search, .pe-add-property .pe-search { flex: none; }
.pe-vocab-preview {
    flex: 0 0 290px; min-width: 0; display: flex; flex-direction: column; min-height: 0; border-radius: 8px;
    background: var(--surface-card-elev); border: 1px solid var(--border-subtle);
}
.pe-vocab-preview-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 4px; }
.pe-terms { padding: 0 14px 12px; }
.pe-term { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; font-size: 12.5px; color: var(--text-tertiary); min-width: 0; overflow-wrap: anywhere; }

.pe-add-property { flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.pe-add-property .pe-search { height: 32px; }
.pe-custom-iri { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 2px 10px 6px; align-items: center; }
.pe-callout {
    flex: none; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px;
    background: var(--surface-card-elev); border: 1px solid var(--border-subtle); color: var(--text-tertiary); font-size: 12.5px;
}
.pe-callout strong { color: var(--text-primary); }

/* Tabs layout (the Datasets Library): a narrower inspector and denser rows. */
.pe-layout-tabs .pe-inspector { width: 330px; }
.pe-layout-tabs .pe-prop-select { grid-template-columns: minmax(0, 1fr) 112px 94px 20px; }

/* Shared dialogs: a plain card, the content filling the height the opener sets. */
.pe-dialog::part(dialog) {
    background: var(--surface-card);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: var(--shadow-dialog);
    max-height: calc(100vh - 40px);
}
/* The body fills the height the opener sets, so the lists inside scroll instead of growing the dialog. */
.pe-dialog fluent-dialog-body { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.pe-dialog fluent-dialog-body::part(title) { display: block; flex: none; }
.pe-dialog fluent-dialog-body::part(content) { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.pe-dialog fluent-dialog-body::part(actions) { flex: none; }
.pe-dialog fluent-dialog-body > div:not([slot]) { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Narrow widths: the inspector takes less room before the list gives way. */
@media (max-width: 1180px) {
    .pe-inspector { width: 330px; }
    .pe-prop-select { grid-template-columns: minmax(0, 1fr) 120px 96px 24px; }
}
