/* Scope everything under .mst-chat-widget */
.mst-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    box-sizing: border-box;
    z-index: 99999;
}

.mst-chat-widget * {
    box-sizing: border-box;
}

/* Floating Mode */
.mst-chat-widget[data-mode="floating"] {
    position: fixed;
    bottom: 20px;
    right: 20px;
}

/* Shortcode Mode */
.mst-chat-widget[data-mode="shortcode"] {
    position: relative;
    display: inline-block;
    margin: 10px;
}

/* Bubble */
.mst-chat-bubble {
    width: 60px;
    height: 60px;
    background-color: var(--mst-bubble-color, #0073aa);
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: transform 0.3s ease, background-color 0.2s;
    outline: none;
    padding: 0;
}

.mst-chat-bubble:hover,
.mst-chat-bubble:focus {
    transform: scale(1.05);
    filter: brightness(0.9);
}

.mst-chat-bubble svg {
    display: block;
}

/* Menu Selector */
.mst-chat-menu {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 200px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.2s cubic-bezier(0.19, 1, 0.22, 1);
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

/* Shortcode Mode specific menu position */
.mst-chat-widget[data-mode="shortcode"] .mst-chat-menu {
    bottom: auto;
    top: 70px;
    right: auto;
    left: 0;
    transform-origin: top left;
}

/* Open State */
.mst-chat-widget.mst-open .mst-chat-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Greeting */
.mst-chat-greeting {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    color: #666;
    background: #f9f9f9;
    text-align: center;
}

/* Menu Items */
.mst-chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.1s;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.mst-chat-item:last-child {
    border-bottom: none;
}

.mst-chat-item:hover,
.mst-chat-item:focus {
    background-color: #f5f5f5;
    color: #0073aa;
}

.mst-chat-icon {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #fff;
    font-weight: bold;
    font-size: 10px;
}

.mst-chat-icon.zalo { background-color: #0068FF; }
.mst-chat-icon.messenger { background-color: #0084FF; }
.mst-chat-icon.telegram { background-color: #24A1DE; }

/* Hidden State (Scroll) */
.mst-chat-widget.mst-hidden .mst-chat-bubble {
    transform: translateY(100px);
    opacity: 0;
}

/* Ensure menu is hidden properly */
.mst-chat-menu[hidden] {
    display: none !important;
}

/* Icon Styles */
.mst-bubble-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.mst-bubble-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.mst-chat-icon-img {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    margin-right: 12px;
    object-fit: contain;
    display: block;
}

.mst-chat-icon-emoji {
    font-size: 16px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

/* SVG Support */
.mst-svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mst-svg svg {
    width: 18px;
    height: 18px;
    display: block;
}

.mst-bubble-icon.mst-svg svg {
    width: 24px;
    height: 24px;
}

.mst-chat-item .mst-svg {
    margin-right: 12px;
}

/* Zalo Loading State */
.mst-chat-item.zalo_loading {
    pointer-events: none;
    opacity: 0.5;
    cursor: wait;
}
