/* Connections screens. Ported from the approved mockup (frontend/mockups/connections/mockups.css). */

/* service mark: one letter, tinted by category (lead source blue, enrichment green, system grey) */
.svc { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 24px; height: 24px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.svc-lead { background: var(--color-accent-100); color: var(--color-accent-700); }
.svc-enrich { background: var(--color-ok-100); color: var(--color-ok-700); }
.svc-system { background: var(--color-neutral-200); color: var(--color-neutral-800); }
.svc-lg { width: 36px; height: 36px; border-radius: 8px; font-size: 15px; }

/* danger tints, next to the design system's --color-danger (6.55:1 text contrast on the 100 tint) */
:root { --color-danger-100: #fdf3f4; --color-danger-300: #f1bbbc; }

/* status pills: always text plus an icon, never color alone */
.pill svg { flex: none; }
.pill-danger { border-color: var(--color-danger-300); background: var(--color-danger-100); color: var(--color-danger); }
.pill-dashed { border-style: dashed; border-color: var(--color-neutral-500); background: var(--color-surface); color: var(--color-neutral-800); font-weight: 400; }

/* connections table: one line per row */
.conn-table { table-layout: fixed; min-width: 1000px; }
.table-wrap + .hint { margin-top: var(--space-2); }
.conn-table td, .conn-table th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.conn-table td { height: 44px; padding-top: 6px; padding-bottom: 6px; }
/* Widths measured on the rendered text: at 1440 px no Connector, Scope (including "Personal (owner)"), Access or
   Last tested value clips; longer names and reasons end in "…" with the full text on hover. */
.conn-table .c-name { width: 20%; }
.conn-table .c-conn { width: 16%; }
.conn-table .c-scope { width: 14%; }
.conn-table .c-status { width: 22%; }
.conn-table .c-access { width: 8%; }
.conn-table .c-tested { width: 8%; }
.conn-table .c-act { width: 120px; text-align: right; overflow: visible; }
.name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.name-cell a { color: var(--color-text); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.name-cell a:hover { color: var(--color-accent-700); text-decoration: underline; }
.status-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.status-why { overflow: hidden; text-overflow: ellipsis; color: var(--color-neutral-700); font-size: 13px; }
.row-actions { display: inline-flex; gap: 4px; justify-content: flex-end; }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: 13px; }
.btn-icon { min-height: 28px; width: 28px; padding: 0; }
.group-row td { height: 32px; background: var(--color-neutral-100); color: var(--color-neutral-700); font-size: 12px; font-weight: 600; }

.list-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-3); }
.list-tools .search { flex: 0 1 280px; }
.list-tools .search .input { height: 30px; min-height: 30px; font-size: 13px; }
.list-count { margin-left: auto; color: var(--color-neutral-700); font-size: 13px; }

/* connector picker */
.picker-search { max-width: 360px; margin-bottom: var(--space-4); }
.picker-group { margin-bottom: var(--space-6); }
.picker-group h2 { margin: 0 0 var(--space-2); font-size: 14px; }
.picker-group h2 .muted { font-weight: 400; font-size: 13px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-2); }
.pick { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: start; padding: 12px; background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: 6px; color: var(--color-text); text-decoration: none; }
/* a card that is a link lifts on hover and on keyboard focus, so it reads as clickable */
.pick:hover, .pick:focus-visible { border-color: var(--color-accent-400); background: var(--color-accent-100); color: var(--color-text); box-shadow: var(--shadow-sm); }
.pick .svc { grid-row: span 2; }
.pick-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; }
.pick-what { color: var(--color-neutral-800); font-size: 13px; line-height: 18px; }
.pick-meta { grid-column: 2; display: flex; gap: 6px; align-items: center; margin-top: 4px; color: var(--color-neutral-700); font-size: 12px; }
.pick[aria-disabled="true"] { background: var(--color-neutral-100); color: var(--color-neutral-700); }
.pick[aria-disabled="true"]:hover { border-color: var(--color-divider); background: var(--color-neutral-100); }

/* steps of the new-connection flow (a real sequence, so numbered) */
.flow-steps { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0 0 var(--space-4); padding: 0; list-style: none; font-size: 13px; color: var(--color-neutral-700); }
.flow-steps li { display: flex; align-items: center; gap: 6px; }
.flow-steps .n { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--color-neutral-500); font-size: 12px; font-weight: 600; }
.flow-steps .done .n { background: var(--color-ok-100); border-color: var(--color-ok-300); color: var(--color-ok-700); }
.flow-steps .now { color: var(--color-text); font-weight: 600; }
.flow-steps .now .n { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }

/* connection form */
.form-split { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 340px); gap: var(--space-6); align-items: start; }
.panel { padding: var(--space-4) 20px; background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: 6px; }
.panel-title { display: flex; align-items: center; gap: 10px; margin: 0 0 var(--space-4); font-size: 16px; }
.panel .field { margin-bottom: var(--space-4); }
.field-help { margin: 4px 0 0; color: var(--color-neutral-700); font-size: 13px; line-height: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 120px; gap: var(--space-3); }
.locked { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 5px 10px; border: 1px dashed var(--color-neutral-400); border-radius: var(--radius-sm); background: var(--color-neutral-100); color: var(--color-neutral-800); font-size: 13px; overflow-wrap: anywhere; }
.locked svg { flex: none; color: var(--color-neutral-700); }
.secret-set { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-height: 32px; font-size: 14px; }
.secret-set .link-button { white-space: nowrap; }
details.advanced { margin: 0 0 var(--space-4); border-top: 1px solid var(--color-divider); padding-top: var(--space-3); }
details.advanced summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--color-neutral-800); }
details.advanced[open] summary { margin-bottom: var(--space-3); }
fieldset.choice { margin: 0 0 var(--space-4); padding: 0; border: 0; }
fieldset.choice legend { padding: 0; margin-bottom: 6px; font-size: 13px; color: var(--color-neutral-700); }
.radio-line { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--color-divider); border-radius: var(--radius-sm); margin-bottom: 6px; }
.radio-line input { margin-top: 3px; accent-color: var(--color-accent); }
.radio-line .opt { font-weight: 600; }
.radio-line .opt-what { grid-column: 2; color: var(--color-neutral-800); font-size: 13px; line-height: 18px; }
.radio-line.on { border-color: var(--color-accent-400); background: var(--color-accent-100); }

/* test result: one line, details underneath */
.test-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--color-divider); }
.test-result { margin: var(--space-3) 0 0; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; line-height: 20px; }
.test-result strong { display: inline-flex; align-items: center; gap: 6px; }
.test-ok { background: var(--color-ok-100); border: 1px solid var(--color-ok-300); color: var(--color-ok-700); }
.test-fail { background: var(--color-danger-100); border: 1px solid var(--color-danger-300); color: var(--color-danger); }
.test-result p { margin: 4px 0 0; color: var(--color-text); }
.checks-list { margin: 8px 0 0; padding: 0; list-style: none; color: var(--color-text); font-size: 13px; }
.checks-list li { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.checks-list .ok { color: var(--color-ok-700); }
.checks-list .bad { color: var(--color-danger); }
.save-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-4); }
.save-note { color: var(--color-neutral-700); font-size: 13px; }
.aside h2 { margin: 0 0 var(--space-2); font-size: 14px; }
.aside * + h2 { margin-top: var(--space-4); }
.aside p, .aside li { font-size: 13px; line-height: 19px; color: var(--color-neutral-800); }
.aside ul { margin: 0 0 var(--space-3); padding-left: 18px; }
.aside .kv { font-size: 13px; }

/* detail page */
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.detail-head h1 { display: flex; align-items: center; gap: 10px; }
.detail-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.detail-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.btn-danger-quiet { color: var(--color-danger); }
.cards-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); align-items: start; } /* each card as tall as its content */
.cards-2 .panel h2 { margin: 0 0 var(--space-3); font-size: 14px; }
.activity td { white-space: nowrap; }
.activity td.what { white-space: normal; min-width: 240px; } /* on a phone the table scrolls sideways instead of squeezing this column to a letter wide */

/* admin: new connector */
.base-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--space-2); margin-bottom: var(--space-2); }
.base-type { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; padding: 10px 12px; border: 1px solid var(--color-divider); border-radius: var(--radius-sm); background: var(--color-surface); }
.base-type input { accent-color: var(--color-accent); margin-top: 3px; }
.base-type .opt { font-weight: 600; }
.base-type .opt-what { grid-column: 2; font-size: 12px; line-height: 16px; color: var(--color-neutral-700); }
.base-type.on { border-color: var(--color-accent-400); background: var(--color-accent-100); }
.form-section { margin-bottom: var(--space-6); }
.form-section > h2 { margin: 0 0 var(--space-1); font-size: 16px; }
.form-section > .field-help { margin: 0 0 var(--space-3); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-4); }
.fields-table td, .fields-table th { vertical-align: middle; }
.fields-table input[type="checkbox"] { accent-color: var(--color-accent); width: 15px; height: 15px; }
.icon-pick { display: flex; align-items: center; gap: var(--space-3); }


@media (max-width: 900px) {
  .form-split, .cards-2, .grid-2 { grid-template-columns: 1fr; }
  .list-count { margin-left: 0; }
}

.field-label-static { display: block; font-size: 13px; margin-bottom: 4px; color: var(--color-neutral-700); }

/* admin connectors table: seven columns (Connector, Type, Category, Who can connect, Used by, Status, Updated).
   Updated is a short date (the full time is its hover text). At the 1000 px minimum no value clips. */
.cx-table { min-width: 1000px; }
.cx-table th:nth-child(1) { width: 21%; }
.cx-table th:nth-child(2) { width: 19%; }
.cx-table th:nth-child(3) { width: 11%; }
.cx-table th:nth-child(4) { width: 17%; }
.cx-table th:nth-child(5) { width: 10%; }
.cx-table th:nth-child(6) { width: 11%; }
.cx-table th:nth-child(7) { width: 11%; }

/* Live screens: additions to the mockup styles */
.base-type:has(input:checked), .radio-line:has(input:checked) { border-color: var(--color-accent-400); background: var(--color-accent-100); }
.list-slot + .hint { margin-top: var(--space-2); } /* the table sits inside .list-slot, so .table-wrap + .hint does not match */
.other-services { margin-top: var(--space-6); }
.other-services > summary { cursor: pointer; font-weight: 600; margin-bottom: var(--space-2); }
.extra-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto auto; gap: var(--space-2); align-items: end; margin-bottom: var(--space-3); }
.extra-row > label:not(.extra-cell) { display: flex; align-items: center; gap: var(--space-1); min-height: 32px; } /* Required, level with the boxes */
.extra-cell { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.extra-label { font-size: 13px; color: var(--color-neutral-700); }
@media (max-width: 600px) { .extra-row { grid-template-columns: 1fr; } }
/* details page: Delete sits after a divider, apart from the everyday actions */
.action-sep { align-self: stretch; width: 1px; margin: 4px var(--space-1); background: var(--color-neutral-400); }

/* admin connector editor: short fields in pairs (as in the mockup) and a readable width */
.cx-form { max-width: 960px; }
.grid-2 > .span-2 { grid-column: 1 / -1; }

/* Phones. The two tables scroll sideways inside their box (never the page); the name column stays pinned so each
   row keeps its name while Status and the button scroll into view. Column widths are set in px so nothing clips. */
@media (max-width: 600px) {
  .conn-table { width: 1068px; min-width: 1068px; }
  .conn-table .c-name { width: 170px; }
  .conn-table .c-conn { width: 184px; }
  .conn-table .c-scope { width: 160px; }
  .conn-table .c-status { width: 250px; }
  .conn-table .c-access { width: 92px; }
  .conn-table .c-tested { width: 92px; }
  .conn-table .c-act { width: 120px; }
  .cx-table { width: 970px; min-width: 970px; }
  .cx-table th:nth-child(1) { width: 170px; }
  .cx-table th:nth-child(2) { width: 190px; }
  .cx-table th:nth-child(3) { width: 110px; }
  .cx-table th:nth-child(4) { width: 170px; }
  .cx-table th:nth-child(5) { width: 100px; }
  .cx-table th:nth-child(6) { width: 120px; }
  .cx-table th:nth-child(7) { width: 110px; }
  .conn-table tr:not(.group-row) > :first-child { position: sticky; left: 0; z-index: 1; background: var(--color-surface); box-shadow: inset -1px 0 0 var(--color-divider); }
  .conn-table thead tr > :first-child { z-index: 2; background: var(--color-neutral-100); }
  .conn-table tbody tr:not(.group-row):hover > :first-child { background: var(--color-bg); }
  .conn-table .group-row td { overflow: visible; }  /* a clipping cell would hold the label still instead of the table box */
  .group-row td > span { position: sticky; left: 12px; }
  .conn-table td { height: 56px; }  /* every row as tall as one with a 44 px button */
  /* touch: the compact row buttons and filters grow to 44 px */
  .conn-table .btn-sm { min-height: 44px; padding: 0 14px; }
  .list-tools .search .input, .list-tools .flt .input { height: 44px; min-height: 44px; }
  /* Activity: When and Who wrap, so all three columns fit and nothing hides behind a sideways swipe */
  .activity td { white-space: normal; }
  .activity td.what { min-width: 0; }
}

/* a field the last Test or Save named as wrong (aria-invalid), until the person changes a value */
.form-split .input[aria-invalid="true"] { border-color: var(--color-danger); box-shadow: inset 0 -1px 0 var(--color-danger); }
/* a finished step of the new-connection flow links back to it */
.flow-steps .done a { color: var(--color-accent-700); }
.save-bar .save-note:empty { display: none; }

/* details page: the callout spans the content width (lined up with the cards) and leads with an icon */
.detail-callout { display: flex; align-items: flex-start; gap: var(--space-2); max-width: none; }
.detail-callout svg { flex: none; margin-top: 2px; }
/* a note under a button bar sits a step below it, not against it */
.save-bar + .save-note { margin-top: var(--space-2); }
/* a text button at the start of a section lines its text up with the fields above it */
.form-section > .btn-ghost { margin-left: calc(-1 * var(--space-2)); }
@media (max-width: 600px) { .extra-row .btn-ghost { justify-self: start; margin-left: calc(-1 * var(--space-2)); } }
