.wdp-ai-chat-toggle {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #2271b1;
    border: none;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wdp-ai-chat-toggle:hover {
    background: #135e96;
}

.wdp-ai-chat-toggle[hidden] {
    display: none;
}


.wdp-ai-chat-toggle .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

/* bottom/max-height reclaim the toggle button's own space (52px tall, 24px from the
   viewport edge) - the panel is only ever shown while the toggle is hidden (see
   AiChat.open()/close() in ai-chat.js), so there's nothing left to avoid overlapping there */
.wdp-ai-chat-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 360px;
    min-width: 300px;
    max-width: calc(100vw - 48px);
    height: 480px;
    min-height: 320px;
    max-height: calc(100vh - 76px);
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wdp-ai-chat-panel[hidden] {
    display: none;
}

body.wdp-ai-chat-resizing {
    user-select: none;
}

.wdp-ai-chat-resize {
    position: absolute;
    z-index: 2;
}

.wdp-ai-chat-resize-w {
    top: 0;
    left: 0;
    width: 10px;
    height: 100%;
    cursor: ew-resize;
}

.wdp-ai-chat-resize-h {
    top: 0;
    left: 0;
    width: 100%;
    height: 10px;
    cursor: ns-resize;
}

.wdp-ai-chat-panel.wdp-ai-chat-maximized .wdp-ai-chat-resize {
    display: none;
}

.wdp-ai-chat-panel.wdp-ai-chat-maximized {
    resize: none;
    top: auto;
    left: 16px;
    right: 16px;
    bottom: 0;
    width: auto;
    height: 50vh;
    max-width: none;
    max-height: none;
    border-radius: 8px 8px 0 0;
}

/* matches .wdp-ai-chat-maximized's height above, so the tab's content can still be
   scrolled past the maximized chat panel instead of its last part staying hidden behind
   it - applied to the whole postbox-container (not just #rules-container) so the empty
   space lands after the pagination/"Add rule" controls that follow the rule rows, not
   immediately after the last rule row itself */
body.wdp-ai-chat-maximized-active #postbox-container-2 {
    padding-bottom: 50vh;
}

/* tabs without a rules list: same spacer, as a margin under the tab's content wrapper */
body.wdp-ai-chat-maximized-active .wdp_settings:not(:has(#postbox-container-2)) {
    margin-bottom: 50vh;
}

.wdp-ai-chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f6f7f7;
    border-bottom: 1px solid #dcdcde;
    font-weight: 600;
    font-size: 13px;
    color: #1d2327;
}

.wdp-ai-chat-header span {
    flex: 1;
}

.wdp-ai-chat-minimize,
.wdp-ai-chat-maximize {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #646970;
    font-size: 16px;
    line-height: 1;
    padding: 2px 4px;
    display: flex;
    align-items: center;
}

.wdp-ai-chat-minimize:hover,
.wdp-ai-chat-maximize:hover {
    color: #1d2327;
}

.wdp-ai-chat-minimize .dashicons,
.wdp-ai-chat-maximize .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.wdp-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wdp-ai-chat-message {
    max-width: 85%;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.wdp-ai-chat-message-user {
    align-self: flex-end;
    background: #2271b1;
    color: #fff;
    border-bottom-right-radius: 2px;
}

.wdp-ai-chat-message-assistant {
    align-self: flex-start;
    background: #f0f0f1;
    color: #1d2327;
    border-bottom-left-radius: 2px;
}

.wdp-ai-chat-message-assistant.wdp-ai-chat-pending {
    color: #646970;
}

.wdp-ai-chat-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.wdp-ai-chat-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .4;
    animation: wdp-ai-chat-typing-bounce 1.2s infinite ease-in-out;
}

.wdp-ai-chat-typing-dots span:nth-child(2) {
    animation-delay: .2s;
}

.wdp-ai-chat-typing-dots span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes wdp-ai-chat-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: .4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.wdp-ai-chat-message-assistant.wdp-ai-chat-error {
    background: #fcf0f1;
    color: #d63638;
}

.wdp-ai-chat-loading,
.wdp-ai-chat-empty,
.wdp-ai-chat-error {
    color: #646970;
    font-size: 12px;
    text-align: center;
    padding: 12px 0;
}

.wdp-ai-chat-compose {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid #dcdcde;
}

.wdp-ai-chat-input {
    width: 100%;
    resize: none;
    font-size: 13px;
    box-sizing: border-box;
}

.wdp-ai-chat-compose-footer {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wdp-ai-chat-context {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #2271b1;
    background: #f0f6fc;
    border: 1px solid #c5d9ed;
    border-radius: 10px;
    padding: 3px 6px 3px 10px;
}

.wdp-ai-chat-context[hidden] {
    display: none;
}

.wdp-ai-chat-context-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wdp-ai-chat-context-remove {
    flex-shrink: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #2271b1;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}

.wdp-ai-chat-context-remove:hover {
    color: #135e96;
}

.wdp-ai-chat-send {
    flex-shrink: 0;
    /* keeps it pinned to the right of .wdp-ai-chat-compose-footer whether or not the
       context badge next to it is present (flex:1 isn't there to do that job when it's
       hidden) */
    margin-left: auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #2271b1;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.wdp-ai-chat-send:hover:not(:disabled) {
    background: #135e96;
}

.wdp-ai-chat-send:disabled {
    background: #dcdcde;
    color: #a7aaad;
    cursor: default;
}

.wdp-ai-chat-send .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.wdp-ai-chat-nav-tab {
    background: #2271b1 !important;
    color: #fff !important;
}

.wdp-ai-chat-nav-tab:hover,
.wdp-ai-chat-nav-tab:focus {
    background: #135e96 !important;
    color: #fff !important;
}

.wdp-ai-chat-empty a {
    color: #2271b1;
}

.wdp-ai-chat-compose[hidden] {
    display: none;
}

.wdp-ai-chat-message-link {
    display: inline-block;
    margin-top: 6px;
    font-weight: 600;
}
