/* Widget de suporte próprio — tema neon pink */
#ps-support-root {
    touch-action: manipulation;
}

.ps-support-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    z-index: 99990;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(145deg, #ff2d95 0%, #ff0080 55%, #c40063 100%);
    color: #fff;
    box-shadow:
        0 0 0 3px rgba(255, 0, 128, 0.25),
        0 8px 28px rgba(255, 0, 128, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.ps-support-fab:hover {
    transform: scale(1.06);
    box-shadow:
        0 0 0 4px rgba(255, 0, 128, 0.35),
        0 10px 32px rgba(255, 0, 128, 0.55);
}

.ps-support-fab svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.ps-support-fab .ps-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #fff;
    color: #ff0080;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ps-support-fab .ps-badge.show {
    display: flex;
}

.ps-support-panel {
    position: fixed;
    right: 18px;
    bottom: 88px;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    z-index: 99991;
    width: min(380px, calc(100% - 24px));
    max-width: calc(100% - 24px);
    height: min(560px, calc(100dvh - 110px));
    max-height: calc(100dvh - 110px);
    background: #121212;
    border: 2px solid #ff0080;
    border-radius: 18px;
    box-shadow: 0 0 40px rgba(255, 0, 128, 0.35);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: inherit;
    box-sizing: border-box;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.ps-support-panel.open {
    display: flex;
    animation: psSupportIn 0.22s ease;
}

@keyframes psSupportIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ps-support-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(255, 0, 128, 0.25), rgba(255, 0, 128, 0.08));
    border-bottom: 1px solid rgba(255, 0, 128, 0.35);
    flex-shrink: 0;
}

.ps-support-header h3 {
    margin: 0;
    color: #ff0080;
    font-size: 15px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.ps-support-header .ps-sub {
    display: block;
    color: #aaa;
    font-size: 11px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.ps-support-header-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.ps-icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 0, 128, 0.35);
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.ps-icon-btn:hover {
    background: rgba(255, 0, 128, 0.2);
}

.ps-support-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

.ps-view {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    padding: 16px;
    box-sizing: border-box;
}

.ps-view.active {
    display: flex;
}

.ps-auth-form label {
    color: #ccc;
    font-size: 13px;
    margin-bottom: 8px;
    display: block;
}

.ps-auth-form input[type="email"] {
    width: 100%;
    max-width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #333;
    background: #1a1a1a;
    color: #fff;
    /* 16px evita zoom automático no iOS ao focar */
    font-size: 16px;
    outline: none;
    margin-bottom: 12px;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.ps-auth-form input[type="email"]:focus {
    border-color: #ff0080;
    box-shadow: 0 0 0 2px rgba(255, 0, 128, 0.2);
}

.ps-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff0080, #cc0066);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.ps-btn:hover {
    filter: brightness(1.08);
}

.ps-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ps-btn-ghost {
    background: transparent;
    border: 1px solid rgba(255, 0, 128, 0.45);
    color: #ff8fc8;
}

.ps-hint {
    color: #888;
    font-size: 12px;
    line-height: 1.45;
    margin-top: 12px;
}

.ps-error {
    background: rgba(255, 68, 68, 0.12);
    border: 1px solid rgba(255, 68, 68, 0.4);
    color: #ff8888;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
    display: none;
    word-break: break-word;
}

.ps-error.show {
    display: block;
}

.ps-messages {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 4px 2px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.ps-msg {
    max-width: 88%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    box-sizing: border-box;
}

.ps-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #ff0080, #d1006a);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ps-msg.admin {
    align-self: flex-start;
    background: #222;
    border: 1px solid #333;
    color: #eee;
    border-bottom-left-radius: 4px;
}

.ps-msg .ps-meta {
    display: block;
    margin-top: 6px;
    font-size: 10px;
    opacity: 0.7;
}

.ps-chat-link {
    color: #fff;
    text-decoration: underline;
    word-break: break-all;
    font-weight: 600;
}

.ps-msg.admin .ps-chat-link {
    color: #7ec8ff;
}

.ps-msg.user .ps-chat-link {
    color: #fff;
}

.ps-msg.system {
    align-self: center;
    max-width: 95%;
    background: rgba(255, 0, 128, 0.08);
    border: 1px dashed rgba(255, 0, 128, 0.35);
    color: #ccc;
    text-align: center;
    font-size: 12px;
}

.ps-composer {
    display: flex;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #2a2a2a;
    flex-shrink: 0;
    min-width: 0;
}

.ps-composer textarea {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    max-height: 110px;
    resize: none;
    border-radius: 12px;
    border: 1px solid #333;
    background: #1a1a1a;
    color: #fff;
    padding: 10px 12px;
    /* 16px evita zoom automático no iOS ao focar */
    font-size: 16px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.ps-composer textarea:focus {
    border-color: #ff0080;
}

.ps-composer button {
    width: 48px;
    border: none;
    border-radius: 12px;
    background: #ff0080;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.ps-composer button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ps-status-bar {
    font-size: 11px;
    color: #888;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
    min-width: 0;
}

.ps-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #44ff44;
    display: inline-block;
    margin-right: 5px;
    box-shadow: 0 0 8px rgba(68, 255, 68, 0.6);
}

.ps-status-dot.off {
    background: #888;
    box-shadow: none;
}

.ps-empty {
    color: #777;
    text-align: center;
    margin: auto;
    font-size: 13px;
    padding: 20px;
    line-height: 1.5;
}

/* Trava scroll da página atrás do chat (mobile) — sem position:fixed no body (quebra no iOS) */
html.ps-support-open,
html.ps-support-open body {
    overflow: hidden !important;
    overscroll-behavior: none;
    width: 100%;
    max-width: 100%;
    height: 100%;
}

html.ps-support-open #ps-support-root {
    touch-action: manipulation;
}

@media (max-width: 640px) {
    .ps-support-fab {
        right: 14px;
        bottom: 14px;
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
        width: 54px;
        height: 54px;
    }

    .ps-support-panel {
        right: 0 !important;
        left: 0 !important;
        bottom: auto !important;
        top: var(--ps-panel-top, 0px) !important;
        width: 100% !important;
        max-width: 100% !important;
        height: var(--ps-panel-height, 100dvh) !important;
        max-height: var(--ps-panel-height, 100dvh) !important;
        border-radius: 18px 18px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        transform: none !important;
    }

    .ps-support-header {
        flex-shrink: 0;
    }

    .ps-support-header .ps-sub {
        max-width: 55vw;
    }

    .ps-view {
        padding: 12px;
        min-height: 0;
    }

    .ps-view#ps-view-chat {
        padding-bottom: 8px;
    }

    .ps-composer {
        flex-shrink: 0;
        position: relative;
        z-index: 2;
        background: #121212;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .ps-composer textarea,
    .ps-auth-form input[type="email"] {
        font-size: 16px !important;
        transform: translateZ(0);
    }

    .ps-messages {
        min-height: 0;
        flex: 1 1 auto;
    }
}
