/* ===========================================================================
 * Chatter and Supporters — the two feed modals (#viewComments, #viewLikes).
 *
 * Shared by live-feed, eng-feed, live-profile, live-profile-detail,
 * view-profile and profile-individual, all of which render them from
 * js/SocialInteractionFeed.js. That file emits Bootstrap-3 grid strings and
 * puts each comment's text in a READONLY TEXTAREA, so every comment arrived as
 * a bordered form control with its own scrollbar inside a modal barely wide
 * enough for a name.
 *
 * The markup is left alone — six pages depend on it — and restyled here, which
 * is why a few selectors reach for generated .row/.col-md-* classes rather than
 * names of their own.
 *
 * Both modals are styled together on purpose: they are the same object seen two
 * ways (who talked, who liked), and they were two different-looking dialogs.
 * =========================================================================== */

/* --- the shell, shared ---------------------------------------------------
 * Height is the fix for "the popup gets cut off". A fixed max-height on the
 * body alone does not bound the DIALOG, so on a busy thread the box grew past
 * the bottom of the screen and the last comments were unreachable. The dialog
 * is a flex column capped in viewport units: the header stays, the body takes
 * what is left and scrolls inside it, and the box can never exceed the window.
 * --------------------------------------------------------------------- */
/* The dialog is centred in the scroll container rather than given a top
   margin, so a short thread does not sit high on the screen and a long one
   cannot start above the top edge. min-height:100% + flex centring is the
   Bootstrap-3-safe way to do it — the .modal itself is the scroller. */
#viewComments .modal-dialog,
#viewLikes .modal-dialog {
    width: 520px;
    max-width: calc(100vw - 32px);
    margin: 0 auto;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4vh 0;
}
#viewLikes .modal-dialog { width: 420px; }

#viewComments .modal-content,
#viewLikes .modal-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 90vh;
    border: 0;
    border-radius: 16px;
    overflow: hidden;
    background: var(--lf-surface, #fff);
    color: var(--lf-ink, #131a18);
    box-shadow: 0 24px 60px -20px rgba(16, 23, 29, .45);
}

#viewComments .modal-header,
#viewLikes .modal-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 0;
    background: var(--lf-accent, #0c7a55);
    color: var(--lf-accent-ink, #fff);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
}
#viewComments .modal-header .close,
#viewLikes .modal-header .close {
    order: 2;                     /* the markup prints it first */
    float: none;
    margin: 0 0 0 auto;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--lf-accent-ink, #fff) 16%, transparent);
    color: var(--lf-accent-ink, #fff);
    opacity: 1;
    font-size: 19px;
    line-height: 1;
    text-shadow: none;
}
#viewComments .modal-header .close:hover,
#viewComments .modal-header .close:focus,
#viewLikes .modal-header .close:hover,
#viewLikes .modal-header .close:focus {
    background: color-mix(in srgb, var(--lf-accent-ink, #fff) 30%, transparent);
    color: var(--lf-accent-ink, #fff);
    opacity: 1;
}

/* flex: 0 1 auto, NOT 1 1 auto. Growing meant a dialog with one supporter in it
   stretched to the full capped height and left a wall of empty white under a
   single name. It shrinks when it must and never grows past its content. */
#viewComments .modal-body,
#viewLikes .modal-body {
    flex: 0 1 auto;
    min-height: 0;
    padding: 8px 20px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* --- one comment --------------------------------------------------------- */
#viewComments .view-comments > div[class^="comment-row"] {
    padding: 14px 0;
    border-bottom: 1px solid var(--lf-line-soft, #ebefed);
}
#viewComments .view-comments > div[class^="comment-row"]:last-child { border-bottom: 0; }

/* :not([hidden]) matters — getComments() gives the reply editor the classes
   "row mt-3 reply-rowN" AND the hidden attribute, and a display declaration
   beats [hidden]'s UA display:none. Without this every reply box is open from
   the moment the modal appears. */
#viewComments .view-comments .row:not([hidden]) {
    display: flex;
    align-items: flex-start;
    margin: 0;
}
#viewComments .view-comments [hidden] { display: none !important; }
#viewComments .view-comments .row > div { padding-left: 0; padding-right: 0; }

#viewComments .view-comments .row > div:first-child {
    flex: 0 0 38px; width: 38px; margin-right: 12px;
}
#viewComments .view-comments .row > div:first-child img {
    width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
    border: 1px solid var(--lf-line, #dfe5e2) !important;
}
#viewComments .view-comments .row > div:nth-child(2) {
    flex: 1 1 auto; min-width: 0; width: auto;
}

#viewComments .view-comments .cmtName {
    font-size: 14px; font-weight: 650; color: var(--lf-ink, #131a18);
}
#viewComments .view-comments small { font-size: 11.5px; color: var(--lf-ink-3, #5e6b66); }
#viewComments .view-comments .row > div:nth-child(2) > br { display: none; }
#viewComments .view-comments small:first-of-type { margin-left: 8px; }

/* --- the comment text ---------------------------------------------------- *
 * A textarea because the same element becomes the editor on Edit. Readonly it
 * should read as text; editable it should look like a field. Driven off the
 * attribute so no JS has to toggle a class.
 * ------------------------------------------------------------------------- */
#viewComments .view-comments textarea {
    display: block; width: 100%; margin: 3px 0 0; padding: 0;
    border: 0; border-radius: 8px; background: transparent; box-shadow: none;
    resize: none; overflow: hidden;
    font-size: 14px; line-height: 1.5; color: var(--lf-ink, #131a18);
    min-height: 0; height: auto;
}
#viewComments .view-comments textarea[readonly] { cursor: default; }
#viewComments .view-comments textarea:not([readonly]) {
    padding: 8px 40px 8px 12px;   /* room for the emoji trigger */
    margin-top: 6px;
    border: 1px solid var(--lf-accent-strong, #0c7a55);
    background: var(--lf-surface, #fff);
}
#viewComments .view-comments textarea:focus { outline: none; }

/* --- Edit · Delete · Reply ----------------------------------------------- *
 * These were bare 11px links separated by literal " | " characters, and because
 * Edit, Save, Delete and Cancel show and hide independently the bars were often
 * left stranded on their own. The separators are gone from the template; this
 * is a flex row with a gap, and each action is a quiet button that only shows
 * its ground on hover.
 * ------------------------------------------------------------------------- */
#viewComments .view-comments .row.text-right {
    display: flex; justify-content: flex-end; align-items: center;
    gap: 4px; margin: 8px 0 0;
}
#viewComments .view-comments .row.text-right > div {
    display: flex; justify-content: flex-end; align-items: center;
    gap: 4px; width: auto; flex: 1 1 auto;
}
#viewComments .view-comments .cmtAction {
    display: inline-flex; align-items: center;
    padding: 4px 9px; border-radius: 6px;
    font-size: 12.5px; font-weight: 600; line-height: 1.3;
    color: var(--lf-ink-3, #5e6b66) !important;
    text-decoration: none;
    transition: background-color .13s ease, color .13s ease;
}
#viewComments .view-comments .cmtAction:hover,
#viewComments .view-comments .cmtAction:focus {
    background: var(--lf-accent-bg, #e6f1ee);
    color: var(--lf-accent-strong, #0c7a55) !important;
    text-decoration: none;
}
#viewComments .view-comments .cmtAction--danger:hover,
#viewComments .view-comments .cmtAction--danger:focus {
    background: #fbe9ec;
    color: #a32639 !important;
}
/* the reply count is empty until getRepliesCount fills it in */
#viewComments .view-comments .cmtAction--count:empty { display: none; }
#viewComments .view-comments .cmtAction--count { margin-right: auto; }

/* --- replies ------------------------------------------------------------- */
#viewComments .view-comments div[class^="reply-row"],
#viewComments .view-comments .collapse {
    margin-top: 10px; padding-left: 12px;
    border-left: 2px solid var(--lf-line, #dfe5e2);
}
#viewComments .view-comments .reply-content textarea {
    padding: 8px 40px 8px 12px;   /* room for the emoji trigger on the right */
    border: 1px solid var(--lf-line, #dfe5e2);
    background: var(--lf-raise, #f1f4f3);
    border-radius: 16px;
    min-height: 38px;
}
#viewComments .view-comments .reply-content textarea:focus {
    border-color: var(--lf-accent-strong, #0c7a55);
    background: var(--lf-surface, #fff);
}

/* --- the emoji picker inside Chatter ------------------------------------- *
 * js/inputEmoji.js injects an absolutely-positioned grid. The modal body has to
 * scroll — a long thread has to go somewhere — and an absolutely-positioned
 * child of a scrolling box is clipped by it, which is why the picker came out
 * cut off here while working fine in the feed composer.
 *
 * So inside this modal it is not an overlay. Forced back into normal flow, it
 * opens as a panel directly beneath the reply field, scrolls with the thread,
 * and cannot be clipped by anything. The plugin toggles display, which still
 * works. The !importants are unavoidable: the plugin sets its geometry inline.
 * ------------------------------------------------------------------------- */
#viewComments .view-comments .reply-content,
#viewComments .view-comments .cmtEditWrap { position: relative; }
#viewComments .view-comments .cmtEditWrap { margin-top: 6px; }
#viewComments .view-comments .cmtEditWrap textarea { margin-top: 0; }

#viewComments .view-comments .emoji-icons {
    position: absolute !important;
    top: 9px !important;
    right: 12px !important;
    left: auto !important;
    float: none !important;
    margin: 0 !important;
    width: 22px; height: 22px;
    display: inline-flex !important;
    align-items: center; justify-content: center;
    font-size: 16px !important;
    line-height: 1;
    opacity: .65;
    z-index: 2;
}
#viewComments .view-comments .emoji-icons:hover { opacity: 1; }

#viewComments .view-comments div[style] {
    position: static !important;
    inset: auto !important;
    width: auto !important;
    max-width: 100% !important;
    margin: 8px 0 0 !important;
    padding: 8px !important;
    border: 1px solid var(--lf-line, #dfe5e2) !important;
    border-radius: 12px;
    box-shadow: none;
}
#viewComments .view-comments div[style] span {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 6px;
    font-size: 17px !important;
}
#viewComments .view-comments div[style] span:hover { background: var(--lf-accent-bg, #e6f1ee); }
#viewComments .view-comments div[style] br { display: none; }

/* --- Supporters ---------------------------------------------------------- *
 * getLikes() emits a .row per person with an <hr> inside it, which drew a rule
 * through the middle of each entry. Same person-row treatment as Chatter, so
 * the two modals read as one product.
 * ------------------------------------------------------------------------- */
#viewLikes .view-likes .row {
    display: flex; align-items: center; gap: 12px;
    margin: 0; padding: 10px 0;
    border-bottom: 1px solid var(--lf-line-soft, #ebefed);
}
#viewLikes .view-likes .row:last-child { border-bottom: 0; }
#viewLikes .view-likes .row > div { padding: 0; width: auto; }
#viewLikes .view-likes .row > div:first-child { flex: 0 0 34px; }
#viewLikes .view-likes .row > div:nth-child(2) { flex: 1 1 auto; min-width: 0; }
#viewLikes .view-likes img {
    width: 34px !important; height: 34px !important;
    border-radius: 50%; object-fit: cover;
    border: 1px solid var(--lf-line, #dfe5e2) !important;
}
#viewLikes .view-likes .cmtName {
    font-size: 14px; font-weight: 600;
    color: var(--lf-ink, #131a18);
}
/* the rule the markup draws through each row */
#viewLikes .view-likes hr { display: none; }

/* --- empty states -------------------------------------------------------- */
#viewComments .cmtEmpty,
#viewLikes .cmtEmpty {
    margin: 0;
    padding: 28px 8px;
    text-align: center;
    color: var(--lf-ink-3, #5e6b66);
    font-size: 14px;
    line-height: 1.5;
}
