/**
 * WPMCP Chatbot frontend styles.
 */

.wpmcp-chatbot {
    --wpmcp-chatbot-main-color: #333333;
    --wpmcp-chatbot-on-main-color: #fff;
    --wpmcp-chatbot-user-bubble-color: #1b5f8f;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 99999;
    color: #1d2327;
}

.wpmcp-chatbot__toggle {
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: var(--wpmcp-chatbot-main-color);
    color: var(--wpmcp-chatbot-on-main-color);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    padding: 10px;
}

.wpmcp-chatbot__toggle-icon {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wpmcp-chatbot__panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    display: none;
    width: min(380px, calc(100vw - 32px));
    height: min(620px, 75vh);
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
    overflow: hidden;
}

.wpmcp-chatbot.is-open .wpmcp-chatbot__panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.wpmcp-chatbot__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 12px 14px;
    border-bottom: 1px solid #dcdcde;
    background: #f6f7f7;
}

.wpmcp-chatbot__header strong {
    min-width: 0;
    font-size: 15px;
    line-height: 1.3;
}

.wpmcp-chatbot__close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: #ddd;
    cursor: pointer;
    line-height: 1;
}

.wpmcp-chatbot__messages {
    min-height: 0;
    padding: 14px;
    overflow-y: auto;
    background: #fafafa;
}

.wpmcp-chatbot__message {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.wpmcp-chatbot__message--user {
    align-items: flex-end;
}

.wpmcp-chatbot__message--assistant {
    align-items: flex-start;
}

.wpmcp-chatbot__bubble {
    max-width: 88%;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.wpmcp-chatbot__message--user .wpmcp-chatbot__bubble {
    background: var(--wpmcp-chatbot-user-bubble-color);
    color: #fff;
    white-space: pre-wrap;
}

.wpmcp-chatbot__message--assistant .wpmcp-chatbot__bubble {
    background: var(--wpmcp-chatbot-main-color);
    border: 1px solid var(--wpmcp-chatbot-main-color);
    color: var(--wpmcp-chatbot-on-main-color);
    white-space: normal;
}

.wpmcp-chatbot.is-loading:not(.has-stream-content) .wpmcp-chatbot__message--assistant:last-child .wpmcp-chatbot__bubble {
    animation: wpmcp-chatbot-thinking-pulse 1.4s ease-in-out infinite;
}

.wpmcp-chatbot__bubble > :first-child {
    margin-top: 0;
}

.wpmcp-chatbot__bubble > :last-child {
    margin-bottom: 0;
}

.wpmcp-chatbot__message--assistant .wpmcp-chatbot__bubble p,
.wpmcp-chatbot__message--assistant .wpmcp-chatbot__bubble ul,
.wpmcp-chatbot__message--assistant .wpmcp-chatbot__bubble ol,
.wpmcp-chatbot__message--assistant .wpmcp-chatbot__bubble li,
.wpmcp-chatbot__message--assistant .wpmcp-chatbot__bubble strong,
.wpmcp-chatbot__message--assistant .wpmcp-chatbot__bubble em,
.wpmcp-chatbot__message--assistant .wpmcp-chatbot__bubble a {
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
}

.wpmcp-chatbot__bubble p {
    margin: 0 0 8px;
}

.wpmcp-chatbot__bubble ul,
.wpmcp-chatbot__bubble ol {
    margin: 6px 0 8px;
    padding-left: 20px;
    white-space: normal;
}

.wpmcp-chatbot__bubble li {
    margin: 2px 0;
}

.wpmcp-chatbot__bubble a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.wpmcp-chatbot__bubble img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 220px;
    margin: 8px 0;
    border-radius: 6px;
    object-fit: contain;
}

.wpmcp-chatbot__sources,
.wpmcp-chatbot__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 88%;
    margin-top: 7px;
}

.wpmcp-chatbot__sources span {
    flex-basis: 100%;
    color: #50575e;
    font-size: 12px;
}

.wpmcp-chatbot__sources a,
.wpmcp-chatbot__action {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 6px;
    background: #ddd;
    color: #222;
    font-size: 10px;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}

.wpmcp-chatbot__reasoning {
    max-width: 88%;
    margin-top: 7px;
    color: #50575e;
    font-size: 11px;
    line-height: 1.35;
}

.wpmcp-chatbot__reasoning summary {
    cursor: pointer;
}

.wpmcp-chatbot__reasoning p {
    margin: 6px 0 0;
}

.wpmcp-chatbot__privacy {
    padding: 10px 14px;
    border-top: 1px solid #dcdcde;
    background: #fff;
}

.wpmcp-chatbot__privacy[hidden] {
    display: none;
}

.wpmcp-chatbot__privacy p {
    margin: 0 0 8px;
    color: #50575e;
    font-size: 12px;
    line-height: 1.4;
}

.wpmcp-chatbot__privacy a {
    display: inline-block;
    margin-right: 8px;
    font-size: 12px;
}

.wpmcp-chatbot__privacy-accept {
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid var(--wpmcp-chatbot-main-color);
    border-radius: 6px;
    background: var(--wpmcp-chatbot-main-color);
    color: var(--wpmcp-chatbot-on-main-color);
    cursor: pointer;
    display:block;
    margin-top: 1em;
}

.wpmcp-chatbot__form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 12px;
    border-top: 1px solid #dcdcde;
    background: #fff;
    position: relative;
}

.wpmcp-chatbot__input {
    width: 100%;
    height: 44px;
    resize: vertical;
    border: 1px solid #8c8f94;
    border-radius: 6px;
    padding: 8px 76px 8px 10px;
    font: inherit;
    font-size: 14px;
    line-height: 1.35;
}

.wpmcp-chatbot__send {
    min-width: 68px;
    height: 44px;
    border: 0;
    border-radius: 6px;
    background: var(--wpmcp-chatbot-main-color);
    color: var(--wpmcp-chatbot-on-main-color);
    font-weight: 600;
    cursor: pointer;
    position:absolute;
    right:12px;
    bottom:12px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.wpmcp-chatbot__send:disabled,
.wpmcp-chatbot__input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@keyframes wpmcp-chatbot-thinking-pulse {
    0%,
    100% {
        opacity: 0.82;
    }

    50% {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wpmcp-chatbot.is-loading:not(.has-stream-content) .wpmcp-chatbot__message--assistant:last-child .wpmcp-chatbot__bubble {
        animation: none;
    }
}

@media (max-width: 480px) {
    .wpmcp-chatbot {
        right: 12px;
        bottom: 12px;
    }

    .wpmcp-chatbot__panel {
        right: -4px;
        bottom: 68px;
        width: calc(100vw - 24px);
        height: min(620px, 75vh);
    }

    .wpmcp-chatbot__bubble,
    .wpmcp-chatbot__sources,
    .wpmcp-chatbot__actions {
        max-width: 94%;
    }
}
