#webhat-ai-chat,
#webhat-ai-chat * {
    box-sizing: border-box;
}

#webhat-ai-chat {
    --whai-primary: #0f766e;
    --whai-text: #172026;
    --whai-muted: #637083;
    --whai-border: #dfe7ef;
    --whai-surface: #ffffff;
    --whai-user: #e8f7f4;
    --whai-input-bg: #ffffff;
    --whai-input-text: #172026;
    --whai-input-border: #dfe7ef;
    position: fixed;
    z-index: 999999;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#webhat-ai-chat.whai-chat--bottom-right {
    right: 20px;
}

#webhat-ai-chat.whai-chat--bottom-left {
    left: 20px;
    align-items: flex-start;
}

#webhat-ai-chat button,
#webhat-ai-chat textarea {
    font: inherit;
    letter-spacing: normal !important;
    text-transform: none !important;
}

.whai-greeting {
    max-width: 240px;
    border: 0;
    border-radius: 8px;
    padding: 10px 12px;
    color: #ffffff;
    background: var(--whai-primary);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
    cursor: pointer;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.whai-window {
    width: min(380px, calc(100vw - 32px));
    height: min(620px, calc(100vh - 120px));
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--whai-border);
    border-radius: 10px;
    background: var(--whai-surface);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.2);
}

.whai-chat--open .whai-window {
    display: flex;
}

.whai-chat--open .whai-greeting {
    display: none;
}

.whai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    color: #ffffff;
    background: var(--whai-primary);
}

.whai-title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.whai-title-image {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.22);
}

.whai-header strong,
.whai-header span {
    display: block;
}

.whai-header span {
    font-size: 12px;
    opacity: 0.85;
}

.whai-header .whai-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: max-content;
    opacity: 0.9;
}

.whai-header .whai-status-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.whai-icon-btn {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 7px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.18);
    cursor: pointer;
    padding: 5px;
    opacity: 0.96;
    transition: background-color 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.whai-icon-btn:hover,
.whai-icon-btn:focus {
    background: rgba(255, 255, 255, 0.28);
    opacity: 1;
}

.whai-icon-btn:active {
    transform: translateY(1px);
}

.whai-icon-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.82);
    outline-offset: 2px;
}

.whai-icon-btn svg {
    width: 20px;
    height: 20px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.whai-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    overflow: auto;
    background: #f7fafc;
}

.whai-message {
    max-width: 86%;
}

.whai-message--user {
    align-self: flex-end;
}

.whai-message--bot,
.whai-message--thinking {
    align-self: flex-start;
}

.whai-bubble {
    border-radius: 10px;
    padding: 11px 13px;
    color: var(--whai-text);
    background: #ffffff;
    border: 1px solid var(--whai-border);
    line-height: 1.58;
    font-size: 14.5px;
}

.whai-message--user .whai-bubble {
    color: #0f3d37;
    background: var(--whai-user);
    border-color: #c7ede6;
}

.whai-rich-text {
    display: grid;
    gap: 9px;
}

.whai-rich-text p,
.whai-rich-text ul,
.whai-rich-text ol {
    margin: 0;
}

.whai-rich-text ul,
.whai-rich-text ol {
    padding-left: 18px;
}

.whai-rich-text li + li {
    margin-top: 5px;
}

.whai-rich-text strong {
    font-weight: 750;
}

.whai-rich-heading {
    margin: 1px 0 2px;
    padding: 7px 9px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-left: 3px solid var(--whai-primary);
    border-radius: 7px;
    color: var(--whai-text);
    background: rgba(15, 118, 110, 0.06);
    background: color-mix(in srgb, var(--whai-primary) 7%, #ffffff);
    font-size: 14px;
    font-weight: 780;
    line-height: 1.35;
}

.whai-bubble a {
    color: var(--whai-primary);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}

.whai-bubble .whai-link-badge {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 26px;
    margin: 2px 2px 2px 0;
    padding: 5px 9px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-color: color-mix(in srgb, var(--whai-primary) 22%, transparent);
    border-radius: 999px;
    color: #ffffff;
    background: var(--whai-primary);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
    font-size: 12.5px;
    font-weight: 750;
    line-height: 1.2;
    text-decoration: none;
    vertical-align: baseline;
    white-space: normal;
    overflow-wrap: anywhere;
}

.whai-bubble .whai-link-badge:hover,
.whai-bubble .whai-link-badge:focus {
    filter: brightness(0.94);
    text-decoration: none;
}

.whai-bubble .whai-link-badge:focus-visible {
    outline: 2px solid #ffffff;
    outline: 2px solid color-mix(in srgb, var(--whai-primary) 35%, #ffffff);
    outline-offset: 2px;
}

.whai-sources {
    margin-top: 6px;
    font-size: 12px;
    color: var(--whai-muted);
}

.whai-sources a {
    color: var(--whai-primary);
}

.whai-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 92%;
    margin: -2px 0 2px;
}

.whai-quick-actions button,
.whai-feedback button,
.whai-contact-form button,
.whai-confirmation-actions button {
    border: 1px solid var(--whai-border);
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.2;
}

.whai-quick-actions button {
    min-height: 30px;
    padding: 5px 9px;
    color: var(--whai-primary);
    background: #ffffff;
    box-shadow: none;
    font-size: 12.5px;
    font-weight: 650;
}

.whai-contact-form,
.whai-confirmation {
    display: grid;
    gap: 9px;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--whai-border);
    border-radius: 8px;
    background: #ffffff;
}

.whai-contact-form label {
    display: grid;
    gap: 4px;
    color: var(--whai-muted);
    font-size: 12px;
    font-weight: 700;
}

.whai-contact-form input {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--whai-border);
    border-radius: 7px;
    padding: 8px 9px;
    color: var(--whai-text);
    background: #f8fafc;
}

.whai-contact-form input:focus {
    outline: none;
    border-color: var(--whai-primary);
    background: #ffffff;
}

.whai-contact-form button,
.whai-confirmation-actions button {
    min-height: 38px;
    padding: 8px 10px;
    color: #ffffff;
    background: var(--whai-primary);
    border-color: var(--whai-primary);
    font-weight: 700;
}

.whai-confirmation div {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 8px;
    font-size: 13px;
}

.whai-confirmation strong {
    color: var(--whai-muted);
}

.whai-confirmation p {
    margin: 0;
    white-space: pre-wrap;
    color: var(--whai-text);
    font-size: 13px;
}

.whai-confirmation-actions {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 8px;
    flex-wrap: wrap;
}

.whai-confirmation-actions .whai-secondary-action {
    color: var(--whai-text);
    background: #ffffff;
    border-color: var(--whai-border);
}

.whai-feedback {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    color: var(--whai-muted);
    font-size: 12px;
}

.whai-feedback button {
    min-height: 26px;
    padding: 4px 8px;
    color: var(--whai-text);
    background: #ffffff;
}

.whai-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--whai-border);
    background: #ffffff;
}

.whai-form textarea {
    flex: 1;
    height: 82px;
    min-height: 82px;
    max-height: 142px;
    resize: none;
    overflow-y: auto;
    border: 1px solid var(--whai-input-border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--whai-input-text);
    background: var(--whai-input-bg);
    caret-color: var(--whai-input-text);
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 112, 131, 0.34) transparent;
    transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.whai-form textarea::-webkit-scrollbar {
    width: 6px;
}

.whai-form textarea::-webkit-scrollbar-track {
    background: transparent;
}

.whai-form textarea::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(99, 112, 131, 0.28);
}

.whai-form textarea::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 112, 131, 0.42);
}

.whai-form textarea::-webkit-scrollbar-button {
    width: 0;
    height: 0;
    display: none;
}

.whai-form textarea::placeholder {
    color: var(--whai-input-text);
    opacity: 0.62;
}

.whai-form textarea:focus {
    outline: none;
    border-color: var(--whai-input-focus-border);
    background: var(--whai-input-focus-bg);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.whai-send {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-color: color-mix(in srgb, var(--whai-primary) 28%, transparent);
    border-radius: 10px;
    color: #ffffff;
    background: var(--whai-primary);
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
    transition: transform 0.16s ease, filter 0.16s ease, opacity 0.16s ease;
}

.whai-send:hover,
.whai-send:focus {
    filter: brightness(0.96);
}

.whai-send:active {
    transform: translateY(1px);
}

.whai-send:disabled {
    cursor: default;
    opacity: 0.82;
}

.whai-send svg {
    width: 20px;
    height: 20px;
    display: block;
    fill: currentColor;
}

.whai-send-loader {
    width: 24px;
    min-width: 24px;
    height: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.whai-send-loader span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.42;
    animation: whai-send-dot 0.96s ease-in-out infinite;
}

.whai-send-loader span:nth-child(2) {
    animation-delay: 0.12s;
}

.whai-send-loader span:nth-child(3) {
    animation-delay: 0.24s;
}

.whai-send.is-loading .whai-send-icon {
    display: none;
}

.whai-send.is-loading .whai-send-loader {
    display: inline-flex;
}

.whai-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes whai-send-dot {
    0%,
    80%,
    100% {
        opacity: 0.42;
        transform: translateY(0) scale(0.86);
    }

    40% {
        opacity: 1;
        transform: translateY(-2px) scale(1);
    }
}

.whai-toggle {
    width: 62px;
    height: 62px;
    border: 1px solid rgba(112, 48, 144, 0.18);
    border-radius: 50%;
    color: var(--whai-primary);
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
    cursor: pointer;
    font-weight: 700;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#webhat-ai-chat .whai-toggle,
#webhat-ai-chat .whai-toggle:hover,
#webhat-ai-chat .whai-toggle:focus {
    color: var(--whai-primary) !important;
    background: #ffffff !important;
}

#webhat-ai-chat .whai-toggle:hover,
#webhat-ai-chat .whai-toggle:focus {
    border-color: rgba(112, 48, 144, 0.3) !important;
    background: #fbf8ff !important;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.18);
}

#webhat-ai-chat .whai-toggle:active {
    background: #f7f0fb !important;
    transform: translateY(1px);
}

.whai-toggle img {
    width: 72%;
    height: 72%;
    display: block;
    border-radius: 0;
    filter: none !important;
    opacity: 1;
    object-fit: contain;
}

.whai-toggle span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

@media (max-width: 520px) {
    #webhat-ai-chat {
        right: 12px;
        left: 12px;
        bottom: 12px;
        align-items: flex-end;
    }

    #webhat-ai-chat.whai-chat--bottom-left {
        align-items: flex-start;
    }

    .whai-window {
        width: calc(100vw - 24px);
        height: min(620px, calc(100vh - 100px));
    }
}
