* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: transparent;
    overflow: hidden;
}

.widget {
    position: relative;

    width: 100%;
    height: 100%;

    min-height: 100vh;
}

.launcher {
    position: absolute;

    right: 20px;
    bottom: 20px;

    width: 62px;
    height: 62px;

    border: 0;
    border-radius: 50%;

    background: #111827;
    color: #ffffff;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;

    box-shadow:
        0 12px 35px rgba(0, 0, 0, 0.22);

    transition:
        transform 0.2s ease,
        opacity 0.2s ease;
}

.launcher:hover {
    transform: translateY(-3px) scale(1.03);
}

.launcher.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.7);
}

.launcher-icon {
    font-size: 28px;
    line-height: 1;
}

.chat-window {
    position: absolute;

    right: 20px;
    bottom: 20px;

    width: min(
        calc(100% - 40px),
        390px
    );

    height: min(
        calc(100% - 40px),
        650px
    );

    min-height: 450px;

    display: flex;
    flex-direction: column;

    background: #ffffff;

    border: 1px solid #e5e7eb;

    border-radius: 20px;

    overflow: hidden;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.20);

    opacity: 0;

    visibility: hidden;

    transform:
        translateY(20px)
        scale(0.96);

    transform-origin:
        bottom right;

    transition:
        opacity 0.2s ease,
        transform 0.2s ease,
        visibility 0.2s ease;
}

.chat-window.open {
    opacity: 1;

    visibility: visible;

    transform:
        translateY(0)
        scale(1);
}

.chat-header {
    height: 68px;

    flex-shrink: 0;

    display: flex;
    align-items: center;

    padding: 10px 12px;

    border-bottom: 1px solid #e5e7eb;

    background: #ffffff;
}

.bot-avatar {
    width: 42px;
    height: 42px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #111827;

    color: #ffffff;

    font-size: 12px;
    font-weight: 700;
}

.bot-info {
    min-width: 0;

    margin-left: 10px;
}

.bot-info h1 {
    margin: 0;

    font-size: 15px;

    line-height: 1.3;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}

.bot-info span {
    display: flex;
    align-items: center;
    gap: 5px;

    margin-top: 3px;

    color: #64748b;

    font-size: 11px;
}

.bot-info span i {
    width: 6px;
    height: 6px;

    display: inline-block;

    border-radius: 50%;

    background: #22c55e;
}

.header-actions {
    margin-left: auto;

    display: flex;
    align-items: center;

    gap: 3px;
}

.header-button {
    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 9px;

    background: transparent;

    color: #64748b;

    font-size: 22px;

    cursor: pointer;

    transition:
        background 0.15s ease,
        color 0.15s ease;
}

.header-button:hover {
    background: #f1f5f9;
    color: #111827;
}

.close-button {
    font-size: 25px;
}

.messages {
    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding: 18px 14px;

    display: flex;
    flex-direction: column;

    gap: 12px;

    background: #ffffff;
}

.welcome {
    margin: auto;

    padding: 20px;

    color: #64748b;

    font-size: 14px;

    line-height: 1.6;

    text-align: center;
}

.message {
    width: 100%;

    display: flex;
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.bubble {
    max-width: 82%;

    padding: 10px 13px;

    border-radius: 14px;

    font-size: 14px;

    line-height: 1.55;

    white-space: pre-wrap;

    word-break: break-word;
}

.message.user .bubble {
    background: #111827;

    color: #ffffff;

    border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
    background: #f1f5f9;

    color: #111827;

    border-bottom-left-radius: 4px;
}

.chat-form {
    flex-shrink: 0;

    display: flex;

    align-items: flex-end;

    gap: 8px;

    padding: 10px;

    border-top: 1px solid #e5e7eb;

    background: #ffffff;
}

.chat-form textarea {
    flex: 1;

    width: 100%;

    min-height: 42px;
    max-height: 130px;

    resize: none;

    padding: 11px 12px;

    border: 1px solid #d1d5db;

    border-radius: 12px;

    outline: none;

    font-family: inherit;

    font-size: 14px;

    line-height: 1.4;

    background: #ffffff;

    color: #111827;
}

.chat-form textarea:focus {
    border-color: #111827;
}

.chat-form button {
    width: 42px;
    height: 42px;

    flex-shrink: 0;

    border: 0;

    border-radius: 12px;

    background: #111827;

    color: #ffffff;

    font-size: 18px;

    cursor: pointer;
}

.chat-form button:hover {
    opacity: 0.9;
}

.chat-form button:disabled {
    opacity: 0.5;

    cursor: not-allowed;
}

@media (max-width: 500px) {

    .launcher {
        right: 14px;
        bottom: 14px;

        width: 56px;
        height: 56px;
    }

    .chat-window {
        right: 10px;
        bottom: 10px;

        width: calc(100% - 20px);

        height: calc(100% - 20px);

        min-height: 0;

        border-radius: 16px;
    }

    .bubble {
        max-width: 88%;
    }
}