.grema-chat {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 260;
    font-family: "Poppins", sans-serif;
}

.grema-chat__trigger {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 56px;
    padding: 6px 16px 6px 8px;
    border: 0;
    border-radius: 999px;
    background: #F37021;
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    animation: grema-chat-call 2.6s ease-in-out infinite;
}

.grema-chat__trigger::before,
.grema-chat__trigger::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(243, 112, 33, 0.55);
    animation: grema-chat-ring 2.6s ease-out infinite;
    pointer-events: none;
}

.grema-chat__trigger::after {
    animation-delay: 1.3s;
}

.grema-chat__trigger img {
    width: 40px;
    height: 40px;
    padding: 7px;
    border-radius: 50%;
    background: #1E1E1E;
    object-fit: contain;
}

.grema-chat__trigger[aria-expanded="true"],
.grema-chat__trigger[aria-expanded="true"]::before,
.grema-chat__trigger[aria-expanded="true"]::after {
    animation: none;
}

@keyframes grema-chat-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(243, 112, 33, 0.45);
        opacity: 1;
    }
    70%,
    100% {
        box-shadow: 0 0 0 16px rgba(243, 112, 33, 0);
        opacity: 0;
    }
}

@keyframes grema-chat-call {
    0%,
    62%,
    100% {
        transform: translateY(0) rotate(0);
    }
    6% {
        transform: translateY(-2px) rotate(-8deg);
    }
    12% {
        transform: translateY(-2px) rotate(8deg);
    }
    18% {
        transform: translateY(-1px) rotate(-5deg);
    }
    24% {
        transform: translateY(0) rotate(4deg);
    }
    30% {
        transform: translateY(0) rotate(0);
    }
}

.grema-chat__trigger:hover {
    background: #E85D15;
}

.grema-chat__trigger:focus-visible,
.grema-chat__close:focus-visible,
.grema-chat__composer button:focus-visible,
.grema-chat__advisor:focus-visible,
.grema-chat__lead-send:focus-visible,
.grema-chat__suggestions button:focus-visible {
    outline: 3px solid rgba(243, 112, 33, 0.45);
    outline-offset: 2px;
}

.grema-chat__panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    display: flex;
    flex-direction: column;
    width: min(390px, calc(100vw - 32px));
    max-height: min(560px, calc(100dvh - 110px));
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 20px;
    background: #fafafa;
    color: #1E1E1E;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.2);
}

.grema-chat__panel[hidden] {
    display: none;
}

.grema-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 1;
    min-height: 76px;
    padding: 14px 14px 14px 16px;
    background: #F37021;
    color: #fff;
}

.grema-chat__identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.grema-chat__logo {
    width: 72px;
    height: 36px;
    padding: 4px 6px;
    border-radius: 8px;
    background: #1E1E1E;
    object-fit: contain;
}

.grema-chat__identity strong,
.grema-chat__identity span {
    display: block;
}

.grema-chat__identity strong {
    font-size: 15px;
    line-height: 1.2;
}

.grema-chat__identity span {
    margin-top: 2px;
    font-size: 12px;
    opacity: 0.92;
}

.grema-chat__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.grema-chat__close:hover {
    background: rgba(255, 255, 255, 0.16);
}

.grema-chat__log {
    flex: 1 1 auto;
    min-height: 96px;
    max-height: 220px;
    overflow-y: auto;
    padding: 16px;
}

.grema-chat__bubble {
    max-width: 92%;
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.grema-chat__bubble--assistant {
    background: #fff;
    border: 1px solid #eee;
}

.grema-chat__bubble--user {
    margin-left: auto;
    background: #1E1E1E;
    color: #fff;
}

.grema-chat__bubble--pending {
    color: #7A7A7A;
    font-style: italic;
}

.grema-chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 8px;
}

.grema-chat__suggestions[hidden] {
    display: none;
}

.grema-chat__suggestions button,
.grema-chat__advisor,
.grema-chat__lead-send {
    border: 1px solid #F37021;
    border-radius: 999px;
    background: #fff;
    color: #F37021;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.grema-chat__suggestions button {
    padding: 8px 12px;
    text-align: left;
}

.grema-chat__suggestions button:hover,
.grema-chat__advisor:hover,
.grema-chat__lead-send:hover {
    background: #F37021;
    color: #fff;
}

.grema-chat__suggestions button:disabled,
.grema-chat__composer button:disabled,
.grema-chat__lead-send:disabled {
    opacity: 0.55;
    cursor: default;
}

.grema-chat__bottom {
    padding: 8px 16px 14px;
    background: #fff;
    border-top: 1px solid #eee;
}

.grema-chat__notice {
    margin: 0 0 8px;
    font-size: 12px;
    line-height: 1.4;
    color: #7A7A7A;
}

.grema-chat__notice a,
.grema-chat__consent a {
    color: #F37021;
}

.grema-chat__composer {
    display: flex;
    align-items: center;
    gap: 8px;
}

.grema-chat__honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.grema-chat__composer input {
    flex: 1;
    min-width: 0;
    height: 42px;
    padding: 0 12px;
    border: 1px solid #e4e4e4;
    border-radius: 999px;
    font: inherit;
    font-size: 14px;
}

.grema-chat__composer button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background: #F37021;
    color: #fff;
    cursor: pointer;
}

.grema-chat__advisor,
.grema-chat__lead-send {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 10px 14px;
}

.grema-chat__lead {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.grema-chat__lead[hidden] {
    display: none;
}

.grema-chat__lead-title {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 700;
}

.grema-chat__lead label {
    display: block;
    margin-bottom: 8px;
}

.grema-chat__lead label span {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #7A7A7A;
}

.grema-chat__lead input[type="text"],
.grema-chat__lead input[type="email"],
.grema-chat__lead input[type="tel"] {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #e4e4e4;
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
}

.grema-chat__consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    line-height: 1.4;
}

.grema-chat__consent input {
    margin-top: 2px;
}

.grema-chat__lead-status {
    min-height: 1.2em;
    margin: 4px 0 0;
    font-size: 13px;
}

.grema-chat__lead-status.is-error {
    color: #b42318;
}

.grema-chat__lead-status.is-ok {
    color: #067647;
}

@media (prefers-reduced-motion: reduce) {
    .grema-chat__trigger,
    .grema-chat__trigger::before,
    .grema-chat__trigger::after {
        animation: none;
    }
}

@media (max-width: 767px) {
    .grema-chat {
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .grema-chat__panel {
        max-height: min(70dvh, 560px);
    }
}
