/* =================================================================
   CONTACT Elements — App Shell + shared template primitives
   Used by Class Page.html and Object Page.html.
   Builds on colors_and_type.css (link that first).
   ================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
body.ce-shell {
  margin: 0;
  font-family: var(--ce-font-sans);
  font-size: var(--ce-text-sm);
  color: var(--ce-fg-default);
  background: var(--ce-bg-app);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---------- CIS icon sizing ---------- */
.ce-icon   { width: 16px; height: 16px; fill: currentColor; vertical-align: middle; flex-shrink: 0; display: block; }
.ce-icon-md{ width: 24px; height: 24px; }
.ce-icon-lg{ width: 32px; height: 32px; }

/* =================================================================
   App layout grid: title bar (top) + rail (left) + content (fill)
   ================================================================= */
.app {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: 48px 1fr;
  grid-template-areas:
    "title  title"
    "rail   main";
  height: 100vh;
  width: 100vw;
}

/* ---------- Title bar ---------- */
.titlebar {
  grid-area: title;
  display: flex;
  align-items: center;
  gap: var(--ce-space-3);
  height: 48px;
  padding: 0 var(--ce-space-4) 0 var(--ce-space-3);
  background: var(--ce-gray-0);
  border-bottom: 1px solid var(--ce-border-subtle);
}
.titlebar .logo { display: flex; align-items: center; }
.titlebar .logo svg { width: 30px; height: 30px; display: block; }
.titlebar .product {
  font-size: var(--ce-text-2xl);
  font-weight: 400;
  color: var(--ce-blue-500);
  letter-spacing: -0.005em;
  line-height: 1;
}
.titlebar .search-group {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--ce-space-3);
}
.titlebar .search-label {
  font-size: var(--ce-text-base);
  color: var(--ce-fg-default);
}
.titlebar .ent-search {
  display: flex;
  align-items: center;
  gap: var(--ce-space-2);
  width: 340px;
  height: 30px;
  padding: 0 var(--ce-space-3);
  background: var(--ce-gray-0);
  border: 1px solid var(--ce-gray-600);
  border-radius: var(--ce-radius-xs);
  color: var(--ce-fg-subtle);
}
.titlebar .ent-search svg { width: 14px; height: 14px; fill: var(--ce-fg-subtle); }
.titlebar .ent-search input {
  flex: 1; min-width: 0;
  border: 0; outline: none; background: transparent;
  font: inherit; font-size: var(--ce-text-sm); color: var(--ce-fg-default);
}
.titlebar .tb-actions {
  display: flex; align-items: center; gap: var(--ce-space-5);
  color: var(--ce-blue-500);
}
.titlebar .tb-actions button {
  appearance: none; border: 0; background: transparent; padding: 0;
  color: inherit; cursor: pointer; display: flex; align-items: center;
}
.titlebar .tb-actions svg { width: 18px; height: 18px; fill: currentColor; }
.titlebar .avatar {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ce-blue-100);
  color: var(--ce-blue-700);
  font-weight: 600; font-size: var(--ce-text-base);
  border-radius: var(--ce-radius-xs);
}

/* ---------- Left app rail (collapsed icon rail) ---------- */
.rail {
  grid-area: rail;
  background: #0F6AAA;
  color: #fff;
  display: flex;
  flex-direction: column;
  width: 48px;
  user-select: none;
}
.rail-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rail-item > a {
  display: flex; align-items: center; justify-content: center;
  height: 44px; color: #fff; cursor: pointer; text-decoration: none;
}
.rail-item > a svg { width: 20px; height: 20px; fill: currentColor; }
.rail-item > a:hover { background: #0C5A93; }
.rail-item.is-active > a { background: #0B4F82; }
.rail-sep { height: 1px; background: #003C63; margin: 6px 0; }
.rail-spacer { flex: 1; }
.rail-foot > a {
  display: flex; align-items: center; justify-content: center;
  height: 44px; color: #fff; cursor: pointer;
}
.rail-foot > a svg { width: 20px; height: 20px; fill: currentColor; }
.rail-foot > a:hover { background: #0C5A93; }
.rail-toggle {
  display: flex; align-items: center; justify-content: center;
  height: 44px; cursor: pointer; border-top: 1px solid #003C63;
}
.rail-toggle svg { width: 20px; height: 20px; fill: #fff; }
.rail-toggle:hover { background: #0C5A93; }

/* ---------- Main content region ---------- */
.main {
  grid-area: main;
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--ce-gray-0);
  overflow: hidden;
}

/* =================================================================
   Reusable primitives
   ================================================================= */

/* ---------- Buttons ---------- */
.btn {
  appearance: none; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--ce-space-2);
  height: 32px; padding: 0 var(--ce-space-3);
  font-size: var(--ce-text-sm); font-weight: 600; line-height: 1;
  border-radius: var(--ce-radius-sm);
  border: 1px solid var(--ce-gray-600);
  background: var(--ce-gray-0); color: var(--ce-fg-default);
  white-space: nowrap;
  transition: background var(--ce-dur-fast) var(--ce-ease), border-color var(--ce-dur-fast) var(--ce-ease);
}
.btn svg { width: 14px; height: 14px; fill: currentColor; }
.btn:hover { background: var(--ce-gray-50); }
.btn:active { background: var(--ce-gray-100); }
.btn--primary {
  background: var(--ce-blue-500); border-color: var(--ce-blue-500); color: #fff;
}
.btn--primary:hover { background: var(--ce-blue-600); border-color: var(--ce-blue-600); }
.btn--primary:active { background: var(--ce-blue-700); border-color: var(--ce-blue-700); }
.btn:focus-visible { outline: 2px solid rgba(0,118,197,.30); outline-offset: 1px; }

/* Icon-only button (tertiary / chrome) */
.ibtn {
  appearance: none; cursor: pointer;
  width: 28px; height: 28px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--ce-radius-sm);
  background: transparent; color: var(--ce-gray-500);
}
.ibtn svg { width: 15px; height: 15px; fill: currentColor; }
.ibtn:hover { background: var(--ce-gray-50); color: var(--ce-gray-600); }
.ibtn:active { background: var(--ce-gray-100); color: var(--ce-gray-800); }
.ibtn:focus-visible { outline: 2px solid rgba(0,118,197,.30); outline-offset: 0; }

/* Outline icon button (sits inside inputs / toolbars with a hairline) */
.ibtn--outline { border-color: var(--ce-gray-600); color: var(--ce-blue-500); }
.ibtn--outline:hover { background: var(--ce-blue-50); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: var(--ce-space-1); }
.field > label {
  font-size: var(--ce-text-sm); color: var(--ce-fg-default); line-height: 1.2;
}
.field .req { color: var(--ce-danger-fg); }
.input, .select {
  height: 32px; width: 100%;
  padding: 0 var(--ce-space-3);
  font: inherit; font-size: var(--ce-text-sm); color: var(--ce-fg-default);
  background: var(--ce-gray-0);
  border: 1px solid var(--ce-gray-600);
  border-radius: var(--ce-radius-xs);
}
.input::placeholder { color: var(--ce-fg-subtle); }
.input:focus, .select:focus { outline: 2px solid rgba(0,118,197,.30); outline-offset: 0; border-color: var(--ce-blue-500); }
/* Input with a trailing affix button group */
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .affix {
  display: flex; align-items: center; justify-content: center;
  width: 32px; border: 1px solid var(--ce-gray-600); border-left: 0;
  background: var(--ce-gray-50); color: var(--ce-blue-500); cursor: pointer;
  border-radius: 0;
}
.input-group .affix:last-child { border-top-right-radius: var(--ce-radius-xs); border-bottom-right-radius: var(--ce-radius-xs); }
.input-group .affix svg { width: 15px; height: 15px; fill: currentColor; }
.input-group .affix:hover { background: var(--ce-gray-100); }

.checkrow { display: flex; align-items: center; gap: var(--ce-space-2); font-size: var(--ce-text-sm); }
.checkrow input { width: 15px; height: 15px; margin: 0; accent-color: var(--ce-blue-500); }

/* ---------- Status dot ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.dot--draft   { background: var(--ce-danger-fg); }
.dot--review  { background: var(--ce-warning-fg); }
.dot--released{ background: var(--ce-success-fg); }
.dot--info    { background: var(--ce-info-fg); }

/* ---------- Sub action / quick-filter tab strip ---------- */
.quickbar {
  display: flex; align-items: stretch; gap: var(--ce-space-1);
  padding: 0 var(--ce-space-5);
  border-bottom: 1px solid var(--ce-border-subtle);
  background: var(--ce-gray-0);
}
.quick {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 var(--ce-space-3);
  font-size: var(--ce-text-sm); color: var(--ce-fg-default);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
  cursor: pointer; opacity: .8; background: transparent; border-top: 0; border-left: 0; border-right: 0;
  font-family: inherit;
}
.quick svg { width: 15px; height: 15px; fill: var(--ce-blue-500); }
.quick:hover { opacity: 1; border-bottom-color: var(--ce-blue-500); }
.quick.is-active { opacity: 1; font-weight: 600; border-bottom-color: var(--ce-blue-500); }

/* ---------- Tab bar (object content) ---------- */
.tabbar {
  position: relative;
  display: flex; align-items: stretch;
  background: var(--ce-gray-0);
  border-bottom: 1px solid var(--ce-border-subtle);
  font-size: var(--ce-text-sm);
  padding: 0 var(--ce-space-5);
  user-select: none;
}
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 var(--ce-space-3); height: 40px;
  cursor: pointer; color: var(--ce-fg-default);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
  white-space: nowrap; opacity: .8;
  background: transparent; border-top: 0; border-left: 0; border-right: 0;
  font-family: inherit; font-size: var(--ce-text-sm);
}
.tab svg { width: 16px; height: 16px; fill: var(--ce-blue-500); }
.tab:hover { opacity: 1; border-bottom-color: var(--ce-blue-500); }
.tab.is-active { opacity: 1; font-weight: 600; border-bottom-color: var(--ce-blue-500); }
.tab:focus-visible { outline: 2px solid rgba(0,118,197,.30); outline-offset: -2px; }

/* ---------- Table (condensed object list) ---------- */
.tbl-wrap { overflow: auto; min-height: 0; flex: 1; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 13px; }
table.tbl th {
  position: sticky; top: 0; z-index: 1;
  background: var(--ce-gray-0);
  text-align: left; font-weight: 700; font-size: 12px; color: var(--ce-fg-default);
  padding: 0 var(--ce-space-3); height: 30px; white-space: nowrap;
  border-bottom: 1px solid var(--ce-border-subtle);
  border-right: 1px solid var(--ce-border-subtle);
}
table.tbl th:last-child { border-right: none; }
table.tbl td {
  padding: 0 var(--ce-space-3); height: 30px; white-space: nowrap;
  border-bottom: 1px solid var(--ce-border-subtle);
  overflow: hidden; text-overflow: ellipsis;
}
table.tbl tbody tr:nth-child(odd) td { background: var(--ce-gray-50); }
table.tbl tbody tr:nth-child(even) td { background: var(--ce-gray-0); }
table.tbl tbody tr:hover td { background: #EFEFEF; }
table.tbl tbody tr.selected td,
table.tbl tbody tr.selected:hover td { background: var(--ce-blue-50); }
table.tbl .col-check { width: 32px; text-align: center; padding: 0; }
table.tbl .col-check input { margin: 0; accent-color: var(--ce-blue-500); cursor: pointer; }
table.tbl .col-icon { width: 30px; text-align: center; padding: 0; color: var(--ce-product-elements); }
table.tbl .col-icon svg { width: 15px; height: 15px; fill: currentColor; }
table.tbl .cell-link { color: var(--ce-fg-link); cursor: pointer; }
table.tbl .cell-link:hover { text-decoration: underline; }

/* "Drag column headers here to group" rail */
.groupbar {
  display: flex; align-items: center; justify-content: center; gap: var(--ce-space-2);
  height: 34px; margin: var(--ce-space-3) 0;
  border: 1px dashed var(--ce-gray-300); border-radius: var(--ce-radius-xs);
  color: var(--ce-fg-subtle); font-size: var(--ce-text-sm);
}
.groupbar svg { width: 15px; height: 15px; fill: currentColor; }

/* ---------- Striped image placeholder ---------- */
.img-ph {
  position: relative;
  background-color: var(--ce-gray-50);
  background-image: repeating-linear-gradient(
    -45deg, transparent, transparent 9px,
    rgba(0,118,197,.07) 9px, rgba(0,118,197,.07) 18px);
  border: 1px solid var(--ce-border-subtle);
  border-radius: var(--ce-radius-xs);
  display: flex; align-items: center; justify-content: center;
}
.img-ph .ph-label {
  font-family: var(--ce-font-mono); font-size: 11px; letter-spacing: .04em;
  color: var(--ce-fg-subtle); text-transform: uppercase;
  background: var(--ce-gray-0); padding: 3px 8px; border: 1px solid var(--ce-border-subtle);
  border-radius: var(--ce-radius-xs);
}

/* ---------- Splitter resizer (vertical) ---------- */
.sp-resizer {
  position: relative; flex: 0 0 7px; width: 7px;
  background: transparent; cursor: col-resize; user-select: none;
  display: flex; align-items: center; justify-content: center;
}
.sp-resizer::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
  width: 1px; transform: translateX(-50%); background: var(--ce-border-subtle);
}
.sp-grip {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 2px 2px; grid-auto-rows: 2px; gap: 2px;
  padding: 3px 4px; background: var(--ce-gray-0); opacity: 0;
  transition: opacity 120ms var(--ce-ease);
}
.sp-grip span { display: block; width: 2px; height: 2px; border-radius: 50%; background: var(--ce-gray-600); }
.sp-resizer:hover .sp-grip, .sp-resizer.is-dragging .sp-grip { opacity: 1; }
.sp-resizer:hover::before, .sp-resizer.is-dragging::before { background: var(--ce-gray-600); }

/* Collapsed splitter rail */
.sp-resizer.is-collapsed { flex: 0 0 28px; width: 28px; cursor: pointer; padding: 8px 0; }
.sp-resizer.is-collapsed .sp-grip { display: none; }
.sp-resizer.is-collapsed .sp-pill {
  flex: 1; align-self: stretch; display: flex; align-items: center; justify-content: center;
  margin-left: 8px; background: var(--ce-gray-50); border-radius: var(--ce-radius-sm);
}
.sp-resizer.is-collapsed:hover .sp-pill { background: var(--ce-gray-100); }
.sp-resizer .sp-pill { display: none; }
.sp-resizer.is-collapsed .sp-label {
  writing-mode: vertical-rl; font-size: var(--ce-text-sm); color: var(--ce-fg-default); white-space: nowrap;
}
/* Collapse to the right */
.sp-resizer.is-collapsed.dir-right::before { left: auto; right: 0; }
.sp-resizer.is-collapsed.dir-right .sp-pill { margin-left: 0; margin-right: 8px; }
.sp-resizer.is-collapsed.dir-right .sp-label { transform: rotate(180deg); }

/* ---------- Content block ---------- */
.cb { display: flex; flex-direction: column; border-bottom: 1px solid var(--ce-border-subtle); }
.cb-header { display: flex; align-items: center; gap: 6px; padding: var(--ce-space-2) 0; user-select: none; }
.cb-toggle {
  appearance: none; background: transparent; border: 0; padding: 0; margin: 0;
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ce-fg-default); cursor: pointer; border-radius: 2px; flex: 0 0 auto;
}
.cb-toggle:hover { background: var(--ce-gray-50); }
.cb-toggle svg { width: 10px; height: 10px; fill: currentColor; transition: transform 160ms var(--ce-ease); }
.cb.is-collapsed .cb-toggle svg { transform: rotate(-90deg); }
.cb-icon { width: 16px; height: 16px; display: inline-flex; color: var(--ce-product-elements); flex: 0 0 auto; }
.cb-icon svg { width: 16px; height: 16px; fill: currentColor; }
.cb-title { font-weight: 600; font-size: var(--ce-text-base); line-height: 1.2; margin: 0; flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-body { padding: var(--ce-space-2) 0 var(--ce-space-3) 24px; font-size: var(--ce-text-sm); line-height: 1.5; }
.cb.is-collapsed .cb-body { display: none; }

/* ---------- Attribute definition grid (header meta / properties) ---------- */
.attr-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--ce-space-4); align-items: baseline; }
.attr-grid dt { color: var(--ce-fg-muted); font-size: var(--ce-text-sm); }
.attr-grid dd { margin: 0; color: var(--ce-fg-default); font-size: var(--ce-text-sm); }
.attr-grid dd a { color: var(--ce-fg-link); text-decoration: none; }
.attr-grid dd a:hover { text-decoration: underline; }

/* ---------- Thumbnail tile ---------- */
.thumb {
  width: 56px; height: 56px; flex: 0 0 56px;
  border: 1px solid var(--ce-border-subtle); border-radius: var(--ce-radius-xs);
  display: flex; align-items: center; justify-content: center;
  color: var(--ce-product-elements);
  background-color: var(--ce-gray-50);
  background-image: repeating-linear-gradient(-45deg, transparent, transparent 6px, rgba(0,118,197,.07) 6px, rgba(0,118,197,.07) 12px);
}
.thumb svg { width: 26px; height: 26px; fill: currentColor; }

/* ---------- Page header (object + class pages share the rhythm) ---------- */
.page-head { display: flex; align-items: flex-start; gap: var(--ce-space-4); padding: var(--ce-space-4) var(--ce-space-5) var(--ce-space-3); }
.page-title { font-size: var(--ce-text-3xl); font-weight: 700; color: var(--ce-fg-heading); margin: 0; line-height: 1.1; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: var(--ce-space-2); }

/* dropzone affordance */
.dropzone {
  display: flex; align-items: center; gap: var(--ce-space-2);
  height: 32px; padding: 0 var(--ce-space-4);
  border: 1px dashed var(--ce-gray-300); border-radius: var(--ce-radius-sm);
  color: var(--ce-fg-subtle); font-size: var(--ce-text-sm);
}
.dropzone svg { width: 15px; height: 15px; fill: currentColor; }

/* utility */
.muted { color: var(--ce-fg-muted); }
.eyebrow { font-size: var(--ce-text-xs); color: var(--ce-fg-muted); letter-spacing: .02em; }
.scrolly { overflow: auto; min-height: 0; }
