/*
 * alignvu UI v2.1: the entity profile, new format (v2): #search-profile-modal-v2 and the compare, relationship and
 * records-in-entity Dialogs in application/views/search/profile_v2.php. Markup from js/modules/search/profile_v2/
 * (the grids are finished as FeedTables by body_style.js). Replaces the view's old inline <style> block.
 * The id-scoped rules beat the old .search-profile rules in css/search.css; the !important ones beat inline styles
 * the grid builders still write.
 */

/* ---------- The Dialog ---------- */

#search-profile-modal-v2 > .modal-content.app-profile-v2 {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(1440px, calc(100vw - 32px));
    max-width: none;
    height: calc(100vh - 48px);
    max-height: calc(100vh - 48px);
    padding: 0;
    gap: 0;
    overflow: hidden;
    background: var(--surface);
}

#search-profile-modal-v2 .modal-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    padding: 0;
    overflow: hidden;
}

/* ---------- Header: name, status, type, ID and datafeed; the switch and buttons on the right ---------- */

#search-profile-modal-v2 .profile-header.app-profile-v2__head {
    position: static;
    padding: 0;
    margin: 0;
    background: var(--surface);
}

#search-profile-modal-v2 .title-banner.app-profile-v2__banner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    width: auto;
    margin: 0;
    padding: 18px 20px 12px;
    background: var(--surface);
}

#search-profile-modal-v2 .title-banner .title.app-profile-v2__title {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: auto;
    min-width: 0;
    padding: 0;
}

.app-profile-v2__name-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}

#search-profile-modal-v2 .title-banner .title h2#profile-name-v2 {
    margin: 0;
    font: 700 20px/28px var(--font-display);
    color: var(--heading-ink);
    overflow-wrap: anywhere;
}

#search-profile-modal-v2 .title-banner .title .details {
    display: flex;
    gap: 6px;
}

.app-profile-v2__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
}

#search-profile-modal-v2 .title-banner .app-profile-v2__meta .id {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    width: auto;
    text-align: left;
    justify-content: flex-start;
}

.app-profile-v2__record-id {
    font: 600 13px/18px var(--font-display);
    color: var(--heading-ink);
    font-variant-numeric: tabular-nums;
}

#search-profile-modal-v2 .app-profile-v2__feed.av-chip {
    padding: 3px 10px;
    cursor: default;
    font-size: 12px;
}

.app-profile-v2__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: none;
}

#search-profile-modal-v2 .native-mapping-toggle-container {
    font-size: 13px;
}

#search-profile-modal-v2 .profile-version-switch-container-v2 {
    display: none;
    position: static;
}

/* ---------- Tabs ---------- */

#search-profile-modal-v2 .search-profile-tabs-container {
    margin: 0;
    padding: 0 20px;
    background: var(--surface);
    box-shadow: none;
}

#search-profile-modal-v2 .search-profile-tabs.av-tabs {
    width: auto;
    margin: 0;
    gap: 20px;
    border-top: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

#search-profile-modal-v2 .search-profile-tab.av-tab {
    height: auto;
    flex: none;
    padding: 10px 0;
    white-space: nowrap;
    border-bottom: 0;
}

#search-profile-modal-v2 .search-profile-tab.av-tab:hover {
    background: none;
    color: var(--heading-ink);
}

#search-profile-modal-v2 .search-profile-tab.av-tab.active {
    color: var(--heading-ink);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--heading-ink);
}

/* ---------- Tab body ---------- */

#search-profile-modal-v2 .front-page,
#search-profile-modal-v2 .front-page .details {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

#search-profile-body-v2 {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px 24px;
    background: var(--paper);
    font: 400 13px/20px var(--font-display);
    color: var(--body-ink);
}

/* a grid's heading row: its title and the "Show cross entity" link */
#search-profile-body-v2 .profile-grid-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 10px !important;
}

#search-profile-body-v2 .profile-grid-header h3,
#search-profile-body-v2 .profile-grid-sub-header h3,
#search-profile-body-v2 h3 {
    margin: 0 !important;
    gap: 12px;
    font: 600 15px/22px var(--font-display);
    color: var(--heading-ink);
}

#search-profile-modal-v2 .app-profile-v2__link,
.profile-compare-modal-v2 .app-profile-v2__link {
    margin-left: 0;
    padding: 0;
    border: 0;
    background: none;
    font: 600 12.5px/18px var(--font-display);
    color: var(--heading-ink);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

#search-profile-modal-v2 .app-profile-v2__link:hover,
.profile-compare-modal-v2 .app-profile-v2__link:hover {
    color: var(--table-ink);
}

/* sub-tabs (identifier and definition clusters) */
#search-profile-body-v2 .profile-sub-tabs.av-tabs,
#search-profile-body-v2 .profile-identifier-sub-tabs.av-tabs {
    flex-wrap: wrap;
    gap: 16px;
    margin: 0 0 16px;
    padding: 0;
}

#search-profile-body-v2 .av-tab.profile-sub-tab,
#search-profile-body-v2 .av-tab.profile-identifier-sub-tab {
    padding: 8px 0;
    font-size: 13px;
    text-decoration: none;
}

#search-profile-body-v2 .av-tab.profile-sub-tab.active,
#search-profile-body-v2 .av-tab.profile-identifier-sub-tab.active {
    color: var(--heading-ink);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--heading-ink);
}

#search-profile-body-v2 .profile-sub-tab-content,
#search-profile-body-v2 .profile-identifier-sub-tab-content {
    margin-top: 0 !important;
}

/* empty and loading states */
#search-profile-body-v2 .no-records-msg {
    padding: 32px 24px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    text-align: center;
    color: var(--muted);
}

/* ---------- Grids (FeedTables) ---------- */

.app-profile-v2__frame {
    margin: 0 0 20px;
}

#search-profile-modal-v2 table.comparison-table,
.profile-compare-modal-v2 table.comparison-table {
    width: 100%;
    margin: 0 !important;
    border-collapse: collapse;
    table-layout: auto;
    font: 400 13px/20px var(--font-display);
    color: var(--table-ink);
}

#search-profile-modal-v2 table.comparison-table th,
.profile-compare-modal-v2 table.comparison-table th {
    position: static;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 10px 12px;
    background: var(--day-band);
    border-bottom: 1px solid var(--border);
    font: 600 12.5px/16px var(--font-display);
    color: var(--heading-ink);
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
    display: table-cell;
}

#search-profile-modal-v2 table.comparison-table td,
.profile-compare-modal-v2 table.comparison-table td {
    max-width: 420px;
    height: auto;
    padding: 9px 12px;
    border-bottom: 1px solid var(--row-rule);
    background: var(--surface);
    vertical-align: top;
    text-align: left;
    overflow-wrap: break-word;
    color: var(--table-ink);
}

#search-profile-modal-v2 table.comparison-table tbody tr:last-child td,
.profile-compare-modal-v2 table.comparison-table tbody tr:last-child td {
    border-bottom: 0;
}

#search-profile-modal-v2 table.comparison-table tbody tr:hover td,
.profile-compare-modal-v2 table.comparison-table tbody tr:hover td {
    background: var(--fill);
}

#search-profile-modal-v2 table.comparison-table td.nowrap {
    white-space: nowrap;
}

/* the first column of a field / value grid reads as the row heading */
#search-profile-modal-v2 table.comparison-table td[style*="font-weight: 600"] {
    color: var(--heading-ink);
}

/* the reference-code timestamps button */
#search-profile-modal-v2 .clock-icon-link img {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

#search-profile-modal-v2 .clock-icon-link:hover img {
    opacity: 1;
}

/* the records-in-entity grid: the current record */
.profile-compare-modal-v2 tr.app-profile-v2__current-row td {
    background: var(--day-band);
}

.app-profile-v2__current {
    margin-left: 6px;
    padding: 1px 8px;
}

/* ---------- Relationships ---------- */

#search-profile-body-v2 .profile-rel-header-controls {
    margin-bottom: 12px !important;
}

.profile-rel-breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font: 400 13px/18px var(--font-display) !important;
    color: var(--body-ink) !important;
}

.profile-rel-breadcrumbs .crumb-link {
    color: var(--heading-ink);
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.profile-rel-breadcrumbs .crumb-current {
    font-weight: 600;
    color: var(--heading-ink);
}

.profile-rel-breadcrumbs .crumb-sep {
    color: var(--muted);
}

label.av-switch.profile-rel-toggle-container {
    font-size: 13px;
}

.profile-network-container {
    position: relative;
    width: 100%;
    height: 540px;
    min-height: 500px;
    margin-top: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    background-image: radial-gradient(var(--row-rule) 1.25px, transparent 1.25px);
    background-size: 20px 20px;
}

.profile-network-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: visible;
}

.profile-network-svg line {
    stroke: var(--heading-ink);
    stroke-width: 2;
    transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

.profile-network-svg line.entity-records-line {
    stroke: var(--muted);
    stroke-dasharray: 6 3;
}

.profile-network-svg line.active-hover,
.profile-network-svg line.entity-records-line.active-hover {
    stroke: var(--heading-ink) !important;
    stroke-width: 3.5 !important;
    stroke-dasharray: none !important;
}

.profile-node {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    z-index: 2;
    font-family: var(--font-display);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.profile-node-center {
    width: 110px;
    height: 110px;
    padding: 8px;
    background: var(--surface);
    border: 2px solid var(--heading-ink);
    box-shadow: 0 0 0 6px var(--fill), 0 8px 24px rgba(26, 26, 46, 0.14);
    cursor: default;
    z-index: 3;
}

.profile-node-center-id,
.profile-node-center-prod {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-node-center-id {
    margin-top: 1px;
    font-size: 12px;
    font-weight: 700;
    color: var(--heading-ink);
}

.profile-node-center-prod {
    margin-top: 1px;
    font-size: 10px;
    line-height: 1.1;
    color: var(--muted);
}

.profile-node-satellite {
    width: 92px;
    height: 92px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--heading-ink);
    box-shadow: 0 4px 14px rgba(26, 26, 46, 0.1);
    z-index: 3;
}

.profile-node-satellite:hover,
.profile-node-entity-records:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 22px rgba(26, 26, 46, 0.18);
}

.profile-node-satellite .node-badge {
    margin-bottom: 2px;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--muted);
}

.profile-node-satellite .node-count {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    color: var(--heading-ink);
}

.profile-node-satellite .node-title {
    display: -webkit-box;
    max-width: 80px;
    margin-top: 3px;
    overflow: hidden;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.15;
    color: var(--body-ink);
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.profile-node-entity-records {
    border: 1px dashed var(--muted);
}

/* ---------- Compare, relationship and records-in-entity Dialogs ---------- */

.profile-compare-modal-v2.modal-backdrop {
    z-index: 10010;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    box-sizing: border-box;
    background: rgba(26, 26, 46, 0.4);
}

.profile-compare-modal-v2.modal-backdrop:not([style*="display: none"]):not([style*="display:none"]) {
    display: flex !important;
}

.profile-compare-modal-v2 .card-container {
    display: block;
    width: min(1100px, calc(100vw - 32px));
    min-height: 0;
    margin: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.profile-compare-modal-v2 .modal-content.app-profile-v2-dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    max-height: calc(100vh - 48px);
    padding: 0;
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: 0 12px 40px rgba(26, 26, 46, 0.18);
}

.profile-compare-modal-v2 .modal-header.app-dialog__head--bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--row-rule);
}

.profile-compare-modal-v2 .modal-title.app-dialog__title {
    margin: 0;
    font: 600 17px/24px var(--font-display);
    color: var(--heading-ink);
}

.profile-compare-modal-v2 .modal-content .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: 16px 20px 20px;
    overflow: auto;
}

.compare-feed-entry {
    margin-bottom: 6px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 12.5px;
    line-height: 1.4;
}

.compare-feed-entry:last-child {
    margin-bottom: 0;
}

.compare-feed-entry-name {
    margin-bottom: 3px;
    font-weight: 600;
    color: var(--heading-ink);
    overflow-wrap: anywhere;
}

.compare-feed-entry-id,
.compare-feed-entry-meta {
    font-size: 12px;
    color: var(--muted);
}

.compare-feed-entry-id a {
    color: var(--heading-ink);
    font-weight: 600;
    text-decoration: underline;
}

.profile-compare-modal-v2 .comparison-table td.grouped-val {
    font-weight: 600;
    color: var(--heading-ink);
    border-right: 1px solid var(--row-rule);
}

.profile-compare-modal-v2 .comparison-table tbody tr.group-bg-gray td {
    background: var(--day-band);
}

#search-profile-modal-v2 .vendor-filter-menu {
    margin-left: 200px;
    margin-top: 100px;
}
