/* Chat AI tư vấn khách — dùng token trong variable.css, font tối thiểu 14px */
.fe-sticky-chat { background: var(--red); font-size: 19px; }

.fe-chat {
    /* z-index cao hơn thanh menu (.fe-nav = 400) và cao tối đa vừa dưới nó (nav 70px + thanh tab dự án + khoảng hở)
       để tiêu đề khung không bị menu che trên màn hình PC thấp. */
    position: fixed; right: 74px; bottom: 24px; z-index: 450;
    width: 520px; max-width: calc(100vw - 90px);
    height: min(680px, calc(100vh - 140px)); min-height: 320px;
    display: flex; flex-direction: column;
    background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(0,0,0,.2); overflow: hidden;
}
.fe-chat[hidden] { display: none; }

.fe-chat-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; background: var(--red); color: #fff; font-size: var(--fs-md); font-weight: 700;
}
.fe-chat-title i { margin-right: 6px; }
.fe-chat-actions { display: flex; align-items: center; gap: 2px; }
.fe-chat-close { background: none; border: none; color: #fff; font-size: var(--fs-md); cursor: pointer; padding: 4px 8px; }

.fe-chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--light); }
.fe-chat-msg { max-width: 90%; padding: 10px 14px; border-radius: 12px; font-size: var(--fs-md); line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.fe-chat-msg.bot  { align-self: flex-start; background: var(--white); border: 1px solid var(--border); color: var(--text); }
/* Link trong bong bóng: không tràn khung, gạch chân khi hover */
.fe-chat-msg { overflow-wrap: anywhere; }
.fe-chat-link { color: var(--red); font-weight: 500; text-decoration: none; word-break: break-word; }
.fe-chat-link:hover { text-decoration: underline; }
.fe-chat-msg.user { align-self: flex-end; background: var(--red); color: #fff; }
.fe-chat-msg.err  { align-self: flex-start; background: var(--red-soft); color: var(--red-dark); }
.fe-chat-typing   { color: var(--muted); font-style: italic; }

/* Khách chưa đăng nhập: chỉ hiện lời mời đăng nhập, ẩn ô nhập, nút làm mới và dòng ghi chú */
.fe-chat.is-guest .fe-chat-form,
.fe-chat.is-guest #feChatNew,
.fe-chat.is-guest .fe-chat-note { display: none; }
.fe-chat-login { margin: auto; text-align: center; padding: 24px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.fe-chat-login-icon { font-size: 40px; line-height: 1; }
.fe-chat-login-msg { font-size: var(--fs-md); color: var(--text); line-height: 1.55; max-width: 320px; }
.fe-chat-login-btn { display: inline-block; padding: 10px 28px; border-radius: 8px; background: var(--red); color: #fff !important; font-size: var(--fs-md); font-weight: 700; text-decoration: none; }
.fe-chat-login-btn:hover { background: var(--red-dark); }
.fe-chat-login-reg { font-size: var(--fs-sm); color: var(--red); text-decoration: none; }
.fe-chat-login-reg:hover { text-decoration: underline; }

.fe-chat-note { padding: 6px 12px; font-size: var(--fs-sm); color: var(--muted); border-top: 1px solid var(--border); background: var(--white); }

.fe-chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--white); }
.fe-chat-input { flex: 1; min-width: 0; font-size: var(--fs-md); padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.fe-chat-input:focus { outline: none; border-color: var(--red); }
.fe-chat-send { width: 42px; border: none; border-radius: 8px; background: var(--red); color: #fff; font-size: var(--fs-md); cursor: pointer; }
.fe-chat-send:disabled { opacity: .5; cursor: not-allowed; }

/* Mobile: khung full-width dạng bottom sheet; ẩn cụm nút nổi khi đang mở để không đè nút Zalo */
@media (max-width: 576px) {
    .fe-chat {
        left: 0; right: 0; bottom: 0; width: auto; max-width: none;
        height: 88vh; max-height: 88vh; border-radius: var(--radius) var(--radius) 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    body.fe-chat-open .fe-sticky { display: none; }
}
