/* =====================================================================
   Biochemia chat - visitor widget (.bcw-*) and dashboard messaging center (.bcm-*)
   ===================================================================== */

/* ---------------------------------------------------------------- visitor widget */
.bcw-root { position: fixed; right: 20px; bottom: 20px; z-index: 1035; font-family: 'Open Sans', Arial, sans-serif; font-size: 14px; }
.bcw-root * { box-sizing: border-box; }

.bcw-launcher {
    position: relative; display: flex; align-items: center; justify-content: center;
    width: 58px; height: 58px; border: 0; border-radius: 50%; cursor: pointer;
    background: #0d2d52; color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.28);
    transition: transform .15s;
}
.bcw-launcher:hover { transform: scale(1.06); }
.bcw-launcher:focus-visible, .bcw-close:focus-visible, .bcw-send:focus-visible { outline: 3px solid #4a9eff; outline-offset: 2px; }

.bcw-badge {
    position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 5px;
    align-items: center; justify-content: center; border-radius: 11px;
    background: #ed1b4c; color: #fff; font-size: 12px; font-weight: 700;
}

.bcw-panel {
    flex-direction: column; width: 360px; max-width: calc(100vw - 24px);
    height: 520px; max-height: calc(100vh - 40px);
    background: #fff; border-radius: 12px; overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,.28);
}

.bcw-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: #0d2d52; color: #fff; }
.bcw-head-text { flex: 1; min-width: 0; }
.bcw-title { font-weight: 700; font-size: 15px; }
.bcw-status { font-size: 11.5px; opacity: .85; margin-top: 1px; }
.bcw-status.on::before, .bcw-status.off::before {
    content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0;
}
.bcw-status.on::before { background: #35d07f; }
.bcw-status.off::before { background: #f0ad4e; }
.bcw-close { border: 0; background: transparent; color: #fff; font-size: 26px; line-height: 1; cursor: pointer; padding: 0 6px; border-radius: 6px; }
.bcw-close:hover { background: rgba(255,255,255,.14); }

.bcw-messages { flex: 1; overflow-y: auto; padding: 14px; background: #f4f6f9; display: flex; flex-direction: column; gap: 8px; }
.bcw-row { max-width: 85%; display: flex; flex-direction: column; }
.bcw-row.me { align-self: flex-end; align-items: flex-end; }
.bcw-row.them { align-self: flex-start; align-items: flex-start; }
.bcw-bubble { padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.bcw-row.me .bcw-bubble { background: #0d2d52; color: #fff; border-bottom-right-radius: 4px; }
.bcw-row.me .bcw-bubble a { color: #bfe0ff; }
.bcw-row.them .bcw-bubble { background: #fff; color: #222; border: 1px solid #e3e7ee; border-bottom-left-radius: 4px; }
.bcw-time { font-size: 10.5px; color: #8a93a2; margin-top: 2px; }
.bcw-notice { align-self: center; font-size: 12px; color: #6c7686; background: #e9edf3; padding: 4px 10px; border-radius: 10px; text-align: center; }

.bcw-typing { padding: 4px 14px; font-size: 12px; color: #6c7686; background: #f4f6f9; }
.bcw-error { padding: 6px 14px; font-size: 12.5px; color: #b02a37; background: #fdecee; }

.bcw-details { display: none; flex-direction: column; gap: 6px; padding: 8px 10px 0; border-top: 1px solid #e3e7ee; background: #fff; }
.bcw-input { width: 100%; padding: 7px 10px; border: 1px solid #d3d9e2; border-radius: 8px; font-size: 13px; font-family: inherit; }
.bcw-input:focus, .bcw-text:focus { outline: none; border-color: #4a9eff; box-shadow: 0 0 0 3px rgba(74,158,255,.2); }

.bcw-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px; background: #fff; border-top: 1px solid #e3e7ee; }
.bcw-details + .bcw-composer { border-top: 0; }
.bcw-text { flex: 1; resize: none; padding: 8px 10px; border: 1px solid #d3d9e2; border-radius: 10px; font-size: 14px; font-family: inherit; line-height: 1.35; max-height: 110px; }
.bcw-send { flex-shrink: 0; width: 40px; height: 40px; border: 0; border-radius: 50%; background: #ed1b4c; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.bcw-send:disabled { opacity: .5; cursor: default; }

@media (max-width: 480px) {
    .bcw-root { right: 12px; bottom: 12px; }
    .bcw-panel { position: fixed; inset: 0; width: 100vw; max-width: none; height: 100%; max-height: none; border-radius: 0; }
    .bcw-text, .bcw-input { font-size: 16px; } /* stops iOS zooming into the field */
}

/* Printing / PDF pages must never include the chat */
@media print { .bcw-root { display: none !important; } }

/* ---------------------------------------------------------------- dashboard messaging center */
.min-w-0 { min-width: 0; }

.bcm-wrap {
    display: flex; height: calc(100vh - 230px); min-height: 480px;
    border: 1px solid #dfe4ec; border-radius: 8px; overflow: hidden; background: #fff;
}

.bcm-list { width: 340px; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid #dfe4ec; background: #fafbfd; }
.bcm-filters { display: flex; flex-wrap: wrap; gap: 4px; }
.bcm-filters button {
    border: 1px solid #cfd6e1; background: #fff; color: #44506a; font-size: 11.5px; font-weight: 600;
    padding: 3px 10px; border-radius: 12px; cursor: pointer;
}
.bcm-filters button.active { background: #0d2d52; border-color: #0d2d52; color: #fff; }

.bcm-items { flex: 1; overflow-y: auto; }
.bcm-none { padding: 30px 16px; text-align: center; color: #8a93a2; font-size: 13px; }

.bcm-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #eef1f6; cursor: pointer; }
.bcm-item:hover { background: #f0f4fa; }
.bcm-item:focus-visible { outline: 2px solid #4a9eff; outline-offset: -2px; }
.bcm-item.active { background: #e3eefc; }
.bcm-item.unread .bcm-item-name, .bcm-item.unread .bcm-item-prev { font-weight: 700; color: #111; }

.bcm-avatar {
    flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; background: #0d2d52; color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.bcm-item-body { flex: 1; min-width: 0; }
.bcm-item-top, .bcm-item-bot { display: flex; align-items: center; gap: 6px; }
.bcm-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: #222; }
.bcm-item-time { font-size: 11px; color: #8a93a2; flex-shrink: 0; }
.bcm-item-prev { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #6c7686; }
.bcm-item-assign { font-size: 10.5px; color: #8a93a2; margin-top: 1px; }
.bcm-unread { background: #ed1b4c; color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.bcm-tag { margin-left: 6px; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #0d6e3f; background: #dff5ea; padding: 1px 5px; border-radius: 4px; }

.bcm-thread { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bcm-thread-inner { display: flex; flex-direction: column; height: 100%; }
.bcm-thread-inner.d-none { display: none !important; }
.bcm-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #8a93a2; gap: 8px; }
.bcm-empty i { font-size: 42px; opacity: .5; }
.bcm-empty.d-none { display: none !important; }

.bcm-thread-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid #dfe4ec; background: #fff; }
.bcm-thread-head a { color: #0d6efd; }

.bcm-messages { flex: 1; overflow-y: auto; padding: 14px 16px; background: #f4f6f9; display: flex; flex-direction: column; gap: 6px; }
.bcm-day { text-align: center; margin: 6px 0; }
.bcm-day span { font-size: 11px; color: #6c7686; background: #e4e9f0; padding: 2px 10px; border-radius: 10px; }
.bcm-msg { max-width: 75%; display: flex; flex-direction: column; }
.bcm-msg.visitor { align-self: flex-start; align-items: flex-start; }
.bcm-msg.agent { align-self: flex-end; align-items: flex-end; }
.bcm-bubble { padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; font-size: 13.5px; }
.bcm-msg.visitor .bcm-bubble { background: #fff; border: 1px solid #e3e7ee; border-bottom-left-radius: 4px; }
.bcm-msg.agent .bcm-bubble { background: #0d2d52; color: #fff; border-bottom-right-radius: 4px; }
.bcm-msg.agent .bcm-bubble a { color: #bfe0ff; }
.bcm-msg-meta { font-size: 10.5px; color: #8a93a2; margin-top: 2px; }
.bcm-typing { padding: 3px 16px; font-size: 12px; color: #6c7686; background: #f4f6f9; }
.bcm-typing.d-none { display: none !important; }

.bcm-composer {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #dfe4ec;
    background: #fff;
    align-items: stretch;
}

    .bcm-composer .btn {
        white-space: nowrap;
        padding-left: 18px;
        padding-right: 18px;
    }
.bcm-composer textarea { resize: none; font-size: 13.5px; }

/* sidebar badge: hidden when there is nothing unread */
.nav-badge.d-none { display: none !important; }

@media (max-width: 767.98px) {
    .bcm-wrap { height: calc(100vh - 200px); }
    .bcm-list { width: 100%; border-right: 0; }
    .bcm-thread { display: none; }
    .bcm-wrap.show-thread .bcm-list { display: none; }
    .bcm-wrap.show-thread .bcm-thread { display: flex; }
}
