.pefrontchat {
    position: fixed;
    left: 20px;
    right: auto;
    bottom: var(--pefrontchat-bottom, 146px);
    z-index: 10005;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 12px;
    font-family: Montserrat, sans-serif;
}

.pefrontchat.pefrontchat-side-right {
    left: auto;
    right: 20px;
    align-items: flex-end;
}

.pefrontchat-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 999px;
    background: #a00000;
    color: #fff;
    padding: 14px 18px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
    cursor: pointer;
}

.pefrontchat-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
}

.pefrontchat-toggle-icon svg {
    width: 22px;
    height: 22px;
    display: block;
    fill: currentColor;
}

.pefrontchat-toggle-label {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

.pefrontchat-panel {
    width: min(360px, calc(100vw - 40px));
    height: 680px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}

.pefrontchat-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    padding: 16px 18px;
    background: #1f1f1f;
    color: #fff;
}

.pefrontchat-close {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 24px;
    line-height: 1;
}

.pefrontchat-status {
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.8;
}

.pefrontchat-messages {
    flex: 1 1 auto;
    padding: 14px;
    overflow-y: auto;
    background: #f4f1ec;
}

.pefrontchat-suggestions,
.pefrontchat-tools,
.pefrontchat-contact {
    padding: 0 12px 12px;
    background: #fff;
}

.pefrontchat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 4px;
}

.pefrontchat-suggestion,
.pefrontchat-secondary,
.pefrontchat-contact-submit {
    border: 1px solid #d7d0c5;
    border-radius: 999px;
    background: #fff;
    color: #3a342d;
    padding: 8px 12px;
    font-size: 13px;
}

.pefrontchat-tools {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    position: relative;
    min-height: 62px;
    gap: 8px;
    padding: 15px 60px 15px 12px;
    border-top: 0;
}

.pefrontchat-tools::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    border-top: 1px solid #ece5d8;
    z-index: 0;
}

.pefrontchat-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 1 auto;
    max-width: 100%;
    min-height: 42px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.pefrontchat-secondary-toggle {
    position: absolute;
    top: 50%;
    right: 12px;
    width: 42px;
    min-width: 42px;
    padding: 8px;
    transform: translateY(-50%);
}

.pefrontchat-secondary-toggle .pefrontchat-secondary-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
}

.pefrontchat-secondary-toggle .pefrontchat-secondary-icon svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: currentColor;
    transition: transform 0.18s ease;
}

.pefrontchat-secondary-toggle.is-open .pefrontchat-secondary-icon svg {
    transform: rotate(180deg);
}

.pefrontchat-secondary-toggle [data-role="toggle-suggestions-label"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.pefrontchat-secondary-contact {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex: 0 1 auto;
    min-width: 162px;
    min-height: 42px;
    margin: 0;
}

.pefrontchat-contact {
    display: grid;
    gap: 8px;
    border-top: 1px solid #ece5d8;
    padding-top: 12px;
}

.pefrontchat-contact-input {
    border: 1px solid #d7d0c5;
    border-radius: 12px;
    padding: 10px 12px;
}

.pefrontchat-contact-submit {
    justify-self: start;
    border-radius: 12px;
    background: #1f1f1f;
    color: #fff;
}

.pefrontchat-message {
    display: flex;
    margin-bottom: 12px;
}

.pefrontchat-message-visitor {
    justify-content: flex-end;
}

.pefrontchat-bubble {
    max-width: 85%;
    border-radius: 16px;
    padding: 10px 12px;
    background: #fff;
    color: #222;
}

.pefrontchat-message-visitor .pefrontchat-bubble {
    background: #a00000;
    color: #fff;
}

.pefrontchat-message-system .pefrontchat-bubble {
    background: #ece5d8;
}

.pefrontchat-bubble-typing {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 180px;
}

.pefrontchat-bubble-typing-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pefrontchat-typing-label {
    font-size: 12px;
    line-height: 1.35;
    color: #6b6359;
}

.pefrontchat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #a89d8b;
    animation: pefrontchatTyping 1s infinite ease-in-out;
}

.pefrontchat-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.pefrontchat-typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

.pefrontchat-form {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid #ece5d8;
    background: #fff;
}

.pefrontchat-input {
    flex: 1 1 auto;
    min-height: 74px;
    resize: vertical;
    border: 1px solid #d7d0c5;
    border-radius: 12px;
    padding: 10px 12px;
}

.pefrontchat-send {
    flex: 0 0 auto;
    align-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    background: #a00000;
    color: #fff;
    min-height: 46px;
    padding: 12px 16px;
}

@keyframes pefrontchatTyping {
    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.35;
    }

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

@media (max-width: 767px) {
    .pefrontchat-panel {
        width: min(360px, calc(100vw - 40px));
        height: min(78vh, 680px);
    }

    .pefrontchat-form {
        align-items: stretch;
    }

    .pefrontchat-send {
        align-self: stretch;
    }
}
