/* =============================================================================
   JES CRM · detail.css — the record page: record header, tabs, Summary, Updates,
   comments, documents, notifications, access info (static/js/ui/detail-view.js,
   tabs.js, summary.js, record-header.js, history-panel.js, comments-panel.js,
   documents-panel.js, notifications-panel.js, access-info.js).
   Owner: the "detail" builder of the vtiger-look wave (02-ui-contract.md §a.5, §e).
   Every value comes from tokens.css; the few pixel sizes are vtiger v7's
   (skins/vtiger/style.less: .record-header, .related-tabs, .numberCircle,
   .summaryWidgetContainer, .updates_timeline, .commentDetails).
   The blocks themselves (Details tab, Key Fields, header fields) are blocks.css.
   ============================================================================= */

/* ---------- tabs (tabs.js; Settings use the text tabs too) ---------- */
.tabs__bar { display: flex; align-items: stretch; margin-bottom: var(--space-3); border-bottom: 1px solid var(--color-border-light); }
.tabs__strip { display: flex; flex: 1; flex-wrap: wrap; align-items: stretch; min-width: 0; }
/* a strip on its own (the dashboard's links) draws the line itself */
:not(.tabs__bar) > .tabs__strip { margin-bottom: var(--space-3); border-bottom: 1px solid var(--color-border-light); }
.tabs__tab {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 15px; border: 0; border-bottom: 3px solid transparent; background: transparent;
  color: var(--color-text-muted); font-family: var(--font-family); font-size: var(--font-size-btn);
  white-space: nowrap; cursor: pointer;
}
.tabs__tab:hover { color: var(--color-text); }
.tabs__tab[aria-selected="true"] { border-bottom-color: var(--color-tab-active); color: var(--color-text); font-weight: var(--font-weight-semibold); }
.tabs__tab:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: -2px; }
/* the dashboard's strip is made of links, one address per dashboard */
a.tabs__tab { text-decoration: none; }
.tabs__tab[aria-current="page"] { border-bottom-color: var(--color-tab-active); color: var(--color-text); font-weight: var(--font-weight-semibold); }
/* vtiger's related tabs: an icon 90 px wide, the count beside it, the name as tooltip */
.tabs__tab--icon { width: 90px; padding-left: 0; padding-right: 0; color: var(--color-title); }
.tabs__tab--icon .fa, .tabs__tab--icon [class^="vicon-"] { font-size: 20px; }
.tabs__tab--icon .custom-module { font-size: 10px; }
.tabs__count {
  display: inline-block; min-width: 19px; min-height: 19px; padding: 2px;
  border-radius: var(--radius-sm); background: var(--color-count-bg); color: var(--color-count-text);
  font-size: 10px; font-weight: normal; line-height: 15px; text-align: center;
}
/* More ▾ at the end of the strip */
.tabs__more { position: relative; display: flex; }
.tabs__more-toggle { color: var(--color-text-muted); }
.tabs__more-toggle.is-current { border-bottom-color: var(--color-tab-active); color: var(--color-text); }
.tabs__more-menu {
  position: absolute; top: 100%; right: 0; z-index: 30; min-width: 200px; padding: 5px 0;
  border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface);
  box-shadow: var(--shadow-dropdown);
}
.tabs__more-menu[hidden] { display: none; }
.tabs__tab--in-more {
  display: flex; width: 100%; justify-content: flex-start; gap: var(--space-2);
  padding: 4px 20px; border-bottom: 0; color: var(--color-text); text-align: left;
}
.tabs__tab--in-more:hover, .tabs__tab--in-more:focus-visible { background: var(--color-surface-hover); }
.tabs__tab--in-more[aria-selected="true"] { background: var(--color-surface-hover); }
.tabs__tab--in-more.tabs__tab--icon { width: 100%; }
.tabs__tab--in-more .fa, .tabs__tab--in-more [class^="vicon-"] { width: 20px; font-size: 14px; text-align: center; color: var(--color-title); }
.tabs__label { flex: 1; }

/* ---------- the record page ---------- */
.detail { display: flex; flex-direction: column; }
.warnings { margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-3) var(--space-2) var(--space-6); border: 1px solid var(--color-warning); border-radius: var(--radius-sm); background: var(--color-surface); }
.detail__banner:empty { display: none; }
.detail__banner { margin-bottom: var(--space-3); }
.tabs--record > .tabs__bar { margin-bottom: 0; padding-left: 10px; background: var(--color-surface); }
.tabs--record > .tabs__panel { padding: 10px; background: var(--color-surface-alt); }
.detail__two-col { gap: 10px; }
.detail__side-panel { margin-bottom: 0; }

/* ---------- record header (record-header.js; vtiger .record-header) ---------- */
.record-header { display: flex; align-items: flex-start; gap: 10px; min-height: var(--record-icon-size); padding: 0 0 15px; }
.record-header__icon {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: var(--record-icon-size); height: var(--record-icon-size);
  background: var(--color-app); color: var(--color-app-text); font-size: var(--record-icon-font);
}
.record-header__icon .fa, .record-header__icon [class^="vicon-"] { font-size: var(--record-icon-font); }
.record-header__icon .custom-module { background: transparent; font-size: 28px; }
.record-header__icon--photo { overflow: hidden; border: 1px solid var(--color-border-light); background: var(--color-surface); }
.record-header__photo { display: block; width: 100%; height: 100%; object-fit: cover; }
.record-header__icon--missing { border: 1px dashed var(--color-border); background: var(--color-surface); color: var(--color-text-muted); }
.record-header__info { flex: 1; min-width: 0; }
.record-header__title {
  margin: 0 0 4px; overflow: hidden; color: var(--color-text); font-size: var(--font-size-xl); font-weight: normal;
  line-height: 25px; text-overflow: ellipsis; white-space: nowrap;
}
.record-header__fields { margin-bottom: 4px; color: var(--color-text-muted); }
.record-header__field { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-header__strip { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.record-header__strip > * { margin: 0; }
.record-header__buttons { flex: none; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-end; gap: 10px; padding-top: 5px; }
.record-nav .btn { min-width: var(--control-height); }

/* ---------- Summary tab (summary.js; vtiger .summaryWidgetContainer) ---------- */
.summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 10px; align-items: start; }
.summary__left, .summary__right { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.summary-widget { padding: 15px; border: 1px solid var(--color-border-light); background: var(--color-surface); }
.summary-widget__header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: 8px; }
.summary-widget__title { flex: 1; margin: 0; color: var(--color-text); font-size: var(--font-size-block); font-weight: normal; }
.summary-widget__buttons { display: flex; flex-wrap: wrap; gap: var(--space-1); }
/* vtiger's .noContent box: "No Related Documents", "No pending activities", "No comments" */
.summary-widget .state { padding: 10px; border: 1px solid var(--color-border-light); }
.activities { margin: 0; padding: 0; list-style: none; }
.activities__item { display: flex; align-items: center; gap: var(--space-2); padding: 6px 0; border-bottom: 1px solid var(--color-border-light); }
.activities__icon { width: 20px; color: var(--color-title); text-align: center; }
.activities__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activities__when { color: var(--color-text-muted); font-size: var(--font-size-sm); }
.activities__more { display: inline-block; margin-top: 6px; }

/* ---------- Updates (history-panel.js; vtiger .updates_timeline) ---------- */
.history-panel { padding: 20px 20px 1px; border: 1px solid var(--color-border-light); background: var(--color-surface); }
.history-panel--compact { padding: 0; border: 0; }
.history { position: relative; margin: 0; padding: 0; list-style: none; }
/* the line: under the round markers (time 17 % · gap 12 px · half a 35 px marker) */
.history::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(17% + 28px); width: 4px; background: var(--color-surface-alt); }
.history__entry { position: relative; display: grid; grid-template-columns: 17% 35px minmax(0, 1fr); column-gap: 12px; align-items: start; min-height: 40px; padding-bottom: 10px; }
.history__time { padding: 5px; color: var(--color-text-muted); font-size: var(--font-size-md); font-style: italic; text-align: right; }
.history__icon {
  z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 35px; height: 35px;
  border-radius: 50%; background: var(--color-app); color: var(--color-app-text);
}
.history__entry--create .history__icon { background: var(--color-success-bg); }
.history__entry--delete .history__icon { background: var(--color-danger); }
.history__info { min-width: 0; padding-top: 6px; }
.history__head { margin: 0 0 4px; color: var(--color-text); font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); }
.history__actor { color: var(--color-link); }
.history__source { color: var(--color-text-muted); font-weight: normal; }
.history__changes { margin: 0 0 0 15px; padding: 0; list-style: none; }
.history__change { margin-bottom: 5px; overflow-wrap: anywhere; }
.history__label { color: var(--color-link); font-weight: var(--font-weight-semibold); }
.history__word { color: var(--color-link); }
.history__old, .history__new { color: var(--color-text-strong); font-style: italic; white-space: pre-line; }
del.history__old { text-decoration: line-through; }
.history__reason { margin-top: var(--space-1); color: var(--color-text-muted); font-style: italic; }
.history__more { position: relative; z-index: 1; margin-left: calc(17% - 8px); padding-bottom: 10px; list-style: none; }
.history__more-button.btn { border-color: var(--color-rail); background: var(--color-rail); color: var(--color-rail-text); }
.history__more-button.btn:hover { border-color: var(--color-rail-hover); background: var(--color-rail-hover); color: var(--color-rail-text); }
.history-panel--compact .history::before { left: calc(25% + 28px); }
.history-panel--compact .history__entry { grid-template-columns: 25% 35px minmax(0, 1fr); }
.history-panel--compact .history__more { margin-left: calc(25% - 8px); }

/* ---------- comments panel (vtiger .commentDetails, the Comments widget) ---------- */
.comments__form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.comments textarea {
  width: 100%; min-height: 73px; padding: var(--control-padding); resize: vertical;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-family: var(--font-family); font-size: var(--font-size-btn);
}
.comments__bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
/* the file input stays focusable; its label is the blue "Attach Files" button */
.comments__files-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.comments__files-input:focus-visible + .comments__attach { outline: 2px solid var(--color-focus-ring); outline-offset: 1px; }
.comments__attach.btn { border-color: var(--color-primary-border); background: var(--color-primary); color: var(--color-primary-text); }
.comments__chosen { color: var(--color-text-muted); font-size: var(--font-size-sm); }
.comments__spacer { flex: 1; }
.comments__heading { margin: 0 0 8px; color: var(--color-text); font-size: var(--font-size-block); font-weight: normal; }
.comments__list { margin: 0; padding: 0; list-style: none; }
.comment { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--color-border-light); }
.comment--reply { margin-left: 50px; }
.comment__avatar {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: 50%; background: var(--color-custom-module); color: var(--color-app-text);
}
.comment__content { flex: 1; min-width: 0; }
.comment__meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); color: var(--color-text-muted); font-size: var(--font-size-sm); }
.comment__author { color: var(--color-link); font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); }
.comment__body { margin: var(--space-1) 0; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment__files { margin: var(--space-1) 0; padding: 0; list-style: none; font-size: var(--font-size-sm); }
.comment__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.comment__actions .btn--link { padding: 0; font-size: var(--font-size-sm); }
.comments__all { margin-top: 6px; }

/* ---------- documents panel ---------- */
.docs__drop {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: 10px; padding: 10px 15px;
  border: 1px dashed var(--color-border); background: var(--color-surface);
}
.docs__drop.is-over { border-color: var(--color-primary); background: var(--color-surface-hover); }
.docs__hint { color: var(--color-text-muted); }
.docs__scroll { position: relative; overflow-x: auto; border: 1px solid var(--color-border-light); background: var(--color-surface); }
.docs__table { width: 100%; border-collapse: collapse; }
.docs__table th { padding: var(--list-head-padding); border-bottom: 1px solid var(--color-border); color: var(--color-text); font-size: var(--font-size-btn); font-weight: var(--font-weight-semibold); text-align: left; white-space: nowrap; }
.docs__table td { padding: var(--list-cell-padding); border-top: 1px solid var(--color-border); color: var(--color-text-strong); text-align: left; vertical-align: middle; }
.docs__table .is-number { text-align: right; }
.docs__missing { color: var(--color-danger); font-size: var(--font-size-sm); }
.docs__preview { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; }
/* the Documents widget of the Summary tab */
.docs__list { margin: 0; padding: 0; list-style: none; }
.docs__item { display: flex; align-items: baseline; gap: var(--space-2); padding: 5px 0; border-bottom: 1px solid var(--color-border-light); }
.docs__item-icon { color: var(--color-title); }
.docs__item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs__item-meta { color: var(--color-text-muted); font-size: var(--font-size-sm); white-space: nowrap; }
.docs__more { margin-top: 6px; }

/* ---------- notifications panel ---------- */
.mails { margin-bottom: 10px; border: 1px solid var(--color-border-light); background: var(--color-surface); }
.mails > summary { padding: 10px 15px; color: var(--color-title); font-size: var(--font-size-btn); font-weight: var(--font-weight-semibold); cursor: pointer; }
.mails__scroll { position: relative; overflow-x: auto; }
.mails__table { width: 100%; border-collapse: collapse; }
.mails__table th { padding: var(--list-head-padding); border-top: 1px solid var(--color-border); color: var(--color-text); font-size: var(--font-size-btn); font-weight: var(--font-weight-semibold); text-align: left; }
.mails__table td { padding: var(--list-cell-padding); border-top: 1px solid var(--color-border); color: var(--color-text-strong); text-align: left; vertical-align: top; }
/* the Activities widget of the Summary tab when it holds the mails */
.mails__list { margin: 0; padding: 0; list-style: none; }
.mails__item { display: flex; align-items: baseline; gap: var(--space-2); padding: 5px 0; border-bottom: 1px solid var(--color-border-light); }
.mails__item-icon { color: var(--color-title); }
.mails__item-subject { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mails__item-meta { color: var(--color-text-muted); font-size: var(--font-size-sm); white-space: nowrap; }
.mails__more { margin-top: 6px; }

/* ---------- access info (the Members tab: "Who can see this record") ---------- */
.access__box { margin-top: 10px; }
.access { padding: 0 15px 10px; }
.access__everyone { margin: 0 0 var(--space-2); }
.access__title { margin: 10px 0 4px; color: var(--color-title); font-size: var(--font-size-btn); font-weight: var(--font-weight-semibold); }
.access__list { margin: 0; padding-left: 20px; }
.access__why { color: var(--color-text-muted); font-size: var(--font-size-sm); }

/* ---------- narrow screens ---------- */
@media (max-width: 991px) {
  .summary { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .record-header { flex-wrap: wrap; }
  .record-header__buttons { width: 100%; justify-content: flex-start; }
  .tabs__tab--icon { width: 56px; }
  .history::before { left: 16px; }
  .history__entry { grid-template-columns: 35px minmax(0, 1fr); }
  .history__icon { grid-column: 1; grid-row: 1 / span 2; }
  .history__time { grid-column: 2; grid-row: 1; padding: 0; text-align: left; }
  .history__info { grid-column: 2; grid-row: 2; padding-top: 0; }
  .history__more, .history-panel--compact .history__more { margin-left: 0; }
  .history-panel--compact .history::before { left: 16px; }
  .history-panel--compact .history__entry { grid-template-columns: 35px minmax(0, 1fr); }
  .comment--reply { margin-left: 20px; }
}

/* ---------- print: the record without its buttons and tab strip ---------- */
@media print {
  .tabs__bar, .record-header__buttons, .comments__form, .docs__drop { display: none; }
}
