.adminlte-chat-app {
    display: grid;
    grid-template-columns: minmax(260px, var(--adminlte-chat-sidebar-width, 320px)) minmax(0, 1fr);
    gap: 0;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background: var(--bs-body-bg);
}

.agent-chat-shell.adminlte-chat-app {
    --adminlte-chat-sidebar-width: 290px;
}

.adminlte-chat-app .chat-contacts {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    border-inline-end: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}

.adminlte-chat-app .chat-conversation {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
}

.adminlte-chat-app:not(.has-selected-conversation) .chat-conversation {
    justify-content: center;
    padding: 2rem;
}

.adminlte-chat-app.has-selected-conversation {
    display: flex;
    min-height: min(780px, calc(100dvh - 190px));
}

.adminlte-chat-app.has-selected-conversation .chat-conversation {
    width: 100%;
    min-height: min(780px, calc(100dvh - 190px));
}

.adminlte-chat-app .chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.adminlte-chat-app .chat-messages {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bs-tertiary-bg);
}

.adminlte-chat-app .agent-chat-box {
    display: flex;
    align-items: stretch;
    flex-direction: column;
}

.adminlte-chat-app .agent-chat-box > .agent-chat-message {
    display: flex !important;
    height: auto !important;
    flex: 0 0 auto !important;
}

.adminlte-chat-app .chat-message,
.adminlte-chat-conversation .chat-message {
    display: flex;
    width: fit-content;
    max-width: min(78%, 650px);
    margin-bottom: 0.75rem;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.adminlte-chat-app .portal-chat-message,
.adminlte-chat-app .agent-chat-message,
.adminlte-chat-conversation .guest-chat-message {
    width: fit-content !important;
    max-width: min(78%, 650px) !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: inherit !important;
    white-space: normal;
}

.adminlte-chat-app .agent-chat-message.internal {
    width: 100% !important;
    max-width: 100% !important;
}

.adminlte-chat-app .agent-chat-box > .agent-chat-message:not(.internal) {
    width: fit-content !important;
}

.adminlte-chat-app .chat-message.me,
.adminlte-chat-conversation .chat-message.me {
    align-self: flex-end;
    justify-content: flex-end;
}

.adminlte-chat-app .chat-message.them,
.adminlte-chat-conversation .chat-message.them {
    align-self: flex-start;
}

.adminlte-chat-app .chat-bubble,
.adminlte-chat-conversation .chat-bubble {
    max-width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 1rem;
    color: var(--bs-body-color);
    font-size: 0.9rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
    white-space: normal;
}

.adminlte-chat-app .chat-bubble-body,
.adminlte-chat-conversation .chat-bubble-body {
    white-space: pre-wrap;
}

.adminlte-chat-app .chat-message.them .chat-bubble,
.adminlte-chat-conversation .chat-message.them .chat-bubble {
    border-bottom-inline-start-radius: 0.25rem;
    background: var(--bs-body-bg);
}

.adminlte-chat-app .chat-message.internal .chat-bubble {
    border: 1px dashed #e6bd52;
    background: #fff8df;
    color: #263238;
}

html[data-theme='dark'] .adminlte-chat-app .chat-message.internal .chat-bubble {
    border-color: #715d2b;
    background: #3a321f;
    color: #e7edf3;
}

.adminlte-chat-app .chat-message.me .chat-bubble,
.adminlte-chat-conversation .chat-message.me .chat-bubble {
    border-color: var(--bs-primary);
    border-bottom-inline-end-radius: 0.25rem;
    background: var(--bs-primary);
    color: var(--bs-white);
}

.adminlte-chat-app .chat-time,
.adminlte-chat-conversation .chat-time {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.7rem;
    opacity: 0.7;
}

.adminlte-chat-app .chat-composer,
.adminlte-chat-conversation .chat-composer {
    display: flex;
    gap: 0.75rem;
    margin: 0;
    border-top: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
}

.adminlte-chat-app .chat-composer textarea,
.adminlte-chat-conversation .chat-composer textarea {
    min-width: 0;
    flex: 1 1 auto;
}

.adminlte-chat-conversation {
    display: flex;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background: var(--bs-body-bg);
}

.adminlte-chat-conversation .guest-chat-back {
    flex: 0 0 auto;
}

.adminlte-chat-conversation .chat-header {
    flex: 0 0 auto;
    padding: 1rem 1.25rem;
}

.adminlte-chat-conversation .chat-composer {
    flex: 0 0 auto;
    padding: 0.875rem 1.25rem;
}

.adminlte-chat-conversation .chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.adminlte-chat-conversation .chat-messages {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bs-tertiary-bg);
}

@media (max-width: 900px) {
    .adminlte-chat-app:not(.has-selected-conversation) {
        grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
    }

    .adminlte-chat-app.has-selected-conversation,
    .adminlte-chat-app.has-selected-conversation .chat-conversation {
        min-height: calc(100dvh - 130px);
    }
}

@media (max-width: 980px) {
    .agent-chat-shell.adminlte-chat-app {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 768px) {
    .adminlte-chat-app {
        grid-template-columns: minmax(0, 1fr);
    }

    .adminlte-chat-app:not(.has-selected-conversation) .chat-conversation {
        min-height: 220px;
        padding: 1.25rem;
    }

    .adminlte-chat-app .chat-contacts {
        border-inline-end: 0;
        border-bottom: 1px solid var(--bs-border-color);
    }

    .adminlte-chat-app .portal-chat-form,
    .adminlte-chat-conversation .chat-composer {
        flex-direction: column;
    }

    .adminlte-chat-app .chat-message,
    .adminlte-chat-conversation .chat-message {
        max-width: 92%;
    }

    .adminlte-chat-app .portal-chat-message,
    .adminlte-chat-app .agent-chat-message,
    .adminlte-chat-conversation .guest-chat-message {
        max-width: 92% !important;
    }

    .adminlte-chat-conversation {
        height: calc(100dvh - 170px);
        min-height: 360px;
    }

    .adminlte-chat-conversation .chat-header {
        padding: 0.75rem 0.875rem;
    }

    .adminlte-chat-conversation .chat-composer {
        padding: 0.75rem 0.875rem;
    }
}

@media (min-width: 981px) {
    .agent-chat-shell.adminlte-chat-app {
        grid-template-columns: minmax(250px, 290px) minmax(0, 1fr);
    }

    .agent-chat-shell.adminlte-chat-app .agent-chat-main {
        min-height: 0;
    }

    .agent-chat-shell.adminlte-chat-app .agent-conversation {
        min-height: 0;
        grid-template-rows: auto minmax(280px, 1fr) max-content;
        align-content: stretch;
    }

    .agent-chat-shell.adminlte-chat-app .agent-chat-box {
        min-height: 280px;
        max-height: none;
    }

    .agent-chat-shell.adminlte-chat-app .agent-context-rail {
        align-self: start;
    }

    .agent-chat-shell.adminlte-chat-app .agent-composer-grid,
    .agent-chat-shell.adminlte-chat-app .agent-convert {
        align-self: start;
    }
}

@media (max-width: 980px) {
    .agent-chat-shell.adminlte-chat-app {
        height: auto;
        min-height: 0;
    }

    .agent-chat-shell.adminlte-chat-app .agent-chat-main {
        min-height: 0;
    }

    .agent-chat-shell.adminlte-chat-app .agent-conversation {
        height: auto;
        min-height: 0;
        grid-template-rows: auto minmax(280px, 1fr) max-content max-content;
        align-content: start;
    }

    .agent-chat-shell.adminlte-chat-app .agent-chat-box {
        min-height: 280px;
        max-height: min(55vh, 560px);
    }
}

@media (max-width: 640px) {
    .agent-chat-shell.adminlte-chat-app .agent-chat-queue {
        display: flex;
        max-height: 280px;
        overflow-y: auto;
    }

    .agent-chat-shell.adminlte-chat-app .agent-conversation {
        grid-template-rows: auto minmax(240px, 1fr) max-content max-content;
    }

    .agent-chat-shell.adminlte-chat-app .agent-chat-box {
        min-height: 240px;
        max-height: 50vh;
    }
}
