/* Nav bar Chat link — override jive.css a:link color #3778c7 */
li#jive-nav-link-chat a,
li#jive-nav-link-chat a:link,
li#jive-nav-link-chat a:visited,
li#jive-nav-link-chat a:active,
li#jive-nav-link-chat .nav-link,
li#jive-nav-link-chat .j-navLabel {
    color: #fff !important;
    text-decoration: none !important;
    opacity: 1 !important;
}

li#jive-nav-link-chat a:hover,
li#jive-nav-link-chat a:hover .nav-link,
li#jive-nav-link-chat a:hover .j-navLabel {
    color: #fff !important;
    opacity: 0.85 !important;
}

li#jive-nav-link-chat .jive-icon-glyph {
    color: #fff !important;
}

/* Navbar unread badge — LinkedIn-style overlay counter */
li#jive-nav-link-chat {
    position: relative !important;
}

.chat-nav-unread-badge {
    position: absolute;
    top: 2px;
    right: -4px;
    background: #cc1016;
    color: #fff;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: bold;
    line-height: 18px;
    text-align: center;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 1;
}

.chat-layout {
    display: flex;
    height: calc(100vh - 120px);
    border: 1px solid #ddd;
    background: #fff;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.chat-sidebar {
    width: 320px;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
}

.chat-sidebar-header {
    padding: 12px;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 8px;
}

.chat-sidebar-header input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#chat-conversation-list {
    flex: 1;
    overflow-y: auto;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid #ddd;
    font-weight: bold;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
}

#chat-compose {
    padding: 12px;
    border-top: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#chat-compose textarea {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: none;
    min-height: 40px;
}

.chat-security-banner {
    background: #fff3cd;
    color: #856404;
    padding: 8px 16px;
    border-bottom: 1px solid #ffc107;
    font-size: 13px;
    text-align: center;
}

/* Conversation list items */
.chat-conv-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-conv-item:hover {
    background: #f5f5f5;
}

.chat-conv-item.active {
    background: #e6eef7;
}

.chat-conv-name {
    font-weight: 600;
    font-size: 14px;
}

.chat-conv-preview {
    color: #666;
    font-size: 12px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.chat-conv-time {
    color: #999;
    font-size: 11px;
}

.chat-unread-badge {
    background: #3778c7;
    color: #fff;
    border-radius: 10px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: bold;
}

/* Message bubbles */
.chat-msg {
    margin-bottom: 12px;
    max-width: 70%;
}

.chat-msg.sent {
    margin-left: auto;
}

.chat-msg-sender {
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
}

.chat-msg-body {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-msg.received .chat-msg-body {
    background: #f0f0f0;
}

.chat-msg.sent .chat-msg-body {
    background: #3778c7;
    color: #fff;
}

.chat-msg-time {
    font-size: 10px;
    color: #999;
    margin-top: 2px;
}

.chat-msg.sent .chat-msg-time {
    text-align: right;
}

/* Read receipt ticks */
.chat-msg-tick {
    font-size: 12px;
    margin-left: 4px;
}

.chat-tick-sent {
    color: #999;
}

.chat-tick-delivered {
    color: #999;
}

.chat-tick-read {
    color: #53bdeb;
}

.chat-typing-indicator {
    color: #666;
    font-style: italic;
    font-size: 12px;
    padding: 4px 16px;
}

/* Empty state */
.chat-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 14px;
}

/* Error message */
.chat-msg-error {
    color: #d32f2f;
    font-size: 12px;
    padding: 4px 16px;
    text-align: center;
}

/* Edited label */
.chat-msg-edited {
    font-size: 10px;
    color: #999;
    font-style: italic;
}

/* Header */
.chat-header-name {
    font-size: 16px;
    font-weight: 600;
}

.chat-header-subtitle {
    font-size: 12px;
    color: #666;
    font-weight: normal;
}

/* New Chat Modal */
.chat-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-modal {
    background: #fff;
    border-radius: 8px;
    width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.chat-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.chat-modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.chat-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
}

.chat-modal-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
}

.chat-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    color: #666;
}

.chat-tab.active {
    color: #3778c7;
    border-bottom-color: #3778c7;
}

.chat-modal-body {
    padding: 16px 20px;
    flex: 1;
    overflow-y: auto;
}

.chat-modal-body input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.chat-user-results,
.chat-user-results-group {
    max-height: 200px;
    overflow-y: auto;
}

.chat-user-result {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-user-result:hover {
    background: #f5f5f5;
}

.chat-user-result.selected {
    background: #e6eef7;
}

.chat-user-name {
    font-weight: 500;
    font-size: 14px;
}

.chat-user-username {
    color: #999;
    font-size: 12px;
}

.chat-selected-users {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.chat-user-chip {
    background: #e6eef7;
    color: #3778c7;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.chat-chip-remove {
    cursor: pointer;
    font-weight: bold;
}

.chat-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #eee;
    text-align: right;
}

.chat-create-btn {
    min-width: 100px;
}

/* ==================== Attachments ==================== */

.chat-compose-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-attach-btn {
    font-size: 22px;
    cursor: pointer;
    padding: 6px 8px;
    user-select: none;
    color: #555;
}
.chat-attach-btn:hover { color: #222; }

.chat-attach-preview {
    display: none;
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}
.chat-attach-chip {
    display: inline-block;
    background: #e8eef5;
    border-radius: 12px;
    padding: 2px 10px;
    margin: 2px 4px 2px 0;
    font-size: 12px;
}
.chat-attach-chip-size { color: #777; margin-left: 4px; }
.chat-attach-chip-remove { cursor: pointer; margin-left: 6px; color: #c44; font-weight: bold; }

.chat-msg-attachments {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}
.chat-attach-image-link { display: block; cursor: pointer; }
.chat-attach-error { color: #c44; font-size: 12px; font-style: italic; }
.chat-attach-image {
    max-width: 260px;
    max-height: 260px;
    border-radius: 6px;
    display: block;
}
.chat-attach-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.06);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    max-width: 320px;
}
.chat-msg.sent .chat-attach-file { background: rgba(255,255,255,0.2); }
.chat-attach-file-icon { font-size: 20px; }
.chat-attach-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attach-file-size { color: #777; font-size: 11px; }
.chat-msg.sent .chat-attach-file-size { color: rgba(255,255,255,0.7); }
