.wpw-ai-bar,
.wpw-ai-modal,
.wpw-ai-bar *,
.wpw-ai-modal * {
    box-sizing: border-box;
}

.wpw-ai-bar,
.wpw-ai-modal {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #131314;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.wpw-ai-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--wpw-ai-bar-offset, 0px) + var(--wpw-ai-dock-bottom, 16px));
    z-index: 9000;
    padding: 0 16px;
    padding-right: var(--wpw-ai-dock-right, 16px);
    --wpw-ai-form-height: 56px;
    transform: translateY(calc(100% + var(--wpw-ai-dock-bottom, 16px)));
    opacity: 0;
    pointer-events: none;
    transition: transform .25s ease, opacity .25s ease;
}

.wpw-ai-bar.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.wpw-ai-bar.is-visible .wpw-ai-bar__form,
.wpw-ai-bar.is-visible .wpw-ai-bar__toggle {
    pointer-events: auto;
}

.wpw-ai-bar__inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 100%;
}

.wpw-ai-bar__container {
    width: min(320px, 100%);
    max-width: 100%;
}

.wpw-ai-bar.is-active .wpw-ai-bar__container {
    width: min(480px, 100%);
}

.wpw-ai-bar__form {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: var(--wpw-ai-form-height, 56px);
    margin: 0;
    padding: 8px;
    border-radius: calc(var(--wpw-ai-form-height, 56px) / 2);
    background: #fff;
    box-shadow: 0 4px 24px #13131426;
    pointer-events: none;
}

.wpw-ai-bar__toggle {
    display: none !important;
}

.wpw-ai-bar__icon,
.wpw-ai-bar__toggle-icon {
    display: block;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    object-fit: cover;
}

.wpw-ai-bar__icon {
    margin-left: 4px;
}

.wpw-ai-fallback-icon {
    align-items: center;
    justify-content: center;
    background: #131314;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.wpw-ai-bar__input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    height: calc(var(--wpw-ai-form-height, 56px) - 16px);
    border: 0;
    border-radius: calc((var(--wpw-ai-form-height, 56px) - 16px) / 2);
}

.wpw-ai-bar__input-wrap::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(to left, #fff 0, #ffffff00 24px);
}

.wpw-ai-bar__input {
    width: 100%;
    height: calc(var(--wpw-ai-form-height, 56px) - 18px);
    margin: 0 !important;
    padding: 0 12px !important;
    border: 0 !important;
    border-radius: 0;
    box-shadow: none !important;
    font-family: inherit;
    font-size: 1rem !important;
    line-height: 1.5 !important;
    color: #131314;
    background: transparent !important;
}

.wpw-ai-bar__input:focus {
    outline: none;
    border: 0 !important;
    box-shadow: none !important;
}

.wpw-ai-bar__input::placeholder {
    color: #6c727a;
    opacity: 1;
    transition: opacity .3s ease;
}

.wpw-ai-bar__input.is-placeholder-fading::placeholder {
    opacity: 0;
}

.wpw-ai-bar__submit,
.wpw-ai-modal__submit {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 100px;
    background: #136deb;
    color: #fff;
    cursor: pointer;
    box-shadow: none;
}

.wpw-ai-bar__submit {
    width: calc(var(--wpw-ai-form-height, 56px) - 16px);
    height: calc(var(--wpw-ai-form-height, 56px) - 16px);
}

.wpw-ai-bar__submit:hover,
.wpw-ai-modal__submit:hover {
    background: #2466c3;
    color: #fff;
}

.wpw-ai-bar__submit:disabled,
.wpw-ai-modal__submit:disabled {
    background: #6c727a;
    cursor: default;
    pointer-events: none;
}

.wpw-ai-bar__submit:focus-visible,
.wpw-ai-bar__toggle:focus-visible,
.wpw-ai-modal__close:focus-visible,
.wpw-ai-modal__submit:focus-visible,
.wpw-ai-modal__input:focus-visible {
    outline: 2px solid #136deb;
    outline-offset: 2px;
}

.wpw-ai-modal {
    display: none;
    position: fixed;
    top: var(--wpw-ai-vv-top, 0px);
    left: 0;
    width: 100%;
    max-width: 100%;
    height: var(--wpw-ai-vv-height, 100svh);
    z-index: 10000000000;
    background: #0006;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    overflow: hidden;
}

.wpw-ai-modal.is-open {
    display: flex;
}

.wpw-ai-modal__card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(760px, 100%);
    height: min(720px, calc(var(--wpw-ai-vv-height, 85svh) - 48px));
    max-height: calc(var(--wpw-ai-vv-height, 100svh) - 24px);
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
}

.wpw-ai-modal__toolbar {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    height: 60px;
    padding: 12px 20px;
    border-bottom: 1px solid #dadbd9;
    background: #fff;
}

.wpw-ai-modal__icon {
    display: block;
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    border-radius: 9px;
    object-fit: cover;
}

.wpw-ai-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px #13131426;
    color: #4f5661;
    cursor: pointer;
}

.wpw-ai-modal__close:hover {
    background: #f6f8f9;
    color: #4f5661;
}

.wpw-ai-modal__skeleton {
    position: absolute;
    top: 60px;
    right: 0;
    bottom: 96px;
    left: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    background: #fff;
}

.wpw-ai-modal__skeleton.is-hidden {
    display: none;
}

.wpw-ai-modal__skeleton-line {
    height: 20px;
    border-radius: 6px;
    background: #13131412;
    animation: wpw-ai-skeleton-pulse 1.2s ease-in-out infinite;
}

.wpw-ai-modal__skeleton-line:nth-child(1) {
    width: 60%;
    align-self: flex-end;
}

.wpw-ai-modal__skeleton-line:nth-child(2) {
    width: 85%;
}

.wpw-ai-modal__skeleton-line:nth-child(3) {
    width: 70%;
}

.wpw-ai-chat {
    position: absolute;
    top: 60px;
    right: 0;
    bottom: 96px;
    left: 0;
    overflow-y: auto;
    padding: 20px 24px 24px;
    background: #fff;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.wpw-ai-message {
    display: flex;
    margin: 0 0 16px;
}

.wpw-ai-message--user {
    justify-content: flex-end;
}

.wpw-ai-message__bubble {
    max-width: 82%;
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.wpw-ai-message--user .wpw-ai-message__bubble {
    background: #136deb;
    color: #fff;
    border-bottom-right-radius: 5px;
}

.wpw-ai-message--assistant .wpw-ai-message__bubble {
    background: #f6f8f9;
    color: #131314;
    border-bottom-left-radius: 5px;
}

.wpw-ai-message--error .wpw-ai-message__bubble {
    background: #fff2f0;
    color: #8a1f17;
}

.wpw-ai-message--loading .wpw-ai-message__bubble {
    color: #6c727a;
}

.wpw-ai-modal__composer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    height: 96px;
    padding: 16px 20px;
    border-top: 1px solid #dadbd9;
    background: #fff;
}

.wpw-ai-modal__composer-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px;
    border: 1px solid #dadbd9;
    border-radius: 32px;
    background: #fff;
}

.wpw-ai-modal__input {
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 8px 8px 8px 12px;
    border: 0 !important;
    border-radius: 0;
    box-shadow: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    color: #131314;
    background: transparent;
}

.wpw-ai-modal__input:focus {
    outline: none;
    border: 0 !important;
    box-shadow: none;
}

.wpw-ai-modal__input::placeholder {
    color: #6c727a;
    opacity: 1;
}

@keyframes wpw-ai-skeleton-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: .4;
    }
}

body.wpw-ai-modal-open {
    overflow: hidden;
}

body.wpw-ai-modal-open .wpw-ai-bar {
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 1024px) {
    .wpw-ai-bar {
        padding: 0 12px;
        padding-right: var(--wpw-ai-dock-right, 92px);
        bottom: calc(var(--wpw-ai-bar-offset, 0px) + var(--wpw-ai-dock-bottom, 20px));
    }

    .wpw-ai-bar__inner {
        justify-content: flex-end;
    }

    .wpw-ai-bar__container,
    .wpw-ai-bar.is-active .wpw-ai-bar__container {
        width: min(280px, 100%);
        max-width: 100%;
        flex: 0 1 auto;
        margin-left: auto;
    }

    .wpw-ai-modal {
        padding: 10px 12px;
    }

    .wpw-ai-modal__card {
        width: 100%;
        height: min(560px, calc(var(--wpw-ai-vv-height, 100svh) - 20px));
        max-height: calc(var(--wpw-ai-vv-height, 100svh) - 20px);
        border-radius: 14px;
    }
}

@media (max-width: 767px) {
    .wpw-ai-bar {
        padding: 0 12px;
        padding-right: var(--wpw-ai-dock-right, 92px);
    }

    .wpw-ai-modal {
        padding: 8px 12px;
    }

    .wpw-ai-modal__card {
        height: min(72%, 520px);
        max-height: calc(var(--wpw-ai-vv-height, 100svh) - 16px);
        border-radius: 12px;
    }

    .wpw-ai-modal__toolbar {
        height: 52px;
        padding: 8px 12px;
    }

    .wpw-ai-modal__icon,
    .wpw-ai-modal__close {
        width: 32px;
        height: 32px;
    }

    .wpw-ai-chat,
    .wpw-ai-modal__skeleton {
        top: 52px;
        bottom: 88px;
        padding: 14px 12px 16px;
    }

    .wpw-ai-modal__composer {
        height: 88px;
        padding: 12px;
    }

    .wpw-ai-message__bubble {
        max-width: 88%;
        font-size: 14px;
    }

    .wpw-ai-message__link-row {
        margin-top: 10px;
    }

    .wpw-ai-message--assistant .wpw-ai-message__bubble a {
        padding: 8px 0;
    }
}

.wpw-ai-message--assistant .wpw-ai-message__bubble a {
    display: inline-block;
    max-width: 100%;
    padding: 6px 0;
    color: #136deb;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.wpw-ai-message__link-row {
    display: block;
    margin: 8px 0 0;
}

.wpw-ai-message--assistant .wpw-ai-message__bubble a:hover,
.wpw-ai-message--assistant .wpw-ai-message__bubble a:focus {
    color: #0f5bc4;
}

@media (prefers-reduced-motion: reduce) {
    .wpw-ai-bar,
    .wpw-ai-bar__input::placeholder,
    .wpw-ai-modal__skeleton-line {
        transition: none;
        animation: none;
    }
}
