/*
 * Every rule is scoped under #ej-chat-widget-root so it can never leak
 * onto the host theme, and the root resets inherited styles so the host
 * theme can never leak into the widget either.
 */
#ej-chat-widget-root {
    all: initial;
    display: block;
    --ejc-accent: #1A1A2E;
    --ejc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    position: fixed;
    z-index: 999999;
    bottom: 20px;
    font-family: var(--ejc-font);
    font-size: 13px;
    line-height: 1.4;
}

#ej-chat-widget-root * {
    box-sizing: border-box;
    font-family: inherit;
}

#ej-chat-widget-root.ej-bottom-right { right: 20px; }
#ej-chat-widget-root.ej-bottom-left { left: 20px; }

#ej-chat-widget-root .ejc-bubble {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: var(--ejc-accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    animation: ejc-bounce 6s ease-in-out infinite;
}

#ej-chat-widget-root .ejc-bubble-icon {
    width: 28px;
    height: 28px;
}

@keyframes ejc-bounce {
    0%, 88%, 100% { transform: translateY(0); }
    92% { transform: translateY(-8px); }
    96% { transform: translateY(0); }
}

#ej-chat-widget-root .ejc-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 330px;
    max-height: 460px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.22);
    display: none !important;
    flex-direction: column;
    overflow: hidden;
}

#ej-chat-widget-root .ejc-panel.ejc-open {
    display: flex !important;
}

#ej-chat-widget-root.ej-bottom-left .ejc-panel { right: auto; left: 0; }

#ej-chat-widget-root .ejc-header {
    background: var(--ejc-accent);
    color: #fff;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
}

#ej-chat-widget-root .ejc-header-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#ej-chat-widget-root .ejc-header-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

#ej-chat-widget-root .ejc-download,
#ej-chat-widget-root .ejc-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
}

#ej-chat-widget-root .ejc-close { font-size: 20px; }

#ej-chat-widget-root .ejc-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    min-height: 220px;
    max-height: 300px;
    font-size: 13px;
    background: #fafafa;
}

#ej-chat-widget-root .ejc-message {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    max-width: 85%;
    line-height: 1.4;
    word-wrap: break-word;
}

#ej-chat-widget-root .ejc-message p {
    margin: 0 0 8px 0;
}

#ej-chat-widget-root .ejc-message p:last-child {
    margin-bottom: 0;
}

#ej-chat-widget-root .ejc-message strong {
    font-weight: 700;
}

#ej-chat-widget-root .ejc-message-assistant {
    background: #f1f0f4;
    color: #1A1A2E;
}

#ej-chat-widget-root .ejc-message-user {
    background: var(--ejc-accent);
    color: #fff;
    margin-left: auto;
}

#ej-chat-widget-root .ejc-attachment-image {
    display: block;
    max-width: 100%;
    border-radius: 8px;
    margin-top: 6px;
}

#ej-chat-widget-root .ejc-attachment-badge {
    display: inline-block;
    margin-top: 6px;
    color: inherit;
    text-decoration: underline;
    font-size: 12px;
}

#ej-chat-widget-root .ejc-attachment-preview {
    padding: 6px 12px;
    font-size: 12px;
    color: #3c434a;
    background: #f0f0f1;
    border-top: 1px solid #eae6de;
}

#ej-chat-widget-root .ejc-attachment-error {
    color: #B3462C;
}

#ej-chat-widget-root .ejc-form {
    display: flex;
    align-items: center;
    border-top: 1px solid #eae6de;
    background: #fff;
}

#ej-chat-widget-root .ejc-attach {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 0 8px;
    color: #6B6B78;
}

#ej-chat-widget-root .ejc-input {
    flex: 1;
    border: none;
    padding: 10px 6px;
    font-size: 13px;
    outline: none;
    color: #1A1A2E !important;
    background: #fff !important;
}

#ej-chat-widget-root .ejc-input::placeholder {
    color: #6B6B78 !important;
    opacity: 1 !important;
}

#ej-chat-widget-root .ejc-send {
    border: none;
    background: var(--ejc-accent);
    color: #fff;
    padding: 0 14px;
    height: 40px;
    cursor: pointer;
    font-size: 13px;
}

@media (max-width: 480px) {
    #ej-chat-widget-root .ejc-panel {
        width: calc(100vw - 32px);
    }
}
