/* ═══════════════════════════════════════════════════════
   CHAT PRÓPRIO (substitui Leadster)
═══════════════════════════════════════════════════════ */
.pd-chat {
    --pd-chat-primary: #5448c2;
    --pd-chat-primary-soft: #eff2fe;
    --pd-chat-bubble: #f3f2f8;
    --pd-chat-text: #343434;
    --pd-chat-muted: #5e5e5e;
    --pd-chat-shadow: 0 12px 40px rgba(34, 30, 72, 0.22);
    position: fixed;
    left: 20px;
    right: auto;
    bottom: 20px;
    z-index: 99999;
    font-family: "DM Sans", sans-serif;
    color: var(--pd-chat-text);
}

.pd-chat[hidden] {
    display: none !important;
}

.pd-chat__teaser {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 380px;
    animation: pd-chat-in 0.35s ease-out;
    padding-right: 8px;
    padding-top: 8px;
}

.pd-chat__teaser-open {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border: 0;
    background: transparent;
    padding: 0;
    text-align: left;
    appearance: none;
    -webkit-appearance: none;
}

.pd-chat__teaser-open:focus-visible {
    outline: 2px solid var(--pd-chat-primary);
    outline-offset: 4px;
    border-radius: 12px;
}

.pd-chat__teaser-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    overflow: visible;
}

.pd-chat__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 0;
    background: transparent;
    display: block;
}

.pd-chat__avatar--teaser {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    background: #e8e6ef;
}

.pd-chat__avatar--sm {
    width: 28px;
    height: 28px;
    box-shadow: none;
}

.pd-chat__status {
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
    box-shadow: none;
}

.pd-chat__teaser-bubble {
    position: relative;
    background: #fff;
    border-radius: 18px;
    padding: 14px 18px;
    box-shadow: var(--pd-chat-shadow);
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--pd-chat-text);
    max-width: 270px;
}

.pd-chat__teaser-bubble::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 50%;
    margin-top: -8px;
    border-width: 8px 8px 8px 0;
    border-style: solid;
    border-color: transparent #fff transparent transparent;
}

.pd-chat__teaser-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #5e5e5e;
    box-shadow: 0 4px 14px rgba(34, 30, 72, 0.18);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
    z-index: 2;
}

.pd-chat__teaser-close:hover,
.pd-chat__teaser-close:focus-visible {
    background: var(--pd-chat-primary-soft);
    color: var(--pd-chat-primary);
    outline: none;
}

.pd-chat__teaser-close:active {
    transform: scale(0.96);
}

.pd-chat__window {
    display: none;
    width: 380px;
    max-width: calc(100vw - 24px);
    height: 560px;
    max-height: calc(100vh - 40px);
    /* background: #fff; */
    border: 0;
    border-radius: 20px;
    box-shadow: var(--pd-chat-shadow);
    overflow: hidden;
    flex-direction: column;
    animation: pd-chat-in 0.28s ease-out;
}

.pd-chat.is-open .pd-chat__teaser {
    display: none;
}

.pd-chat.is-open .pd-chat__window {
    display: flex;
}

.pd-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--pd-chat-primary);
    color: #fff;
    padding: 14px 14px 14px 16px;
    flex-shrink: 0;
    border-radius: 20px 20px 0 0;
}

.pd-chat__header-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
}

.pd-chat__header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 0;
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.pd-chat__header-status-dot {
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    border: 0;
    box-shadow: none;
}

.pd-chat__header-text {
    flex: 1;
    min-width: 0;
}

.pd-chat__header-name {
    display: block;
    font-weight: 700;
    font-size: 0.98rem;
    line-height: 1.25;
}

.pd-chat__header-status {
    display: block;
    font-size: 0.78rem;
    opacity: 0.92;
    margin-top: 2px;
}

.pd-chat__header-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 0;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.pd-chat__header-close:hover,
.pd-chat__header-close:focus-visible {
    background: rgba(255, 255, 255, 0.28);
    outline: none;
}

.pd-chat__messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 16px 16px;
    background: #fff;
    scroll-behavior: auto;
}

.pd-chat__row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 12px;
}

.pd-chat__row--user {
    justify-content: flex-end;
}

.pd-chat__bubble {
    max-width: 82%;
    background: var(--pd-chat-bubble);
    border-radius: 16px;
    padding: 11px 14px;
    font-size: 0.94rem;
    line-height: 1.5;
    white-space: pre-wrap;
    color: var(--pd-chat-text);
}

.pd-chat__bubble--user {
    background: var(--pd-chat-primary);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.pd-chat__bubble--bot {
    border-bottom-left-radius: 6px;
}

.pd-chat__typing {
    display: inline-flex;
    gap: 5px;
    padding: 12px 16px;
}

.pd-chat__typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9aa0b3;
    animation: pd-chat-typing 1s infinite ease-in-out;
}

.pd-chat__typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.pd-chat__typing span:nth-child(3) {
    animation-delay: 0.3s;
}

.pd-chat__actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 8px;
    padding: 2px 0 12px 36px;
    background: transparent;
}

.pd-chat__actions:empty {
    display: none;
    padding: 0;
    margin: 0;
}

.pd-chat__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    max-width: 100%;
    flex: 0 0 auto;
    border: 0;
    border-radius: 999px;
    background: var(--pd-chat-primary);
    color: #fff;
    padding: 10px 16px;
    min-height: 44px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.3;
    text-align: left;
    white-space: normal;
    box-shadow: 0 2px 6px rgba(84, 72, 194, 0.18);
    transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.pd-chat__btn:hover:not(:disabled) {
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(84, 72, 194, 0.26);
}

.pd-chat__btn:focus-visible {
    outline: 2px solid var(--pd-chat-primary);
    outline-offset: 2px;
}

.pd-chat__btn:active:not(:disabled) {
    transform: scale(0.98);
}

.pd-chat__btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

.pd-chat__composer {
    display: none;
    gap: 8px;
    padding: 12px 14px 16px;
    border-top: 0;
    background: #fff;
    align-items: center;
    flex-shrink: 0;
}

.pd-chat__composer.is-visible {
    display: flex;
}

.pd-chat__input {
    flex: 1;
    border: 1.5px solid #d9dbe7;
    border-radius: 999px;
    padding: 12px 16px;
    min-height: 44px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pd-chat__input:focus {
    border-color: var(--pd-chat-primary);
    box-shadow: 0 0 0 3px rgba(84, 72, 194, 0.15);
}

.pd-chat__send {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: var(--pd-chat-primary);
    color: #fff;
    cursor: pointer;
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: filter 0.15s ease;
}

.pd-chat__send:hover:not(:disabled) {
    filter: brightness(1.06);
}

.pd-chat__send:disabled,
.pd-chat__input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.pd-chat__error {
    color: #c0392b;
    font-size: 0.82rem;
    padding: 0 16px 8px;
    display: none;
    background: #fff;
    flex-shrink: 0;
}

.pd-chat__error.is-visible {
    display: block;
}

@keyframes pd-chat-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pd-chat-typing {
    0%, 80%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@media (max-width: 768px) {
    .pd-chat {
        left: 12px;
        right: auto;
        bottom: 12px;
        max-width: calc(100vw - 24px);
    }

    .pd-chat__teaser {
        max-width: 100%;
    }

    .pd-chat__teaser-bubble {
        max-width: min(240px, calc(100vw - 120px));
        font-size: 0.9rem;
    }

    .pd-chat__teaser-close,
    .pd-chat__header-close {
        width: 44px;
        height: 44px;
        font-size: 26px;
    }

    .pd-chat__window {
        width: min(380px, calc(100vw - 24px));
        height: min(640px, calc(100vh - 24px));
        border-radius: 18px;
    }

    .pd-chat__header {
        border-radius: 18px 18px 0 0;
    }
}
