.live-chat-launcher,
.live-chat-nav-btn {
    position: relative;
}

body.admin-page {
    --admin-live-chat-width: 720px;
}

body.admin-live-chat-popout {
    --admin-live-chat-width: 100vw;
    background: #e2e8f0;
    overflow: hidden;
}

body.admin-live-chat-popout #header,
body.admin-live-chat-popout #sidebar,
body.admin-live-chat-popout #footer,
body.admin-live-chat-popout .back-to-top,
body.admin-live-chat-popout #adminLiveChatLauncher {
    display: none !important;
}

body.admin-live-chat-popout #main {
    margin-left: 0;
    margin-top: 0;
    padding: 1rem;
}

.live-chat-launcher .badge,
.live-chat-nav-btn .badge {
    min-width: 1.25rem;
}

.live-chat-nav-btn {
    background: transparent;
    border: 0;
    color: inherit;
}

.live-chat-nav-btn .bi-headset,
.live-chat-launcher .bi-headset,
.live-chat-launcher .bi-chat-dots {
    font-size: 1.35rem;
}

.live-chat-nav-btn.is-offline,
.live-chat-launcher.is-offline {
    color: #ef4444;
}

.live-chat-nav-btn.is-admins-only,
.live-chat-launcher.is-admins-only {
    color: #f59e0b;
}

.live-chat-nav-btn.is-live,
.live-chat-launcher.is-live {
    color: #22c55e;
}

.live-chat-nav-btn.has-unread,
.live-chat-launcher.has-unread {
    animation: live-chat-pulse 1.15s ease-in-out infinite;
}

.live-chat-launcher {
    position: fixed;
    right: 1.25rem;
    bottom: 5rem;
    z-index: 1040;
    border: 0;
    border-radius: 999px;
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #0d6efd;
    color: #fff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.22);
}

.live-chat-launcher:hover,
.live-chat-launcher:focus {
    color: #fff;
    opacity: 0.96;
}

.live-chat-launcher.is-offline {
    background: #64748b;
}

.live-chat-launcher.is-admins-only {
    background: #c78d12;
}

.live-chat-launcher.is-live {
    background: #15803d;
}

.live-chat-launcher .badge {
    position: absolute;
    top: -0.3rem;
    right: -0.2rem;
}

.live-chat-panel {
    position: fixed;
    right: 0;
    top: 60px;
    bottom: 0;
    width: min(var(--admin-live-chat-width), calc(100vw - 0.75rem));
    max-height: none;
    background: #fff;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-right: 0;
    border-radius: 0;
    box-shadow: -20px 0 44px rgba(15, 23, 42, 0.16);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateX(calc(100% + 1rem));
    transition: transform 0.26s ease, opacity 0.18s ease, box-shadow 0.22s ease;
}

.live-chat-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.live-chat-panel.admin-panel {
    width: min(var(--admin-live-chat-width), calc(100vw - 0.75rem));
    max-height: none;
}

body.admin-live-chat-popout .live-chat-panel.admin-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    border: 0;
    box-shadow: none;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    z-index: 1060;
}

body.admin-live-chat-popout .live-chat-panel.admin-panel .live-chat-panel-body {
    height: 100%;
}

body.admin-live-chat-popout .live-chat-panel-resizer {
    display: none;
}

body.admin-live-chat-popout .live-chat-alert-stack {
    top: 1rem;
    right: 1rem;
}

.live-chat-panel-resizer {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 14px;
    cursor: ew-resize;
    z-index: 2;
}

.live-chat-panel-resizer::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 18px;
    bottom: 18px;
    width: 2px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.5);
}

.live-chat-alert-stack {
    position: fixed;
    top: 4.5rem;
    right: 1rem;
    z-index: 1062;
    width: min(380px, calc(100vw - 2rem));
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.live-chat-alert {
    pointer-events: auto;
    background: #fff;
    border: 1px solid rgba(248, 113, 113, 0.35);
    border-left: 5px solid #dc2626;
    border-radius: 0.9rem;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
    overflow: hidden;
}

.live-chat-alert-body {
    padding: 0.8rem 0.9rem;
}

.live-chat-alert-title {
    font-weight: 700;
    color: #7f1d1d;
}

.live-chat-alert-text {
    color: #334155;
    font-size: 0.9rem;
}

.live-chat-alert-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.7rem;
}

.live-chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: linear-gradient(135deg, #0f172a, #1d4ed8);
    color: #fff;
}

.live-chat-panel-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.live-chat-panel-subtitle {
    font-size: 0.8rem;
    opacity: 0.86;
}

.live-chat-panel-header .btn-close {
    filter: invert(1) grayscale(1);
}

.live-chat-panel-dismiss {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
}

.live-chat-panel-body {
    min-height: 0;
    flex: 1 1 auto;
    background: #f8fafc;
}

.live-chat-panel.admin-panel .live-chat-panel-body {
    display: grid;
    grid-template-columns: minmax(250px, 34%) minmax(0, 1fr);
}

.live-chat-panel.admin-panel.is-sidebar-hidden .live-chat-panel-body {
    grid-template-columns: minmax(0, 1fr);
}

.live-chat-sidebar {
    border-right: 1px solid rgba(148, 163, 184, 0.28);
    background: #fff;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.live-chat-panel.admin-panel.is-sidebar-hidden .live-chat-sidebar {
    display: none;
}

.live-chat-sidebar-section {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.live-chat-sidebar-section-primary {
    min-height: 0;
}

.live-chat-sidebar-section-secondary {
    flex: 0 0 auto;
}

.live-chat-session-list,
.live-chat-search-results {
    overflow-y: auto;
    min-height: 0;
}

.live-chat-sidebar-section-primary .live-chat-search-results {
    flex: 1 1 auto;
    max-height: none;
}

.live-chat-sidebar-section-secondary .live-chat-session-list {
    max-height: min(26vh, 11rem);
}

@keyframes live-chat-pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.live-chat-session-item,
.live-chat-search-item {
    border: 1px solid rgba(203, 213, 225, 0.85);
    border-radius: 0.75rem;
    padding: 0.55rem 0.7rem;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.live-chat-session-item + .live-chat-session-item,
.live-chat-search-item + .live-chat-search-item {
    margin-top: 0.45rem;
}

.live-chat-session-section + .live-chat-session-section {
    margin-top: 1rem;
}

.live-chat-session-item:hover,
.live-chat-search-item:hover,
.live-chat-session-item.is-active {
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.08);
    transform: translateY(-1px);
}

.live-chat-search-item.is-active-admin {
    border-color: rgba(22, 163, 74, 0.48);
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.12);
    background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

.live-chat-session-title,
.live-chat-conversation-title {
    font-weight: 700;
    color: #0f172a;
}

.live-chat-conversation-title a {
    color: inherit;
    text-decoration: none;
}

.live-chat-conversation-title a:hover,
.live-chat-conversation-title a:focus {
    color: #0d6efd;
    text-decoration: underline;
}

.live-chat-session-snippet {
    color: #64748b;
    font-size: 0.84rem;
}

.live-chat-search-item .fw-semibold {
    font-size: 0.9rem;
    line-height: 1.2;
}

.live-chat-search-meta {
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.15;
}

.live-chat-search-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.live-chat-search-actions .btn {
    padding: 0.2rem 0.55rem;
}

.live-chat-conversation {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.live-chat-conversation-meta {
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
    background: rgba(255, 255, 255, 0.94);
    padding: 0.9rem 1rem 0.8rem;
}

.live-chat-conversation-notice {
    margin-top: 0.6rem;
    font-size: 0.82rem;
    color: #92400e;
}

.live-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.06), transparent 30%),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.live-chat-empty {
    padding: 1rem;
    color: #64748b;
}

.live-chat-row {
    display: flex;
    margin-bottom: 0.8rem;
}

.live-chat-row.user {
    justify-content: flex-start;
}

.live-chat-row.admin {
    justify-content: flex-end;
}

.live-chat-row.admin-self {
    justify-content: flex-end;
}

.live-chat-row.admin-peer {
    justify-content: flex-start;
}

.live-chat-row.system {
    justify-content: center;
}

.live-chat-bubble {
    width: min(80%, 680px);
    border-radius: 1rem;
    padding: 0.75rem 0.85rem;
    background: #fff;
    border: 1px solid rgba(203, 213, 225, 0.7);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

.live-chat-bubble.user {
    background: #ffffff;
}

.live-chat-bubble.admin {
    background: #dbeafe;
    border-color: rgba(96, 165, 250, 0.55);
}

.live-chat-bubble.admin-self {
    background: #dbeafe;
    border-color: rgba(96, 165, 250, 0.55);
}

.live-chat-bubble.admin-peer {
    background: #ffffff;
    border-color: rgba(148, 163, 184, 0.55);
}

.live-chat-bubble.system {
    width: min(92%, 760px);
    background: #fff7ed;
    border-color: rgba(251, 191, 36, 0.45);
}

.live-chat-bubble-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.78rem;
    color: #475569;
}

.live-chat-bubble-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.live-chat-translate-btn {
    --bs-btn-padding-y: 0.15rem;
    --bs-btn-padding-x: 0.38rem;
    --bs-btn-font-size: 0.76rem;
    line-height: 1.1;
}

.live-chat-translation-text {
    white-space: pre-wrap;
    word-break: break-word;
    color: #111827;
}

.live-chat-bubble-body {
    margin-top: 0.35rem;
    white-space: pre-wrap;
    word-break: break-word;
    color: #111827;
}

.live-chat-inline-link {
    color: #1d4ed8;
    text-decoration: underline;
    text-underline-offset: 0.12em;
    word-break: break-all;
}

.live-chat-inline-link:hover {
    color: #1e40af;
}

.live-chat-attachments {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.45rem;
}

.live-chat-attachment-link {
    display: inline-flex;
    align-self: flex-start;
    max-width: min(100%, 340px);
    border-radius: 0.9rem;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #fff;
}

.live-chat-attachment-image {
    display: block;
    max-width: min(100%, 340px);
    max-height: 280px;
    object-fit: cover;
}

.live-chat-typing {
    min-height: 1.2rem;
    padding: 0 1rem 0.75rem;
    font-size: 0.82rem;
    color: #475569;
}

.live-chat-composer {
    border-top: 1px solid rgba(226, 232, 240, 0.95);
    padding: 0.85rem 1rem 1rem;
    background: #fff;
}

.live-chat-composer-tools {
    position: relative;
}

.live-chat-compact-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 18rem;
    min-width: 0;
}

.live-chat-inline-select-wrap {
    min-width: 0;
    flex: 1 1 14rem;
}

.live-chat-inline-select {
    white-space: nowrap;
}

.live-chat-emoji-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 0.35rem);
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0.5rem;
    min-width: 15rem;
    border-radius: 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.18);
    overflow-y: auto;
}

.live-chat-emoji-menu.is-above {
    top: auto;
    bottom: calc(100% + 0.35rem);
}

.live-chat-emoji-menu button {
    border: 0;
    border-radius: 0.7rem;
    background: transparent;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.45rem;
}

.live-chat-emoji-menu button:hover,
.live-chat-emoji-menu button:focus {
    background: rgba(37, 99, 235, 0.1);
}

.live-chat-image-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 0.35rem);
    z-index: 4;
    min-width: 12.5rem;
    border-radius: 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.18);
    padding: 0.35rem;
}

.live-chat-image-menu.is-above {
    top: auto;
    bottom: calc(100% + 0.35rem);
}

.live-chat-image-menu button {
    width: 100%;
    border: 0;
    border-radius: 0.7rem;
    background: transparent;
    text-align: left;
    font-size: 0.92rem;
    padding: 0.5rem 0.65rem;
    color: #0f172a;
}

.live-chat-image-menu button:hover,
.live-chat-image-menu button:focus {
    background: rgba(37, 99, 235, 0.1);
}

.live-chat-image-menu .live-chat-image-divider {
    height: 1px;
    margin: 0.3rem 0.2rem;
    background: rgba(148, 163, 184, 0.28);
}

.live-chat-image-menu .live-chat-image-hint {
    padding: 0.45rem 0.65rem 0.2rem;
    font-size: 0.75rem;
    color: #64748b;
}

.live-chat-composer textarea {
    resize: none;
    min-height: 78px;
}

.live-chat-help {
    font-size: 0.8rem;
    color: #64748b;
}

@media (min-width: 1200px) {
    body.admin-chat-drawer-open #main,
    body.admin-chat-drawer-open #footer {
        margin-right: calc(var(--admin-live-chat-width) + 1rem);
    }

    body.admin-chat-drawer-open .live-chat-alert-stack {
        right: calc(var(--admin-live-chat-width) + 1rem);
    }
}

@media (max-width: 1199px) {
    .live-chat-panel {
        top: 60px;
        bottom: 0;
        width: calc(100vw - 0.35rem);
        border-radius: 0;
    }

    .live-chat-panel.admin-panel .live-chat-panel-body {
        grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    }

    .live-chat-panel-resizer {
        display: none;
    }
}

@media (max-width: 767px) {
    .live-chat-compact-tools {
        width: 100%;
        flex-wrap: wrap;
    }

    .live-chat-inline-select-wrap {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 767px) {
    .live-chat-panel {
        right: 0;
        left: 0;
        width: 100vw;
        top: 60px;
        bottom: 0;
        border-radius: 0;
        border-left: 0;
    }

    .live-chat-panel.admin-panel .live-chat-panel-body {
        display: flex;
        flex-direction: column;
    }

    .live-chat-sidebar {
        max-height: 42vh;
    }

    .live-chat-alert-stack {
        top: 4rem;
        right: 0.5rem;
        left: 0.5rem;
        width: auto;
    }
}

.chat-transcript-row {
    display: flex;
    margin-bottom: 0.8rem;
}

.chat-transcript-row.user {
    justify-content: flex-start;
}

.chat-transcript-row.admin {
    justify-content: flex-end;
}

.chat-transcript-row.system {
    justify-content: center;
}

.chat-transcript-bubble {
    width: min(80%, 760px);
    border-radius: 1rem;
    border: 1px solid rgba(203, 213, 225, 0.75);
    background: #fff;
    padding: 0.8rem 0.95rem;
}

.chat-transcript-bubble.admin {
    background: #dbeafe;
    border-color: rgba(96, 165, 250, 0.5);
}

.chat-transcript-bubble.system {
    width: min(92%, 820px);
    background: #fff7ed;
    border-color: rgba(251, 191, 36, 0.45);
}

.chat-transcript-body {
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 991.98px) {
    .live-chat-panel.admin-panel {
        width: min(100vw - 1rem, 100%);
        right: 0.5rem;
        left: 0.5rem;
    }

    .live-chat-panel.admin-panel .live-chat-panel-body {
        grid-template-columns: 1fr;
    }

    .live-chat-sidebar {
        border-right: 0;
        border-bottom: 1px solid rgba(148, 163, 184, 0.28);
        max-height: 42vh;
    }
}

@media (max-width: 575.98px) {
    .live-chat-launcher {
        right: 0.85rem;
        bottom: 4.5rem;
        width: 52px;
        height: 52px;
    }

    .live-chat-panel,
    .live-chat-panel.admin-panel {
        right: 0;
        left: 0;
        bottom: 0;
        top: 60px;
        width: 100vw;
        max-height: none;
        border-radius: 0;
    }

    .live-chat-bubble,
    .chat-transcript-bubble {
        width: 92%;
    }
}

@media (min-width: 680px) {
    body.admin-live-chat-popout .live-chat-panel.admin-panel .live-chat-panel-body {
        display: grid;
        grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    }

    body.admin-live-chat-popout .live-chat-sidebar {
        display: flex;
        border-right: 1px solid rgba(148, 163, 184, 0.28);
        border-bottom: 0;
        max-height: none;
    }

    body.admin-live-chat-popout .live-chat-panel.admin-panel.is-sidebar-hidden .live-chat-sidebar {
        display: none;
    }
}
