/* ============================================================================
   Internal Department Chat — floating widget styles (Blueprint v1.6,
   Section 21). Namespaced entirely under .chat-* / #chat-* so it can't
   collide with any existing site CSS. Include via a single <link> in
   _Layout.cshtml — see README_Integration.md.
   ============================================================================ */

.chat-widget-root {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1080; /* above Bootstrap modals' backdrop (1050/1055) so it's always reachable */
}

.chat-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #0d6efd;
    color: #fff;
    font-size: 1.4rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-bubble:hover { filter: brightness(1.08); }

.chat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: #fff;
    border-radius: 999px;
    font-size: .7rem;
    line-height: 1;
    padding: 4px 6px;
    min-width: 18px;
    text-align: center;
}

.chat-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 340px;
    max-width: calc(100vw - 24px);
    height: 480px;
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: .75rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel-header {
    background: #0d6efd;
    color: #fff;
    padding: .6rem .75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.chat-panel-header-actions { display: flex; gap: .35rem; }

.chat-view {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: .6rem;
    overflow-y: auto;
    min-height: 0;
}

.chat-conversation-list { display: flex; flex-direction: column; gap: .25rem; }

.chat-conversation-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem;
    border-radius: .5rem;
    cursor: pointer;
}

.chat-conversation-item:hover { background: #f1f3f5; }

.chat-online-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #adb5bd;
    flex-shrink: 0;
}

.chat-online-dot.online { background: #28a745; }

.chat-conversation-item-body { flex: 1 1 auto; min-width: 0; }
.chat-conversation-item-name { font-weight: 600; font-size: .85rem; }
.chat-conversation-item-preview {
    font-size: .78rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conversation-item-badge {
    background: #dc3545;
    color: #fff;
    border-radius: 999px;
    font-size: .7rem;
    padding: 2px 6px;
}

.chat-empty-state { text-align: center; padding: 1.5rem .5rem; }

.chat-back-btn { align-self: flex-start; padding-left: 0; }

.chat-picker-users { display: flex; flex-direction: column; gap: .35rem; max-height: 220px; overflow-y: auto; }

.chat-picker-user-row { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }

.chat-message-list {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    padding: .25rem 0;
    min-height: 0;
}

.chat-message-bubble {
    max-width: 80%;
    padding: .4rem .6rem;
    border-radius: .6rem;
    font-size: .85rem;
    background: #f1f3f5;
    align-self: flex-start;
}

.chat-message-bubble.mine {
    background: #0d6efd;
    color: #fff;
    align-self: flex-end;
}

.chat-message-meta { font-size: .68rem; opacity: .7; margin-top: 2px; }

.chat-message-attachment {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .8rem;
    text-decoration: underline;
    color: #750a0a;
}

.chat-error-note {
    align-self: center;
    font-size: .75rem;
    color: #dc3545;
    background: #fdecea;
    border-radius: .4rem;
    padding: .3rem .6rem;
    text-align: center;
}

.chat-input-row { display: flex; align-items: center; gap: .4rem; padding-top: .4rem; border-top: 1px solid #eee; }

.chat-attach-btn { cursor: pointer; color: #6c757d; display: flex; align-items: center; }

@media (max-width: 420px) {
    .chat-panel { width: calc(100vw - 24px); height: calc(100vh - 100px); }
}

/* Ensure dropdowns inside floating chat widget render in front of chat panel */
.select2-container--open {
    z-index: 10000 !important;
}

#chat-picker-department {
    position: relative;
    z-index: 1085;
}
