/* Apple Minimalist Floating LiveChat Widget */
.tw-widget-container {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Position Left (Avoid Messenger/Zalo Collisions) */
.tw-widget-container.tw-pos-bottom-left {
    left: 24px;
    right: auto;
}
.tw-widget-container.tw-pos-bottom-left .tw-chat-box {
    left: 0;
    right: auto;
}

/* Position Right */
.tw-widget-container.tw-pos-bottom-right {
    right: 24px;
    left: auto;
}
.tw-widget-container.tw-pos-bottom-right .tw-chat-box {
    right: 0;
    left: auto;
}

/* Floating Trigger Button */
.tw-chat-trigger {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--tw-theme-color, #0071e3);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 113, 227, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}
.tw-chat-trigger:hover {
    transform: scale(1.06);
    box-shadow: 0 12px 30px rgba(0, 113, 227, 0.45);
}

/* Teaser Popup Welcome Tooltip */
.tw-chat-teaser {
    position: absolute;
    bottom: 70px;
    width: 250px;
    background: #ffffff;
    border: 1px solid #e5e5ea;
    border-radius: 14px;
    padding: 10px 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
    animation: twPop 0.3s ease;
}
.tw-pos-bottom-left .tw-chat-teaser {
    left: 0;
}
.tw-pos-bottom-right .tw-chat-teaser {
    right: 0;
}
.tw-teaser-close {
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 16px;
    color: #86868b;
    cursor: pointer;
}
.tw-teaser-body {
    display: flex;
    align-items: center;
    gap: 10px;
}
.tw-teaser-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.tw-teaser-text {
    font-size: 12px;
    color: #1d1d1f;
    line-height: 1.35;
    font-weight: 500;
}

.tw-chat-box {
    position: absolute;
    bottom: 74px;
    width: 360px;
    height: 500px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid #d2d2d7;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: twPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes twPop {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.tw-chat-header {
    background: var(--tw-theme-color, #0071e3);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.tw-avatar-wrap {
    position: relative;
    width: 40px;
    height: 40px;
}
.tw-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ffffff;
}
.tw-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #34c759;
    border: 2px solid #ffffff;
}
.tw-header-info {
    flex: 1;
}
.tw-bot-name {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
}
.tw-bot-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
}
.tw-close-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
}
.tw-chat-body {
    flex: 1;
    padding: 16px;
    background: #f5f5f7;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.tw-msg {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}
.tw-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.tw-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #e5e5ea;
}
.tw-msg-bot {
    align-self: flex-start;
}
.tw-msg-user {
    align-self: flex-end;
}
.tw-msg-admin {
    align-self: flex-start;
}
.tw-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
}
.tw-msg-bot .tw-msg-bubble {
    background: #ffffff;
    color: #1d1d1f;
    border: 1px solid #e5e5ea;
    border-top-left-radius: 4px;
}
.tw-msg-user .tw-msg-bubble {
    background: var(--tw-theme-color, #0071e3);
    color: #ffffff;
    border-top-right-radius: 4px;
}
.tw-msg-admin .tw-msg-bubble {
    background: #34c759;
    color: #ffffff;
    border-top-left-radius: 4px;
}
.tw-msg-time {
    font-size: 10px;
    color: #86868b;
    margin-top: 3px;
}
.tw-chat-footer {
    padding: 12px;
    background: #ffffff;
    border-top: 1px solid #e5e5ea;
    display: flex;
    gap: 8px;
}
.tw-chat-footer input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #d2d2d7;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
}
.tw-chat-footer input:focus {
    border-color: var(--tw-theme-color, #0071e3);
}
.tw-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--tw-theme-color, #0071e3);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}