﻿/* ================================================================
   Formly Chatbot â€” Frontend Widget Styles  (v2)
   ================================================================ */

#formly-chatbot-root {
    --cb-mauve: #8f6b7a;
    --cb-mauve-dk: #7a5a69;
    --cb-mauve-lt: #d4a5b8;
    --cb-bg: #ffffff;
    --cb-bg-msg: #fdf6f3;
    --cb-text: #2d2d2d;
    --cb-muted: #6b7280;
    --cb-radius: 16px;
    --cb-shadow: 0 8px 40px rgba(45, 45, 45, .18);
    --cb-font: 'Inter', system-ui, sans-serif;
    --cb-toggle-shadow: rgba(143, 107, 122, .45);
    --cb-toggle-shadow-hov: rgba(143, 107, 122, .55);

    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9998;
    font-family: var(--cb-font);
}

/* â”€â”€ Toggle bubble â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-mauve), var(--cb-mauve-dk));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px var(--cb-toggle-shadow);
    transition: transform .2s, box-shadow .2s;
    margin-left: auto;
    position: relative;
    overflow: hidden;
}

.cb-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px var(--cb-toggle-shadow-hov);
}

.cb-btn-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    position: absolute;
    transition: opacity .2s;
}

.cb-icon-chat {
    color: #fff;
    position: absolute;
    transition: opacity .2s, transform .2s;
}

.cb-icon-close {
    color: #fff;
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg);
    transition: opacity .2s, transform .2s;
}

#formly-chatbot-root.cb-open .cb-icon-chat,
#formly-chatbot-root.cb-open .cb-btn-avatar {
    opacity: 0;
    transform: rotate(90deg);
}

#formly-chatbot-root.cb-open .cb-icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

/* -- Status tooltip -- */
.cb-toggle-tooltip {
    position: absolute;
    bottom: 66px;
    right: 0;
    background: rgba(20, 20, 20, .82);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    padding: 6px 12px;
    border-radius: 20px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 1;
    transition: opacity .2s;
    font-family: var(--cb-font);
}

#formly-chatbot-root.cb-open .cb-toggle-tooltip {
    opacity: 0;
}

.cb-unread-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}

#formly-chatbot-root.cb-has-unread .cb-unread-dot {
    display: block;
}

/* â”€â”€ Chat window â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    max-height: 560px;
    background: var(--cb-bg);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(.97);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}

#formly-chatbot-root.cb-open .cb-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* â”€â”€ Header â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--cb-mauve), var(--cb-mauve-dk));
    flex-shrink: 0;
}

.cb-hdr-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.cb-hdr-avatar svg {
    color: #fff;
}

.cb-hdr-avatar-img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
}

.cb-hdr-info {
    flex: 1;
    min-width: 0;
}

.cb-hdr-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cb-hdr-status {
    font-size: 11px;
    color: rgba(255, 255, 255, .8);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.cb-dot-green {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    flex-shrink: 0;
}

/* â”€â”€ Messages area â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    background: var(--cb-bg-msg);
}

.cb-messages::-webkit-scrollbar {
    width: 3px;
}

.cb-messages::-webkit-scrollbar-thumb {
    background: rgba(143, 107, 122, .25);
    border-radius: 3px;
}

/* â”€â”€ Message bubbles â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-bubble {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px 14px 14px 4px;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--cb-text);
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
    white-space: pre-wrap;
    word-break: break-word;
    animation: cb-pop .2s ease;
}

.cb-bubble.cb-user {
    align-self: flex-end;
    background: var(--cb-mauve);
    color: #fff;
    border-radius: 14px 14px 4px 14px;
    box-shadow: none;
}

@keyframes cb-pop {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* â”€â”€ Typing indicator â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 14px 14px 14px 4px;
    width: fit-content;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
    animation: cb-pop .2s ease;
}

.cb-typing span {
    width: 7px;
    height: 7px;
    background: var(--cb-mauve-lt);
    border-radius: 50%;
    animation: cb-bounce .9s infinite ease-in-out;
}

.cb-typing span:nth-child(1) {
    animation-delay: 0s;
}

.cb-typing span:nth-child(2) {
    animation-delay: .15s;
}

.cb-typing span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes cb-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-5px);
    }
}

/* â”€â”€ Input zone â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-input-zone {
    padding: 6px 12px 10px;
    background: var(--cb-bg);
    max-height: 220px;
    overflow-y: auto;
    flex-shrink: 0;
}

/* â”€â”€ Option buttons (type=options) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-opt-btn {
    display: block;
    width: 100%;
    background: #fff;
    border: 1.5px solid rgba(143, 107, 122, .3);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--cb-font);
    color: var(--cb-mauve);
    cursor: pointer;
    text-align: left;
    margin-bottom: 6px;
    transition: background .15s, border-color .15s, color .15s;
    word-break: break-word;
}

.cb-opt-btn:last-child {
    margin-bottom: 0;
}

.cb-opt-btn:hover {
    background: var(--cb-mauve);
    border-color: var(--cb-mauve);
    color: #fff;
}

/* â”€â”€ Radio group (type=radio) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-radio-wrap,
.cb-checkbox-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.cb-radio-label,
.cb-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1.5px solid rgba(143, 107, 122, .25);
    border-radius: 9px;
    font-size: 13px;
    font-family: var(--cb-font);
    color: var(--cb-text);
    cursor: pointer;
    background: #fff;
    transition: border-color .15s, background .15s;
}

.cb-radio-label:hover,
.cb-checkbox-label:hover {
    border-color: var(--cb-mauve-lt);
    background: #fdf6f3;
}

.cb-radio-label input[type="radio"],
.cb-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--cb-mauve);
    flex-shrink: 0;
    cursor: pointer;
}

/* â”€â”€ Submit button â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-submit-btn {
    display: block;
    width: 100%;
    background: var(--cb-mauve);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 11px 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--cb-font);
    cursor: pointer;
    margin-top: 4px;
    transition: background .2s;
}

.cb-submit-btn:hover {
    background: var(--cb-mauve-dk);
}

/* â”€â”€ Text input (type=text) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-text-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cb-text-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    font-size: 13px;
    font-family: var(--cb-font);
    color: var(--cb-text);
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .15);
    border-radius: 8px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.cb-text-input:focus {
    border-color: var(--cb-mauve-lt);
    box-shadow: 0 0 0 3px rgba(143, 107, 122, .1);
}

.cb-textarea {
    resize: vertical;
    min-height: 72px;
}

/* â”€â”€ Phone row (country code + number field) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-phone-row {
    display: flex;
    gap: 6px;
}

.cb-cc-select {
    flex-shrink: 0;
    width: 112px;
    padding: 10px 8px;
    font-size: 12px;
    font-family: var(--cb-font);
    color: var(--cb-text);
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .15);
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    transition: border-color .2s;
}

.cb-cc-select:focus {
    border-color: var(--cb-mauve-lt);
}

.cb-phone-row .cb-text-input {
    flex: 1;
}

/* â”€â”€ Validation error â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-input-err {
    font-size: 12px;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 6px 10px;
    line-height: 1.4;
}

/* â”€â”€ Footer â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-footer {
    padding: 6px 12px 10px;
    text-align: center;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
}

.cb-restart {
    background: none;
    border: none;
    font-size: 11px;
    color: var(--cb-muted);
    cursor: pointer;
    font-family: var(--cb-font);
    transition: color .15s;
}

.cb-restart:hover {
    color: var(--cb-mauve);
}

/* â”€â”€ Embedded legacy form â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.cb-form-wrap {
    padding: 0 4px 8px;
}

.cb-form-wrap .formly-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--cb-text);
    margin-bottom: 4px;
}

.cb-form-wrap .formly-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 9px 11px;
    font-size: 13px;
    font-family: var(--cb-font);
    border: 1px solid rgba(0, 0, 0, .15);
    border-radius: 7px;
    outline: none;
}

.cb-form-wrap .formly-submit {
    width: 100%;
    padding: 11px;
    background: var(--cb-mauve);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.cb-form-wrap .formly-response {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
}

.cb-form-wrap .formly-response.formly-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.cb-form-wrap .formly-response.formly-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* â”€â”€ Mobile â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
@media (max-width: 420px) {
    #formly-chatbot-root {
        bottom: 16px;
        right: 16px;
    }

    .cb-window {
        width: calc(100vw - 32px);
        right: 0;
        bottom: 68px;
        max-height: 72vh;
    }
}