/* Calendar, push notifications, private messages and LTI pages. */

/* ---------- Top bar ---------- */
.msgbadge { position: relative; text-decoration: none; }
.msgbadge__count {
    position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: #dc2626; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; border: 2px solid var(--surface);
}

.pushprompt {
    position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    max-width: min(460px, calc(100vw - 32px)); padding: 14px 16px; background: var(--surface); border: 1px solid var(--line);
    border-radius: 14px; box-shadow: 0 18px 50px rgba(17, 17, 40, .18);
}
.pushprompt__ico { font-size: 22px; }
.pushprompt__body { display: flex; flex-direction: column; gap: 2px; flex: 1 1 200px; font-size: 13.5px; }

/* ---------- Profile ---------- */
.comms__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.comms__url { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.comms__cats { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: grid; gap: 6px; margin-top: 8px; }
.comms__cats legend { font-weight: 700; font-size: 13px; padding: 0 4px; }

/* ---------- Admin ---------- */
.comms__tool { margin-bottom: 16px; }
.comms__config { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0 0; }
.comms__config dt { font-weight: 600; font-size: 13px; }
.comms__config dd { margin: 0; overflow-wrap: anywhere; }
.comms__reason { margin: 8px 0; white-space: pre-wrap; }
.comms__note { max-width: 260px; }
.comms__thread { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 8px; font-size: 13.5px; white-space: pre-wrap; }

/* ---------- Messages page ---------- */
.msgpage {
    display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 0; height: calc(100vh - 140px); min-height: 480px;
    max-width: 1200px; margin: 20px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
}
.msgpage__list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.msgpage__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px; border-bottom: 1px solid var(--line); }
.msgpage__head h1 { font-size: 20px; }
.msgpage__compose { padding: 12px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.msgpage__list .empty, .msgpage__list .cgrid-loading { padding: 24px 16px; }

.msglist { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; }
.msglist__item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; text-decoration: none; color: inherit; }
.msglist__item:hover { background: var(--surface-2); }
.msglist__item--active { background: var(--tint-brand); }
.msglist__item--unread .msglist__name, .msglist__item--unread .msglist__preview { font-weight: 700; color: var(--ink); }
.msglist__body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.msglist__top { display: flex; justify-content: space-between; gap: 8px; }
.msglist__name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msglist__time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.msglist__ctx { color: var(--brand-ink); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msglist__preview { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msglist__count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--brand); color: var(--brand-fg); font-size: 12px; font-weight: 700; display: grid; place-items: center; }

.msgavatar {
    width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; background: var(--tint-brand); color: var(--brand-ink);
    display: grid; place-items: center; font-weight: 700; font-size: 13px;
}

.msgpage__thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.msgthread__placeholder { margin: auto; text-align: center; color: var(--muted); padding: 24px; }
.msgthread__placeholder span { font-size: 40px; display: block; margin-bottom: 8px; }
.msgthread__head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.msgthread__back { display: none; }
.msgthread__who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.msgthread__name { font-size: 16px; }
.msgthread__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.msgthread__report { padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--tint-warn); }
.msgthread__messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.msgthread__more { align-self: center; }
.msgthread__hello { margin: auto; color: var(--muted); }
.msgthread__closed { padding: 14px 16px; border-top: 1px solid var(--line); color: var(--muted); margin: 0; }

.msgbubble {
    align-self: flex-start; max-width: min(560px, 80%); padding: 9px 12px; border-radius: 14px 14px 14px 4px;
    background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px;
}
.msgbubble--mine { align-self: flex-end; background: var(--brand); color: var(--brand-fg); border-color: var(--brand); border-radius: 14px 14px 4px 14px; }
.msgbubble__text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.msgbubble__time { font-size: 11px; opacity: .75; }
.msgbubble__img { max-width: 260px; max-height: 260px; border-radius: 8px; display: block; }
.msgbubble__file { color: inherit; font-weight: 600; }

.msgcomposer { border-top: 1px solid var(--line); padding: 10px 16px; display: grid; gap: 8px; background: var(--surface); }
.msgcomposer__text { resize: vertical; min-height: 54px; }
.msgcomposer__bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.msgcomposer__spacer { flex: 1; }
.msgcomposer__attach { position: relative; overflow: hidden; cursor: pointer; max-width: 260px; white-space: nowrap; text-overflow: ellipsis; }
.msgcomposer__file { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

@media (max-width: 760px) {
    .msgpage { grid-template-columns: 1fr; margin: 0; border-radius: 0; border-left: 0; border-right: 0; height: calc(100vh - 120px); }
    .msgpage--thread .msgpage__list { display: none; }
    .msgpage--list .msgpage__thread { display: none; }
    .msgpage__list { border-right: 0; }
    .msgthread__back { display: inline-flex; }
    .msgbubble { max-width: 90%; }
}

/* ---------- LTI pages (inside a learning platform's frame) ---------- */
body.lti {
    margin: 0; padding: 24px 16px; background: #f5f5f9; color: #16161f;
    font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}
.lti__card { max-width: 640px; margin: 0 auto; background: #fff; border: 1px solid #ececf1; border-radius: 14px; padding: 24px; }
.lti__title { font-size: 20px; margin: 0 0 12px; }
.lti__text { margin: 0 0 12px; line-height: 1.5; }
.lti__btn {
    display: inline-block; padding: 10px 18px; border: 0; border-radius: 10px; background: #4b4fe0; color: #fff;
    font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer;
}
.lti__list { border: 1px solid #ececf1; border-radius: 10px; padding: 8px 12px; margin: 0 0 16px; display: grid; gap: 6px; max-height: 50vh; overflow-y: auto; }
.lti__option { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; }
.lti__option small { color: #5b6270; }
