.lamoi-chat-widget {
    position: fixed;
    z-index: 1200;
    right: 24px;
    bottom: 24px;
    font-family: "Be Vietnam Pro", system-ui, sans-serif;
}

.lamoi-chat-widget [hidden] { display: none !important; }

/* The panel uses display:grid, so the native hidden attribute must win. */
.lamoi-chat-panel[hidden],
.lamoi-chat-callout[hidden] {
    display: none !important;
}

.lamoi-chat-launcher {
    position: relative;
    display: grid;
    width: 66px;
    height: 66px;
    place-items: center;
    padding: 0;
    border: 4px solid #fff;
    border-radius: 22px;
    background: linear-gradient(145deg, var(--brand, #398640), var(--brand-dark, #155a31));
    box-shadow: 0 12px 34px rgba(20, 74, 42, .3);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.lamoi-chat-launcher img,
.lamoi-bot-avatar img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 50%;
}

.lamoi-chat-launcher:hover {
    transform: translateY(-2px) rotate(-2deg);
}

.lamoi-chat-launcher,
.lamoi-chat-callout,
.lamoi-chat-header button { -webkit-tap-highlight-color: transparent; }

.lamoi-chat-launcher:focus-visible,
.lamoi-chat-header > button:focus-visible,
.lamoi-chat-callout:focus-visible {
    outline: 3px solid rgba(109, 192, 103, .45);
    outline-offset: 3px;
}

.lamoi-chat-pulse {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #e3332c;
}

.lamoi-chat-callout {
    position: absolute;
    right: 78px;
    bottom: 5px;
    width: max-content;
    max-width: 260px;
    padding: 12px 16px;
    border: 1px solid #d5e3d3;
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(26, 61, 37, .16);
    color: #1e2c21;
    cursor: pointer;
}

.lamoi-chat-callout::after {
    position: absolute;
    right: -7px;
    bottom: 18px;
    width: 13px;
    height: 13px;
    border-top: 1px solid #d5e3d3;
    border-right: 1px solid #d5e3d3;
    background: #fff;
    content: "";
    transform: rotate(45deg);
}

.lamoi-chat-callout strong,
.lamoi-chat-callout span {
    display: block;
}

.lamoi-chat-callout strong {
    font-size: 14px;
}

.lamoi-chat-callout span {
    margin-top: 2px;
    color: #66736a;
    font-size: 11px;
}

.lamoi-chat-panel {
    position: absolute;
    right: 0;
    bottom: 78px;
    display: grid;
    overflow: hidden;
    width: min(680px, calc(100vw - 32px));
    height: min(820px, calc(100vh - 108px));
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    border: 1px solid #dbe4da;
    border-radius: 22px;
    background: #f5f6f5;
    box-shadow: 0 24px 70px rgba(19, 54, 32, .28);
}

.lamoi-chat-widget.is-open .lamoi-chat-launcher {
    opacity: .86;
}

.lamoi-chat-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 11px;
    padding: 14px 16px;
    background: #fff;
    border-bottom: 1px solid #e6ebe5;
}

.lamoi-bot-avatar {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(145deg, var(--brand, #398640), var(--brand-dark, #155a31));
}

.lamoi-bot-avatar svg {
    width: 34px;
}

.lamoi-bot-avatar img { width: 34px; height: 34px; }

.lamoi-chat-header > div > div {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
}

.lamoi-chat-header strong {
    color: #152219;
    font-size: 16px;
}

.lamoi-chat-header div span {
    padding: 3px 6px;
    border: 1px solid var(--brand, #398640);
    border-radius: 5px;
    color: var(--brand-dark, #155a31);
    font-size: 9px;
    font-weight: 700;
}

.lamoi-chat-header small {
    display: block;
    margin-top: 2px;
    color: #6d786f;
    font-size: 10px;
}

.lamoi-chat-header > button,
.lamoi-chat-toolbar button,
.lamoi-attachment-preview button {
    border: 0;
    background: transparent;
    color: #627067;
    font: inherit;
    cursor: pointer;
}

.lamoi-chat-header > button {
    width: 30px;
    height: 34px;
    padding: 0;
    font-size: 24px;
}

.lamoi-chat-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 18px;
    background: #fff;
}

.lamoi-chat-toolbar strong {
    font-size: 17px;
}

.lamoi-chat-toolbar button {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
}

.lamoi-chat-messages {
    overflow-y: auto;
    padding: 20px 24px;
    background: #fff;
    scroll-behavior: smooth;
}

.lamoi-chat-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}

.lamoi-chat-message.user {
    flex-direction: row-reverse;
}

.lamoi-message-avatar {
    display: grid;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 12px;
    background: var(--brand, #398640);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
}

.lamoi-chat-message > div {
    width: calc(100% - 46px);
    max-width: calc(100% - 46px);
    padding: 7px 4px;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.lamoi-chat-message.user > div {
    width: auto;
    max-width: 82%;
    padding: 11px 15px;
    border-radius: 18px 5px 18px 18px;
    background: #eaf3e9;
    color: #18271d;
}

.lamoi-chat-message strong {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
}

.lamoi-chat-message p {
    margin: 0 0 10px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.7;
}

.lamoi-message-content > :last-child { margin-bottom: 0; }

.lamoi-message-content h3,
.lamoi-message-content h4 {
    margin: 17px 0 7px;
    color: #18351f;
    line-height: 1.4;
}

.lamoi-message-content h3 { font-size: 16px; }
.lamoi-message-content h4 { font-size: 14px; }

.lamoi-message-content ul,
.lamoi-message-content ol {
    margin: 7px 0 12px;
    padding-left: 23px;
    font-size: 14px;
    line-height: 1.7;
}

.lamoi-message-content table {
    width: 100%;
    margin: 10px 0 14px;
    border-collapse: collapse;
    font-size: 12px;
}

.lamoi-message-content th,
.lamoi-message-content td {
    padding: 8px 9px;
    border: 1px solid #dce6dc;
    text-align: left;
    vertical-align: top;
}

.lamoi-message-content th { background: #eef5ed; color: #214b29; }
.lamoi-message-content hr { margin: 15px 0; border: 0; border-top: 1px solid #dfe7df; }

.lamoi-chat-message small {
    display: block;
    margin-top: 8px;
    color: #718078;
    font-size: 9px;
}

.lamoi-chat-message.loading > div {
    color: #728078;
    animation: lamoi-chat-fade 1.25s infinite alternate;
}

@keyframes lamoi-chat-fade {
    to { opacity: .5; }
}

.lamoi-chat-compose {
    padding: 14px 20px 16px;
    border-top: 1px solid #e1e7e0;
    background: #fff;
}

.lamoi-compose-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: end;
    gap: 7px;
}

.lamoi-chat-attach,
.lamoi-chat-send {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 50%;
    cursor: pointer;
}

.lamoi-chat-attach {
    border: 1px solid #e2e7e2;
    background: #f7f9f7;
}

.lamoi-chat-attach input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.lamoi-chat-attach svg,
.lamoi-chat-send svg {
    width: 21px;
    fill: #66746a;
}

.lamoi-chat-compose textarea {
    box-sizing: border-box;
    width: 100%;
    min-height: 48px;
    max-height: 150px;
    resize: none;
    padding: 13px 16px;
    border: 1px solid #e1e6e0;
    border-radius: 18px;
    outline: none;
    background: #f7f8f7;
    font: inherit;
    font-size: 14px;
    line-height: 1.5;
}

.lamoi-chat-compose textarea:focus {
    border-color: var(--brand, #398640);
    box-shadow: 0 0 0 3px rgba(67, 145, 75, .1);
}

.lamoi-chat-send {
    border: 0;
    background: var(--brand, #398640);
}

.lamoi-chat-send svg {
    fill: #fff;
}

.lamoi-chat-send:disabled,
.lamoi-chat-attach:has(input:disabled) {
    opacity: .45;
    cursor: not-allowed;
}

.lamoi-chat-compose > small {
    display: block;
    margin: 7px 4px 0;
    color: #7c877f;
    font-size: 8px;
    text-align: center;
}

.lamoi-attachment-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
    padding: 7px 10px;
    border-radius: 8px;
    background: #edf5ec;
    color: #2b6133;
    font-size: 10px;
    font-weight: 600;
}

.lamoi-attachment-preview span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lamoi-chat-widget.is-disabled .lamoi-chat-pulse {
    background: #9ca69f;
}

@media (max-width: 600px) {
    .lamoi-chat-widget {
        right: 14px;
        bottom: 14px;
    }

    .lamoi-chat-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100dvh;
        border: 0;
        border-radius: 0;
    }

    .lamoi-chat-launcher {
        width: 60px;
        height: 60px;
        border-radius: 20px;
    }

    .lamoi-chat-callout {
        right: 70px;
        max-width: calc(100vw - 105px);
    }

    /* Điện thoại: chỉ giữ nút chatbot để không che nội dung/khung so sánh.
       Tablet/iPad và laptop (>600px) vẫn hiển thị bong bóng giới thiệu như bản cũ. */
    .lamoi-chat-callout {
        display: none !important;
    }

    .lamoi-chat-header {
        padding-top: max(12px, env(safe-area-inset-top));
    }

    /* Điện thoại: ưu tiên không gian hội thoại; tablet/laptop vẫn hiện đầy đủ tên trợ lý. */
    .lamoi-chat-header [data-chat-title],
    .lamoi-chat-header [data-chat-title] + span {
        display: none;
    }
}

/* v0.19.0 - tránh che phân trang/footer; launcher vẫn có thể kéo sang vị trí khác. */
.admin-body .lamoi-chat-widget { bottom: 92px; }
.admin-body .admin-main { padding-bottom: 96px; }
.lamoi-chat-widget.is-dragging { transition: none !important; user-select: none; }
.lamoi-chat-widget.is-dragging .lamoi-chat-launcher { cursor: grabbing; transform: none; }
.lamoi-chat-toolbar > div { display:flex; flex-direction:column; gap:2px; }
.lamoi-chat-toolbar [data-chat-training-hint] { font-size:9px; color:#68766c; font-weight:500; }
/* v0.25 - nhiều file đính kèm */
.lamoi-attachment-preview span{white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;line-height:1.35}
