* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #111827;
}

button {
    font: inherit;
}

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

.public-chat-body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    min-height: 100vh;
    --chat-primary-color: #128c7e;
    --chat-secondary-color: #d9fdd3;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--chat-primary-color) 18%, transparent) 0 128px, transparent 128px),
        radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--chat-primary-color) 16%, transparent), transparent 28%),
        #e7edf2;
}

.public-chat-page {
    display: grid;
    height: 100%;
    min-height: 0;
    place-items: center;
    padding: 28px;
}

.public-chat-window {
    display: flex;
    flex-direction: column;
    width: min(1080px, 100%);
    height: calc(100vh - 56px);
    height: min(760px, calc(100dvh - 56px));
    max-height: calc(100vh - 56px);
    max-height: calc(100dvh - 56px);
    min-height: min(560px, calc(100vh - 56px));
    min-height: min(560px, calc(100dvh - 56px));
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 12px;
    background: #f5f7fb;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.public-chat-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 14px;
    min-height: 74px;
    border-bottom: 1px solid color-mix(in srgb, var(--chat-primary-color) 75%, #ffffff 25%);
    background: var(--chat-primary-color);
    padding: 14px 18px;
}

.public-chat-avatar {
    display: grid;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 19px;
    font-weight: 800;
    overflow: hidden;
}

.public-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.public-chat-header h1,
.public-chat-header span {
    display: block;
    margin: 0;
}

.public-chat-header h1 {
    max-width: 58vw;
    overflow: hidden;
    color: #ffffff;
    font-size: 17px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.public-chat-header span {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.86);
    font-size: 13px;
}

.public-chat-reset {
    min-height: 38px;
    margin-left: auto;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    padding: 0 14px;
}

.public-chat-reset:hover,
.public-chat-reset:focus-visible {
    border-color: rgba(255, 255, 255, 0.62);
    background: rgba(255, 255, 255, 0.24);
    color: #ffffff;
}

.public-chat-messages {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background-color: var(--chat-secondary-color);
    background-image:
        radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.62) 0 2px, transparent 3px),
        radial-gradient(circle at 82% 42%, rgba(255, 255, 255, 0.48) 0 2px, transparent 3px),
        radial-gradient(circle at 42% 78%, color-mix(in srgb, var(--chat-primary-color) 11%, transparent) 0 2px, transparent 3px),
        linear-gradient(135deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0));
    background-size: 42px 42px, 58px 58px, 64px 64px, 100% 100%;
    padding: 26px;
}

.public-chat-bubble {
    width: fit-content;
    max-width: min(680px, 82%);
    border-radius: 10px;
    color: #111827;
    line-height: 1.5;
    overflow-wrap: anywhere;
    padding: 12px 14px;
    white-space: pre-line;
    box-shadow: 0 5px 16px rgba(15, 23, 42, 0.09);
}

.public-chat-bubble.bot {
    align-self: flex-start;
    border-top-left-radius: 3px;
    background: #ffffff;
}

.public-chat-bubble.user {
    align-self: flex-end;
    border-top-right-radius: 3px;
    background: color-mix(in srgb, var(--chat-secondary-color) 82%, #ffffff 18%);
}

.public-chat-bubble.final {
    align-self: flex-start;
    border: 1px solid color-mix(in srgb, var(--chat-primary-color) 30%, #ffffff 70%);
    background: color-mix(in srgb, var(--chat-secondary-color) 62%, #ffffff 38%);
    color: color-mix(in srgb, var(--chat-primary-color) 72%, #111827 28%);
}

.public-chat-rich-bubble {
    max-width: min(720px, 88%);
    white-space: normal;
}

.public-chat-rich-content {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}

.public-chat-rich-content p,
.public-chat-rich-content ul,
.public-chat-rich-content ol,
.public-chat-rich-content table,
.public-chat-rich-content h1,
.public-chat-rich-content h2,
.public-chat-rich-content h3,
.public-chat-rich-content h4 {
    margin: 0 0 10px;
}

.public-chat-rich-content > :last-child {
    margin-bottom: 0;
}

.public-chat-rich-content ul,
.public-chat-rich-content ol {
    padding-left: 22px;
}

.public-chat-rich-content a {
    color: var(--chat-primary-color);
    font-weight: 800;
    text-decoration: underline;
}

.public-chat-rich-content table {
    width: max-content;
    max-width: 100%;
    min-width: min(100%, 320px);
    border-collapse: collapse;
    font-size: 14px;
}

.public-chat-rich-content th,
.public-chat-rich-content td {
    border: 1px solid #d7dee8;
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}

.public-chat-rich-content th {
    background: #f8fafc;
    font-weight: 900;
}

.chat-public-catalog,
.chatbot-catalog-preview {
    display: grid;
    gap: 8px;
}

.chat-public-catalog-title,
.chatbot-catalog-title {
    display: block;
    font-weight: 900;
}

.chat-public-catalog-list,
.chatbot-catalog-list {
    display: grid;
    gap: 5px;
    margin: 0;
    padding-left: 18px;
}

.chat-public-final-button,
.chatbot-final-button,
.chatbot-catalog-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    border: 0;
    border-radius: 999px;
    background: var(--chat-primary-color);
    color: #ffffff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    padding: 9px 13px;
    text-decoration: none;
    white-space: normal;
}

.chat-public-final-button:hover,
.chat-public-final-button:focus-visible,
.chatbot-final-button:hover,
.chatbot-final-button:focus-visible,
.chatbot-catalog-button:hover,
.chatbot-catalog-button:focus-visible {
    background: color-mix(in srgb, var(--chat-primary-color) 86%, #000000 14%);
    color: #ffffff;
}

.chat-public-back-button,
.chatbot-back-button,
.chatbot-secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    padding: 9px 13px;
    text-decoration: none;
}

.chat-public-back-button:hover,
.chat-public-back-button:focus-visible,
.chatbot-back-button:hover,
.chatbot-back-button:focus-visible,
.chatbot-secondary-button:hover,
.chatbot-secondary-button:focus-visible {
    border-color: var(--chat-primary-color);
    color: var(--chat-primary-color);
}

.chat-public-finish-message,
.chatbot-finish-message,
.chatbot-goodbye-message {
    display: grid;
    gap: 10px;
}

.chat-public-contact-form,
.public-chat-contact-bubble {
    display: grid;
    gap: 12px;
    min-width: min(360px, 82vw);
    white-space: normal;
}

.public-chat-contact-bubble p {
    margin: 0;
}

.public-chat-contact-form {
    display: grid;
    gap: 10px;
}

.public-chat-contact-field {
    display: grid;
    gap: 5px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.public-chat-contact-field input,
.public-chat-contact-field textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #111827;
    font: inherit;
    font-weight: 500;
    padding: 10px 11px;
}

.public-chat-contact-field input:focus,
.public-chat-contact-field textarea:focus {
    border-color: var(--chat-primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-primary-color) 16%, transparent);
    outline: none;
}

.public-chat-contact-error {
    margin: 0;
    color: #b91c1c;
    font-size: 13px;
    font-weight: 700;
}

.public-chat-contact-submit {
    width: fit-content;
    border: 0;
    border-radius: 999px;
    background: var(--chat-primary-color);
    color: #ffffff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    padding: 10px 14px;
}

.public-chat-contact-submit:hover,
.public-chat-contact-submit:focus-visible {
    background: color-mix(in srgb, var(--chat-primary-color) 86%, #000000 14%);
}

.public-chat-options {
    display: flex;
    width: fit-content;
    max-width: min(720px, 92%);
    flex-wrap: wrap;
    gap: 8px;
    align-self: flex-start;
    border-radius: 10px;
    border-top-left-radius: 3px;
    background: #ffffff;
    padding: 10px;
    box-shadow: 0 5px 16px rgba(15, 23, 42, 0.08);
}

.public-chat-option {
    max-width: 100%;
    border: 1px solid color-mix(in srgb, var(--chat-primary-color) 30%, #ffffff 70%);
    border-radius: 999px;
    background: color-mix(in srgb, var(--chat-secondary-color) 48%, #ffffff 52%);
    color: color-mix(in srgb, var(--chat-primary-color) 78%, #111827 22%);
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
    padding: 10px 13px;
    text-align: left;
}

.public-chat-option:hover,
.public-chat-option:focus-visible {
    border-color: var(--chat-primary-color);
    background: color-mix(in srgb, var(--chat-secondary-color) 72%, #ffffff 28%);
}

.public-chat-option:disabled {
    cursor: default;
    opacity: 0.58;
}

.public-chat-state {
    width: min(520px, 100%);
    margin: auto;
    border: 1px solid #d7dee8;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.86);
    padding: 24px;
    text-align: center;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.1);
}

.public-chat-state strong {
    display: block;
    margin-bottom: 8px;
    font-size: 18px;
}

.public-chat-state p {
    margin: 0;
    color: #64748b;
    line-height: 1.5;
}

.public-chat-footer {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    min-height: 58px;
    border-top: 1px solid #d8e0e8;
    background: #f8fafc;
    padding: 12px 18px;
}

.public-chat-input-form {
    display: flex;
    width: 100%;
    gap: 10px;
}

.public-chat-input-form input {
    width: 100%;
    min-height: 44px;
    border: 1px solid #d8e0e8;
    border-radius: 999px;
    background: #ffffff;
    color: #111827;
    font-size: 14px;
    outline: none;
    padding: 12px 16px;
}

.public-chat-input-form input:focus {
    border-color: var(--chat-primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-primary-color) 14%, transparent);
}

.public-chat-input-form button {
    min-height: 44px;
    border: 0;
    border-radius: 999px;
    background: var(--chat-primary-color);
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    padding: 0 18px;
}

.public-chat-input-form button:hover,
.public-chat-input-form button:focus-visible {
    background: color-mix(in srgb, var(--chat-primary-color) 86%, #000000 14%);
}

@media (max-width: 720px) {
    .public-chat-page {
        display: block;
        height: 100%;
        padding: 0;
    }

    .public-chat-window {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        min-height: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .public-chat-header {
        min-height: 68px;
        padding: 12px;
    }

    .public-chat-avatar {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
        font-size: 17px;
    }

    .public-chat-header h1 {
        max-width: 44vw;
        font-size: 16px;
    }

    .public-chat-reset {
        min-height: 34px;
        font-size: 13px;
        padding: 0 10px;
    }

    .public-chat-messages {
        padding: 16px 12px;
    }

    .public-chat-bubble {
        max-width: 88%;
    }

    .public-chat-options {
        max-width: 96%;
    }

    .public-chat-footer {
        min-height: 52px;
        padding: 10px 12px;
    }

    .public-chat-input-form {
        gap: 8px;
    }

    .public-chat-input-form input,
    .public-chat-input-form button {
        min-height: 40px;
    }

    .public-chat-input-form button {
        padding: 0 12px;
    }
}
