/* Messaging inbox slide-out panel (message-bar) + topbar unread badge.
   Parallels the Hyper theme's .right-bar (280px Tasks panel) but 2x wide and
   driven by its own body class (message-bar-enabled) so the theme JS in
   app.min.js never touches it.

   Loaded on BOTH themes:
     - Hyper/BS4 pages: hyper/header_ng2.php
     - Classic BS3 timesheet pages: timesheet/headernew.php
   So everything the panel needs is defined here (title bar, spacing, badge)
   rather than borrowed from either theme's utility classes. */

.message-bar {
    background-color: #fff;
    box-shadow: 0 0 24px 0 rgba(0, 0, 0, 0.1), 0 1px 0 0 rgba(0, 0, 0, 0.08);
    display: block;
    position: fixed;
    top: 0;
    bottom: 0;
    width: 560px;
    right: -575px;
    transition: all 200ms ease-out;
    z-index: 9999;
    text-align: left;
}

.message-bar-enabled .message-bar {
    right: 0;
}

.messagebar-overlay {
    background-color: rgba(49, 58, 70, 0.4);
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    display: none;
    z-index: 9998;
    transition: all 0.2s ease-out;
}

.message-bar-enabled .messagebar-overlay {
    display: block;
}

/* Title bar — self-styled (matches the Hyper rightbar-title look, but must
   also render on BS3 pages that have no such class). */
.he-msgbar-title {
    background-color: #313a46;
    color: #fff;
    padding: 12px 25px;
}

/* px (not rem) throughout: BS3 pages set html{font-size:10px}, so rem
   sizes render ~62% smaller there than on Hyper/BS4 pages. */
.he-msgbar-title h5 {
    color: #fff;
    margin: 0;
    font-size: 16px;
}

.he-msgbar-close {
    float: right;
    color: #fff;
    font-size: 16px;
    line-height: 1.2;
}

.he-msgbar-close:hover,
.he-msgbar-close:focus {
    color: #ddd;
    text-decoration: none;
}

.messagebar-content {
    height: calc(100% - 46px);
    overflow-y: auto;
}

@media (max-width: 767.98px) {
    .message-bar {
        width: 100vw;
        right: -100vw;
    }
}

/* Numeric unread badge on the topbar envelope icon. Text + visibility are
   set imperatively by heMessages (he-messages.v1.js); markup ships with
   style="display:none". Positioned relative to the toggle link itself so it
   works in both the Hyper navbar and the BS3 timesheet navbar. */
.message-bar-toggle {
    position: relative;
}

.he-msg-badge {
    position: absolute;
    top: 12px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background-color: #fa5c7c;
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    font-weight: 700;
}

/* --- Panel-local utility classes (neither BS3 nor BS4 assumed) --- */
.he-msg-pad  { padding: 10px 12px; }
.he-msg-bb   { border-bottom: 1px solid #eef2f7; }
.he-msg-bt   { border-top: 1px solid #eef2f7; }
.he-msg-mt   { margin-top: 6px; }
.he-msg-mb   { margin-bottom: 6px; }
.he-msg-ml   { margin-left: 8px; }
.he-msg-m0   { margin: 0; }

.he-msg-row {
    display: flex;
    justify-content: space-between;
}

.he-msg-check {
    font-weight: normal;
    cursor: pointer;
    margin-bottom: 0;
}

.he-msg-check input[type="checkbox"] {
    vertical-align: middle;
    margin: 0 3px 2px 0;
}

/* --- Thread list --- */
.he-msg-thread-row {
    display: block;
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f7;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
}

.he-msg-thread-row:hover {
    background-color: #f6f7fb;
    color: inherit;
    text-decoration: none;
}

.he-msg-thread-row.he-msg-unread .he-msg-subject,
.he-msg-thread-row.he-msg-unread .he-msg-preview {
    font-weight: 700;
}

.he-msg-subject {
    font-size: 15px;
}

.he-msg-preview {
    color: #98a6ad;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 420px;
}

.he-msg-meta {
    color: #98a6ad;
    font-size: 12px;
}

/* per-thread unread count pill in the list (topbar badge is .he-msg-badge) */
.he-msg-count {
    float: right;
    min-width: 16px;
    padding: 0 5px;
    border-radius: 8px;
    background-color: #fa5c7c;
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    font-weight: 700;
}

.he-msg-patient-chip {
    display: inline-block;
    background-color: #eef2f7;
    color: #6c757d;
    border-radius: 10px;
    padding: 0 8px;
    font-size: 12px;
    line-height: 18px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    margin-right: 4px;
}

a.he-msg-patient-chip:hover {
    text-decoration: none;
    background-color: #dfe5ec;
}

/* --- Thread view / message bubbles --- */
.he-msg-bubble {
    background-color: #f1f3fa;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 10px;
    max-width: 85%;
}

.he-msg-bubble.he-msg-mine {
    background-color: #d9e8ff;
    margin-left: auto;
}

.he-msg-bubble-body {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 14px;
}

.he-msg-seenby {
    color: #98a6ad;
    font-size: 11px;
    margin-top: 2px;
}

.he-msg-thread-header {
    border-bottom: 1px solid #eef2f7;
    padding: 8px 12px;
}

/* --- Compose / pickers --- */
.he-msg-picker-list {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px 0;
    background-color: #fff;
}

/* own item styling: BS3 has no .dropdown-item */
.he-msg-pick {
    display: block;
    padding: 4px 12px;
    cursor: pointer;
    color: #333;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.he-msg-pick:hover {
    background-color: #f6f7fb;
    text-decoration: none;
    color: #333;
}
