.floating-chat {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1050;
    font-family: inherit;
}

.floating-chat-button {
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--dynamic-primary, #17a2b8);
    box-shadow: 0 14px 34px rgba(15, 23, 42, .28);
    font-size: 1.35rem;
}

.floating-chat-button:hover {
    background: var(--dynamic-primary-hover, #1491a5);
}

.floating-chat-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 21px;
    height: 21px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border-radius: 999px;
    background: #dc3545;
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
    border: 2px solid #fff;
}

.floating-chat-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: min(420px, 25vw);
    height: min(680px, 72vh);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .1);
    box-shadow: 0 22px 54px rgba(15, 23, 42, .24);
}

.floating-chat-panel.d-none {
    display: none !important;
}

.floating-chat-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #fff;
    background: var(--dynamic-primary, #17a2b8);
}

.floating-chat-back,
.floating-chat-close,
.floating-chat-full {
    border: 0;
    background: transparent;
    color: #fff;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.floating-chat-back:hover,
.floating-chat-close:hover,
.floating-chat-full:hover {
    background: rgba(255, 255, 255, .18);
}

.floating-chat-title {
    min-width: 0;
}

.floating-chat-title strong,
.floating-chat-title small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.floating-chat-title small {
    opacity: .85;
    font-size: .76rem;
}

.floating-chat-body {
    min-height: 0;
    overflow: hidden;
    display: grid;
    background: #f4f8fb;
}

.floating-chat-body > section {
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.floating-chat-body > section.d-none {
    display: none !important;
}

[data-floating-chat-rooms-view] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

[data-floating-chat-messages-view] {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
}

.floating-chat-rooms,
.floating-chat-messages {
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.floating-chat-load-older {
    display: block;
    margin: 6px auto 12px;
    border: 1px solid rgba(23, 162, 184, .25);
    border-radius: 999px;
    padding: 5px 12px;
    color: var(--dynamic-primary, #17a2b8);
    background: rgba(23, 162, 184, .08);
    font-size: .78rem;
    font-weight: 700;
}

.floating-chat-search {
    padding: 9px;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, .07);
}

.floating-chat-search input {
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: .86rem;
}

.floating-room {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 9px;
    width: 100%;
    border: 0;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    padding: 10px;
    text-align: left;
}

.floating-room:hover {
    background: rgba(23, 162, 184, .08);
}

.floating-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #fff;
    background: var(--dynamic-primary, #17a2b8);
}

.floating-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.floating-room-main {
    min-width: 0;
}

.floating-room-name,
.floating-room-preview {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.floating-room-name {
    font-weight: 800;
    color: #212529;
    font-size: .9rem;
}

.floating-room-preview {
    color: #6c757d;
    font-size: .78rem;
}

.floating-room-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    color: #8a94a6;
    font-size: .7rem;
}

.floating-room-unread {
    min-width: 19px;
    height: 19px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    background: #dc3545;
    color: #fff;
    font-weight: 800;
}

.floating-chat-messages {
    padding: 12px;
    background:
        radial-gradient(circle at 12% 18%, rgba(23, 162, 184, .08), transparent 24%),
        linear-gradient(180deg, #f8fafc, #eef3f7);
}

.floating-message {
    display: flex;
    gap: 7px;
    margin-bottom: 9px;
    max-width: 88%;
}

.floating-message.mine {
    margin-left: auto;
    flex-direction: row-reverse;
}

.floating-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex: 0 0 auto;
    background: #fff;
}

.floating-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.floating-message-bubble {
    border-radius: 8px;
    padding: 7px 9px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(15, 23, 42, .07);
    overflow-wrap: anywhere;
}

.floating-message.mine .floating-message-bubble {
    background: var(--dynamic-primary, #17a2b8);
    color: #fff;
}

.floating-message-head {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
    font-size: .72rem;
}

.floating-message-author {
    font-weight: 800;
}

.floating-message-time {
    color: #8a94a6;
}

.floating-message.mine .floating-message-time {
    color: rgba(255, 255, 255, .78);
}

.floating-message-body {
    white-space: pre-wrap;
    line-height: 1.32;
}

.floating-chat-composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 9px;
    background: #fff;
    border-top: 1px solid rgba(0, 0, 0, .08);
}

.floating-chat-composer textarea {
    min-height: 38px;
    max-height: 92px;
    resize: none;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 8px 10px;
}

.floating-chat-composer button {
    width: 40px;
    height: 38px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: var(--dynamic-primary, #17a2b8);
}

.floating-chat-composer.floating-chat-composer-readonly {
    grid-template-columns: minmax(0, 1fr);
    background: #f8fafc;
}

.floating-chat-composer.floating-chat-composer-readonly button {
    display: none;
}

.floating-chat-composer.floating-chat-composer-readonly textarea {
    color: #6c757d;
    background: #eef3f7;
    cursor: not-allowed;
}

.floating-chat-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 18px;
    text-align: center;
    color: #6c757d;
    font-size: .88rem;
}

@media (max-width: 991.98px) {
    .floating-chat-panel {
        width: min(420px, calc(100vw - 24px));
        min-width: 0;
        height: min(620px, 72vh);
        right: -6px;
    }
}

@media (max-width: 575.98px) {
    .floating-chat {
        right: 12px;
        bottom: 12px;
    }

    .floating-chat-panel {
        width: calc(100vw - 24px);
        height: min(560px, 76vh);
        bottom: 66px;
    }
}
