/* ── Header notification bell ── */

.bps-chat-bell {
    position: relative;
    background: none;
    border: none;
    color: #6c757d;
    font-size: 1.15rem;
    padding: .35rem;
    cursor: pointer;
    transition: color .15s;
    line-height: 1;
}

.bps-chat-bell:hover {
    color: #212529;
}

.bps-chat-bell-badge {
    position: absolute;
    top: 0;
    right: -2px;
    background: #0d6efd;
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    min-width: 1rem;
    height: 1rem;
    line-height: 1rem;
    border-radius: 999px;
    text-align: center;
    padding: 0 .25rem;
    display: none;
}

/* ── Dropdown de notificações ── */

.bps-notif-dropdown {
    z-index: 1090;
    max-height: min(70vh, 420px);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .18);
    border-radius: .75rem;
    background: #fff;
    border: 1px solid #e9ecef;
}

.bps-notif-dropdown[hidden] {
    display: none !important;
}

.bps-notif-dropdown-inner {
    display: flex;
    flex-direction: column;
    max-height: inherit;
}

.bps-notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .65rem .85rem;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.bps-notif-dropdown-title {
    font-weight: 600;
    font-size: .9rem;
}

.bps-notif-mark-all {
    background: none;
    border: none;
    color: #0d6efd;
    font-size: .72rem;
    cursor: pointer;
    padding: .2rem 0;
    white-space: nowrap;
}

.bps-notif-mark-all:hover {
    text-decoration: underline;
}

.bps-notif-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.bps-notif-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    color: #adb5bd;
    font-size: .85rem;
}

.bps-notif-item {
    display: flex;
    gap: .65rem;
    padding: .65rem .85rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background .12s;
}

.bps-notif-item:hover {
    background: #f8f9fa;
}

.bps-notif-item-unread {
    background: #f0f7ff;
}

.bps-notif-item-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #495057;
    font-size: .9rem;
}

.bps-notif-item-body {
    min-width: 0;
    flex: 1;
}

.bps-notif-item-title {
    font-weight: 600;
    font-size: .82rem;
    margin-bottom: .15rem;
}

.bps-notif-item-preview {
    font-size: .75rem;
    color: #6c757d;
    line-height: 1.35;
    word-break: break-word;
}

.bps-notif-item-meta {
    font-size: .65rem;
    color: #adb5bd;
    margin-top: .25rem;
}

.bps-notif-item-unread .bps-notif-item-title::before {
    content: '';
    display: inline-block;
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: #0d6efd;
    margin-right: .35rem;
    vertical-align: middle;
}

/* ── Chat widget (floating) ── */

#bps-chat-root {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 1080;
    font-family: inherit;
}

/* ── FAB (floating action button) ── */

.bps-chat-fab {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    background: #212529;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
    transition: transform .15s ease, box-shadow .15s ease;
    z-index: 1081;
}

.bps-chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}

.bps-chat-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #dc3545;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    min-width: 1.15rem;
    height: 1.15rem;
    line-height: 1.15rem;
    border-radius: 999px;
    text-align: center;
    padding: 0 .3rem;
}

/* ── Panel container ── */

.bps-chat-panel {
    position: fixed;
    bottom: 5rem;
    right: 1.25rem;
    width: 360px;
    max-width: calc(100vw - 1.5rem);
    height: 480px;
    max-height: calc(100vh - 7rem);
    background: #fff;
    border-radius: .75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1081;
    opacity: 0;
    transform: translateY(12px) scale(.96);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

.bps-chat-panel.bps-chat-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ── */

.bps-chat-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    background: #212529;
    color: #fff;
    flex-shrink: 0;
}

.bps-chat-header-title {
    flex: 1;
    font-weight: 600;
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bps-chat-header-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, .7);
    cursor: pointer;
    font-size: .85rem;
    padding: .25rem;
    line-height: 1;
    transition: color .15s;
}

.bps-chat-header-btn:hover {
    color: #fff;
}

a.bps-chat-header-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Página dedicada (/painel/mensagens.php) ── */

.bps-chat-page-wrap {
    width: 100%;
    min-height: 0;
}

#bps-chat-root.bps-chat-root--page,
#bps-chat-root[data-layout='page'] {
    position: relative;
    z-index: 1;
    width: 100%;
    min-height: min(72vh, 680px);
}

#bps-chat-root.bps-chat-root--page .bps-chat-fab,
#bps-chat-root[data-layout='page'] .bps-chat-fab {
    display: none !important;
}

#bps-chat-root.bps-chat-root--page .bps-chat-panel,
#bps-chat-root[data-layout='page'] .bps-chat-panel {
    position: relative;
    inset: auto;
    bottom: auto;
    right: auto;
    left: auto;
    width: 100%;
    max-width: 100%;
    height: min(76vh, 720px);
    max-height: 82vh;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    box-shadow: 0 4px 28px rgba(0, 0, 0, .12);
}

#bps-chat-root.bps-chat-root--page .bps-chat-panel.bps-chat-open,
#bps-chat-root[data-layout='page'] .bps-chat-panel.bps-chat-open {
    opacity: 1;
    transform: none;
}

/* Duas colunas: lista à esquerda, conversa à direita */
#bps-chat-root[data-layout='page'] .bps-chat-panel--page,
#bps-chat-root.bps-chat-root--page .bps-chat-panel--page {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bps-chat-page-split {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.bps-chat-page-sidebar {
    width: min(32vw, 300px);
    min-width: 240px;
    max-width: 320px;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
}

.bps-chat-page-sidebar .bps-chat-list-toolbar {
    flex-shrink: 0;
}

.bps-chat-page-sidebar .bps-chat-conv-list {
    flex: 1;
    min-height: 0;
}

.bps-chat-page-sidebar .bps-chat-staff-picker {
    flex: 1;
    min-height: 0;
}

.bps-chat-page-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #f8f9fa;
}

.bps-chat-page-thread-head {
    flex-shrink: 0;
    padding: .65rem 1rem;
    background: #212529;
    color: #fff;
    font-size: .88rem;
    font-weight: 600;
}

.bps-chat-page-thread-title {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bps-chat-page-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    min-height: 8rem;
}

.bps-chat-page-empty-text {
    margin: 0;
    color: #adb5bd;
    font-size: .88rem;
    text-align: center;
    max-width: 16rem;
    line-height: 1.45;
}

#bps-chat-root[data-layout='page'] .bps-chat-panel--page .bps-chat-messages,
#bps-chat-root.bps-chat-root--page .bps-chat-panel--page .bps-chat-messages {
    flex: 1;
    min-height: 0;
    background: #fff;
}

#bps-chat-root[data-layout='page'] .bps-chat-panel--page .bps-chat-input-area,
#bps-chat-root.bps-chat-root--page .bps-chat-panel--page .bps-chat-input-area {
    flex-shrink: 0;
    background: #fff;
}

.bps-chat-conv-item-active {
    background: #e8f2ff !important;
    box-shadow: inset 3px 0 0 #0d6efd;
}

.bps-chat-conv-item-active:hover {
    background: #d9e8ff !important;
}

/* ── Conversation list (staff only) ── */

.bps-chat-conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    list-style: none;
}

.bps-chat-conv-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background .12s;
}

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

.bps-chat-conv-avatar {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: #212529;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.bps-chat-conv-info {
    flex: 1;
    min-width: 0;
}

.bps-chat-conv-name {
    font-weight: 600;
    font-size: .85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bps-chat-conv-preview {
    font-size: .75rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bps-chat-conv-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .25rem;
    flex-shrink: 0;
}

.bps-chat-conv-time {
    font-size: .65rem;
    color: #adb5bd;
}

.bps-chat-conv-unread {
    background: #dc3545;
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    min-width: 1.1rem;
    height: 1.1rem;
    line-height: 1.1rem;
    border-radius: 999px;
    text-align: center;
    padding: 0 .25rem;
}

.bps-chat-conv-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: #adb5bd;
    font-size: .85rem;
}

/* ── Lista: abas, busca, nova conversa, seletor de equipe ── */

.bps-chat-list-toolbar {
    flex-shrink: 0;
    border-bottom: 1px solid #e9ecef;
    background: #fff;
}

.bps-chat-tabs {
    display: flex;
    gap: 0;
    padding: .35rem .5rem 0;
}

.bps-chat-tab {
    flex: 1;
    border: none;
    background: #f1f3f5;
    color: #495057;
    font-size: .78rem;
    font-weight: 600;
    padding: .45rem .5rem;
    cursor: pointer;
    border-radius: .5rem .5rem 0 0;
    transition: background .12s, color .12s;
}

.bps-chat-tab:hover {
    color: #212529;
}

.bps-chat-tab-active {
    background: #212529;
    color: #fff;
}

.bps-chat-search-row {
    padding: .4rem .65rem .35rem;
}

.bps-chat-search-input {
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: .5rem;
    padding: .35rem .55rem;
    font-size: .8rem;
    outline: none;
    font-family: inherit;
}

.bps-chat-search-input:focus {
    border-color: #212529;
}

.bps-chat-new-conv-row {
    padding: 0 .65rem .5rem;
}

.bps-chat-new-conv-btn {
    width: 100%;
    border: 1px dashed #adb5bd;
    background: #fff;
    color: #495057;
    font-size: .78rem;
    font-weight: 600;
    padding: .4rem;
    border-radius: .5rem;
    cursor: pointer;
    transition: border-color .12s, background .12s;
}

.bps-chat-new-conv-btn:hover {
    border-color: #212529;
    background: #f8f9fa;
}

.bps-chat-staff-picker {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.bps-chat-staff-picker-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.bps-chat-staff-picker-title {
    font-weight: 600;
    font-size: .85rem;
}

.bps-chat-staff-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

/* ── Messages area ── */

.bps-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: .75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.bps-chat-msg {
    max-width: 82%;
    padding: .5rem .75rem;
    border-radius: 1rem;
    font-size: .84rem;
    line-height: 1.4;
    word-break: break-word;
    position: relative;
}

.bps-chat-msg-out {
    align-self: flex-end;
    background: #212529;
    color: #fff;
    border-bottom-right-radius: .25rem;
}

.bps-chat-msg-in {
    align-self: flex-start;
    background: #f0f0f0;
    color: #212529;
    border-bottom-left-radius: .25rem;
}

.bps-chat-msg-sender {
    font-size: .7rem;
    font-weight: 600;
    margin-bottom: .15rem;
    opacity: .7;
}

.bps-chat-msg-time {
    font-size: .6rem;
    opacity: .5;
    margin-top: .2rem;
    text-align: right;
}

.bps-chat-date-sep {
    text-align: center;
    font-size: .65rem;
    color: #adb5bd;
    padding: .5rem 0;
    letter-spacing: .03em;
}

.bps-chat-load-more {
    text-align: center;
    padding: .25rem 0 .5rem;
}

.bps-chat-load-more button {
    background: none;
    border: none;
    color: #6c757d;
    font-size: .75rem;
    cursor: pointer;
    text-decoration: underline;
}

.bps-chat-load-more button:hover {
    color: #212529;
}

/* ── Input area ── */

.bps-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: .5rem;
    padding: .5rem .75rem;
    border-top: 1px solid #e9ecef;
    background: #fff;
    flex-shrink: 0;
}

.bps-chat-input-area textarea {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: .5rem;
    padding: .4rem .6rem;
    font-size: .84rem;
    resize: none;
    max-height: 5rem;
    min-height: 2.2rem;
    line-height: 1.4;
    outline: none;
    transition: border-color .15s;
    font-family: inherit;
}

.bps-chat-input-area textarea:focus {
    border-color: #212529;
}

.bps-chat-send-btn {
    background: #212529;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 2.2rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s;
    font-size: .85rem;
}

.bps-chat-send-btn:hover {
    background: #000;
}

.bps-chat-send-btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

/* ── Responsive (small screens) ── */

@media (max-width: 480px) {
    .bps-chat-panel {
        right: 0;
        bottom: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .bps-chat-fab {
        bottom: 1rem;
        right: 1rem;
    }
}

@media (max-width: 991.98px) {
    #bps-chat-root[data-layout='page'] .bps-chat-panel,
    #bps-chat-root.bps-chat-root--page .bps-chat-panel {
        height: calc(100dvh - 7.5rem);
        max-height: none;
        min-height: 26rem;
    }

    .bps-chat-page-split {
        display: block;
    }

    .bps-chat-page-sidebar {
        width: 100%;
        min-width: 0;
        max-width: none;
        border-right: 0;
        border-bottom: 1px solid #e9ecef;
        height: 100%;
    }

    .bps-chat-page-main {
        height: 100%;
    }

    /* Mobile-first no layout de página: lista ou conversa (evita tela esmagada). */
    #bps-chat-root[data-layout='page'] .bps-chat-panel.bps-chat-page-list-mode .bps-chat-page-main,
    #bps-chat-root.bps-chat-root--page .bps-chat-panel.bps-chat-page-list-mode .bps-chat-page-main {
        display: none;
    }

    #bps-chat-root[data-layout='page'] .bps-chat-panel.bps-chat-page-chat-mode .bps-chat-page-sidebar,
    #bps-chat-root.bps-chat-root--page .bps-chat-panel.bps-chat-page-chat-mode .bps-chat-page-sidebar {
        display: none;
    }

    .bps-chat-page-thread-head {
        padding: .75rem .9rem;
    }

    .bps-chat-msg {
        max-width: 92%;
    }

    .bps-chat-page-sidebar .bps-chat-conv-item {
        padding: .8rem .9rem;
    }

    .bps-chat-page-sidebar .bps-chat-conv-name {
        font-size: .9rem;
    }

    .bps-chat-page-sidebar .bps-chat-conv-preview {
        font-size: .8rem;
    }

    #bps-chat-root[data-layout='page'] .bps-chat-page-main .bps-chat-messages,
    #bps-chat-root.bps-chat-root--page .bps-chat-page-main .bps-chat-messages {
        padding: .65rem .75rem;
        gap: .45rem;
    }

    #bps-chat-root[data-layout='page'] .bps-chat-page-main .bps-chat-input-area,
    #bps-chat-root.bps-chat-root--page .bps-chat-page-main .bps-chat-input-area {
        padding: .6rem .65rem max(.6rem, env(safe-area-inset-bottom));
        gap: .55rem;
    }

    #bps-chat-root[data-layout='page'] .bps-chat-page-main .bps-chat-input-area textarea,
    #bps-chat-root.bps-chat-root--page .bps-chat-page-main .bps-chat-input-area textarea {
        min-height: 2.6rem;
        max-height: 7rem;
        padding: .55rem .7rem;
        font-size: .95rem;
        line-height: 1.35;
    }

    #bps-chat-root[data-layout='page'] .bps-chat-page-main .bps-chat-send-btn,
    #bps-chat-root.bps-chat-root--page .bps-chat-page-main .bps-chat-send-btn {
        width: 2.6rem;
        height: 2.6rem;
        min-width: 2.6rem;
        font-size: 1rem;
    }

    #bps-chat-root[data-layout='page'] .bps-chat-header .bps-chat-header-btn,
    #bps-chat-root.bps-chat-root--page .bps-chat-header .bps-chat-header-btn {
        min-width: 2rem;
        min-height: 2rem;
    }
}
