/* Mappings screens (MappingsFrame.razor) */

/* The page fills the panel; only the grid rows scroll */
.map-page { height: 100%; display: flex; flex-direction: column; }
.map-toolbar { flex: none; display: flex; flex-wrap: wrap; align-items: center; min-height: 40px; margin-bottom: 12px; }
.map-toolbar .map-clear { min-width: 30px; }
.map-item-count { margin-left: 16px; font-size: 0.875rem; font-weight: 600; white-space: nowrap; }

/* Titles tab */
.map-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 4px 0; }
.map-filter { display: flex; align-items: center; gap: 4px; }
.map-filter-rows { display: flex; flex-direction: column; }
.map-title-search { width: 360px; max-width: 100%; }
.map-grid th.titles, .map-grid td.titles { width: 28%; }
.map-grid .map-title-text { font-size: 1.1rem; font-weight: 600; line-height: 1.35; }
.map-m { font-size: 1.25rem; }
.map-m.mapped { color: #16a34a; }
.map-m.unmapped { color: #f97316; }

.map-tabs { display: inline-flex; margin-right: 48px; border-top: 1px solid #9ca3af; border-bottom: 1px solid #9ca3af; }
.map-tabs a { min-width: 140px; padding: 7px 24px; text-align: center; color: #111827; text-decoration: none; }
.map-tabs a:hover { background: #f3f4f6; }
.map-tabs a.active { background: #0a6874; color: #fff; }

.map-card { width: 100%; min-height: 0; display: flex; flex-direction: column; background: #fff; border: 1px solid #e5e7eb; border-radius: 16px; padding: 4px 18px 8px; }
/* position: relative keeps hidden icon labels inside the scroll area, so they cannot stretch the page */
.map-scroll { position: relative; min-height: 0; overflow: auto; }

.map-grid { width: 100%; border-collapse: collapse; font-size: 0.875rem; line-height: 1.3; }
/* Specific enough to beat QuickGrid's theme, so header and body padding match */
table.quickgrid.map-grid > thead > tr > th, table.quickgrid.map-grid > tbody > tr > td { padding: 6px 12px; vertical-align: top; }
table.quickgrid.map-grid > thead > tr > th { position: sticky; top: 0; z-index: 2; background: #fff; font-weight: 600; box-shadow: inset 0 -1px 0 #d1d5db; }
table.quickgrid.map-grid[theme] .col-header-content { padding-right: 0; }
table.quickgrid.map-grid[theme] .col-title { padding: 0; font-weight: 600; }
/* QuickGrid makes the header content a flex box, so the names header has to be told to fill it */
.map-grid .col-header-content > .pair { flex: 1; }
.map-grid th, .map-grid td { text-align: left; }
.map-grid tbody tr { border-top: 1px solid #f0f0f0; }
.map-grid tbody tr:nth-child(even) { background-color: #f3f4f6; }
.map-grid tbody tr:hover { background-color: #e5e7eb; }
.map-grid .sub { font-size: 0.75rem; font-weight: 400; color: #6b7280; }

/* Inner grid: two equal columns, one shared row per level */
.map-grid .pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.map-grid .pair > div { padding: 2px 12px 2px 0; overflow-wrap: break-word; }
.map-grid .pair > .sep { border-top: 1px dotted #cbd5e1; }
.map-grid .pair > .l1 { font-weight: 600; }
.map-grid .pair > .l2 { padding-left: 8px; color: #6b7280; }
.map-grid .pair > .l3 { padding-left: 16px; color: #6b7280; }
.map-grid .tag { margin-left: 6px; font-size: 0.7rem; color: #6b7280; }
.map-grid .map-pub-count { color: #4b5563; white-space: nowrap; }

/* Clicking anywhere on a row opens its editor: the row's .row-open button is stretched over the row */
.map-grid tbody tr { position: relative; }
.map-grid .row-open { font-weight: 600; text-align: left; color: inherit; cursor: pointer; }
.map-grid .row-open::after { content: ""; position: absolute; inset: 0; }
.map-grid .row-open:focus-visible { outline: none; }
.map-grid .row-open:focus-visible::after { outline: 2px solid #0a6874; outline-offset: -2px; }

/* Column widths: .code, .num and .act shrink to their content; the rest take the spare width */
.map-grid th.code, .map-grid td.code { width: 1%; min-width: 110px; white-space: nowrap; }
.map-grid th.num, .map-grid td.num { width: 1%; min-width: 85px; white-space: nowrap; }
.map-grid th.act, .map-grid td.act { width: 1%; white-space: nowrap; }
/* The Edit button sits above the stretched row button */
.map-grid td.act button { position: relative; z-index: 1; }
/* Count cells also sit above it: clicking there never opens the editor, only the counts themselves are links */
.map-grid th.count, .map-grid td.count { width: 1%; min-width: 90px; white-space: nowrap; }
.map-grid td.count, .map-grid td.button-only { position: relative; z-index: 1; cursor: default; }

/* A clickable Titles / Mapped / Exempt count */
.map-count, .map-count-none { display: inline-block; min-width: 44px; padding: 3px 10px; border: 1px solid transparent; border-radius: 6px; text-align: right; }
.map-count { color: inherit; text-decoration: none; cursor: pointer; }
.map-count:hover, .map-count:focus-visible { color: #0a6874; background: #d5eef1; border-color: #0a6874; text-decoration: none; }
.map-count-none { color: #9ca3af; }
.map-counts dd .map-count, .map-counts dd .map-count-none { margin-left: -11px; text-align: left; }

/* Slide-over editors (SidePanel.razor): the page behind is blocked, the header stays put, the body scrolls */
.side-backdrop { position: fixed; inset: 0; z-index: 999; background: rgba(17, 24, 39, .3); }
.side-panel { position: fixed; top: 0; right: 0; bottom: 0; max-width: 100%; display: flex; flex-direction: column; background: #fff; box-shadow: -4px 0 12px rgba(0,0,0,.2); z-index: 1000; }
.side-header { flex: none; background-color: #f9fafb; }
.side-header .buttons:disabled { opacity: .45; cursor: default; }
.side-body { flex: 1; min-height: 0; overflow-y: auto; padding: 1.5rem; }

/* Mapping Manager (MappingEditor.razor) */

.map-counts { display: flex; gap: 40px; margin: 0 0 20px; }
.map-counts dt { font-size: 0.75rem; color: #6b7280; text-transform: uppercase; }
.map-counts dd { margin: 0; font-size: 1.25rem; font-weight: 600; }

.map-incoming { margin-bottom: 28px; max-width: 480px; font-size: 0.9rem; border-bottom: 1px solid #e5e7eb; }
.map-incoming .head { padding: 0 4px 8px; font-size: 0.75rem; border-bottom: 2px solid #d1d5db; margin-bottom: 8px; }
.map-incoming .l1 { padding: 2px 12px; font-weight: 600; }
.map-incoming .l2 { padding: 2px 12px 2px 20px; color: #6b7280; border-top: 1px dotted #cbd5e1; }
.map-incoming .l3 { padding: 2px 12px 8px 28px; color: #6b7280; border-top: 1px dotted #cbd5e1; }

.map-field { margin-bottom: 18px; }
.map-field-label { margin-bottom: 4px; font-size: 0.9rem; font-weight: 600; }
.map-field-row { display: flex; align-items: center; gap: 12px; }
.map-field-box { position: relative; flex: 1; min-width: 0; }
.map-field-box .combo-box-container, .map-field-box .combo-box { width: 100%; margin: 0; }
.map-field-box .combo-box input.map-combo-input { padding: 7px 28px 7px 28px; text-overflow: ellipsis; }
.map-readonly { min-height: 34px; padding: 6px 8px 6px 28px; border: 1px solid #e5e7eb; border-radius: 4px; background: #f9fafb; }
.map-dot { position: absolute; left: 10px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; z-index: 1; }
.map-dot.map-matched { background: #16a34a; }
.map-dot.map-picked { background: #f97316; }
.map-status { width: 110px; flex: none; font-size: 0.75rem; font-weight: 600; }
.map-status.map-matched { color: #16a34a; }
.map-status.map-picked { color: #ea580c; }
.map-create { flex: none; font-size: 0.85rem; text-decoration: underline; cursor: pointer; }
.map-create:disabled { color: #9ca3af; cursor: default; text-decoration: none; }
.map-create-form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding: 10px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 4px; }
.map-create-form input { width: 100%; padding: 4px 8px; border: 1px solid #d1d5db; border-radius: 4px; }
.map-warning { margin-bottom: 18px; padding: 12px; font-size: 0.9rem; background: #fff7ed; border: 2px solid #f97316; border-radius: 6px; }
.map-warning strong { display: block; font-size: 1.15rem; }
.map-warning .map-notice { margin-top: 6px; font-weight: 600; color: #c2410c; }
.map-history { padding: 6px 0; border-bottom: 1px solid #f0f0f0; }
.map-history dl { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 1px 8px; margin: 3px 0 0; }
.map-history dt { color: #6b7280; }
.map-history dd { margin: 0; overflow-wrap: break-word; }
/* The submit confirmation stays at the top of the panel while it is scrolled */
.map-confirm { position: sticky; top: 0; z-index: 5; box-shadow: 0 4px 10px rgba(0,0,0,.12); }
