/* PuntersHub Live Chat. Everything hangs off #phchat so the theme's rules don't reach in. */

#phchat {
    --phchat-yellow: #ffcd07;
    --phchat-bg: #0a080d;
    --phchat-card: #1f1b24;
    --phchat-line: #47414d;
    --phchat-text: #fff;
    --phchat-soft: #b9b3c0;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1040; /* above the page, below the theme's sign-up modal */
    font-family: "Roboto", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    color: var(--phchat-text);
    text-align: left;
    letter-spacing: normal;
    text-transform: none;
}

#phchat *,
#phchat *::before,
#phchat *::after {
    box-sizing: border-box;
}

#phchat :where(p) {
    margin: 0;
}

#phchat button,
#phchat input,
#phchat select,
#phchat textarea {
    font-family: inherit;
}

/* ---- the round button ---- */

#phchat .phchat-open {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--phchat-yellow);
    color: #1f1726;
    cursor: pointer;
    box-shadow: 0 0 30px rgba(255, 205, 7, 0.35), 0 4px 14px rgba(0, 0, 0, 0.5);
    transition: transform 0.15s ease;
}

#phchat .phchat-open:hover {
    transform: scale(1.06);
}

#phchat .phchat-open svg {
    display: block;
    width: 28px;
    height: 28px;
    fill: currentColor;
}

#phchat.is-open .phchat-open {
    display: none;
}

/* ---- the panel ---- */

#phchat .phchat-panel {
    display: none;
    flex-direction: column;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    border: 2px solid var(--phchat-yellow);
    border-radius: 20px;
    overflow: hidden;
    background: var(--phchat-bg);
    box-shadow: 0 0 60px rgba(255, 205, 7, 0.2);
}

#phchat.is-open .phchat-panel {
    display: flex;
}

#phchat .phchat-head {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 14px 18px;
    border-bottom: 1px solid var(--phchat-line);
}

#phchat .phchat-title {
    font-family: "Anton", Impact, sans-serif;
    font-size: 22px;
    font-weight: 400;
    line-height: 1.1;
    text-transform: uppercase;
    color: var(--phchat-text);
}

#phchat .phchat-head-tools {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
}

#phchat .phchat-person {
    padding: 6px 10px;
    border: 1px solid var(--phchat-line);
    border-radius: 14px;
    background: none;
    color: var(--phchat-text);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
}

#phchat .phchat-person:hover {
    border-color: var(--phchat-yellow);
}

#phchat [hidden] {
    display: none !important;
}

#phchat .phchat-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #2e2933;
    color: #fff;
    font-size: 20px;
    line-height: 32px;
    text-align: center;
    cursor: pointer;
}

#phchat .phchat-log {
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

#phchat .phchat-msg {
    max-width: 88%;
    margin: 0 0 10px;
    padding: 10px 13px;
    border-radius: 14px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

#phchat .phchat-bot {
    border-bottom-left-radius: 4px;
    background: var(--phchat-card);
    color: var(--phchat-text);
}

#phchat .phchat-me {
    margin-left: auto;
    border-bottom-right-radius: 4px;
    background: var(--phchat-yellow);
    color: #1f1726;
}

#phchat .phchat-team {
    border-bottom-left-radius: 4px;
    background: #2b5278;
    color: #fff;
}

#phchat .phchat-who {
    display: block;
    margin-bottom: 2px;
    color: var(--phchat-yellow);
    font-size: 12px;
    font-weight: 700;
}

#phchat .phchat-sys {
    max-width: 92%;
    margin: 4px auto 12px;
    color: var(--phchat-soft);
    font-size: 13px;
    text-align: center;
}

/* ---- the form before a chat starts ---- */

#phchat .phchat-intro {
    display: grid;
    gap: 14px;
    margin: 0;
}

#phchat .phchat-intro p {
    color: var(--phchat-text);
}

#phchat .phchat-field {
    display: grid;
    gap: 6px;
}

#phchat .phchat-field label {
    color: var(--phchat-text);
    font-size: 14px;
    font-weight: 500;
}

#phchat .phchat-field input,
#phchat .phchat-field select {
    width: 100%;
    height: 44px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--phchat-line);
    border-radius: 10px;
    outline: none;
    background: var(--phchat-card);
    color: var(--phchat-text);
    font-family: inherit;
    font-size: 16px; /* under 16px, iPhones zoom the page when the box is tapped */
    box-shadow: none;
}

#phchat .phchat-field input:focus,
#phchat .phchat-field select:focus {
    border-color: var(--phchat-yellow);
}

#phchat .phchat-error {
    color: #ffb36b;
    font-size: 13px;
}

#phchat .phchat-start {
    height: 44px;
    border: 0;
    border-radius: 10px;
    background: var(--phchat-yellow);
    color: #1f1726;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

#phchat .phchat-start:disabled {
    opacity: 0.6;
    cursor: default;
}

#phchat .phchat-fine {
    color: var(--phchat-soft);
    font-size: 12px;
}

/* A reply from the team while the chat is closed */
#phchat.has-new .phchat-open::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    border: 2px solid var(--phchat-bg);
    border-radius: 50%;
    background: #e5484d;
}

#phchat .phchat-open {
    position: relative;
}

#phchat .phchat-msg a {
    color: var(--phchat-yellow);
    text-decoration: underline;
}

#phchat .phchat-typing {
    display: flex;
    gap: 5px;
    width: 58px;
    padding: 14px 13px;
}

#phchat .phchat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--phchat-soft);
    animation: phchat-dot 1.1s infinite ease-in-out;
}

#phchat .phchat-typing span:nth-child(2) { animation-delay: 0.15s; }
#phchat .phchat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes phchat-dot {
    0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* ---- suggested questions and buttons in the chat ---- */

#phchat .phchat-chips,
#phchat .phchat-help {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
}

#phchat .phchat-chip {
    padding: 7px 12px;
    border: 1px solid var(--phchat-line);
    border-radius: 16px;
    background: none;
    color: var(--phchat-text);
    font-size: 14px;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
}

#phchat .phchat-chip:hover {
    border-color: var(--phchat-yellow);
}

#phchat .phchat-action {
    display: inline-block;
    padding: 9px 14px;
    border: 0;
    border-radius: 10px;
    background: var(--phchat-yellow);
    color: #1f1726;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}

#phchat .phchat-action:hover {
    background: #fd0;
    color: #1f1726;
}

/* A second button in a row (Keep waiting) is the quieter choice. */
#phchat .phchat-action + .phchat-action {
    border: 1px solid var(--phchat-line);
    background: none;
    color: var(--phchat-text);
}

#phchat .phchat-action + .phchat-action:hover {
    border-color: var(--phchat-yellow);
    background: none;
    color: var(--phchat-text);
}

/* ---- typing box ---- */

#phchat .phchat-form {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
    align-items: flex-end;
    margin: 0;
    padding: 10px 12px 6px;
    border-top: 1px solid var(--phchat-line);
}

#phchat .phchat-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 42px;
    max-height: 110px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--phchat-line);
    border-radius: 10px;
    outline: none;
    background: var(--phchat-card);
    color: var(--phchat-text);
    font-size: 16px; /* under 16px, iPhones zoom the page when the box is tapped */
    line-height: 1.3;
    resize: none;
    scrollbar-width: none;
}

#phchat .phchat-input::-webkit-scrollbar {
    display: none;
}

#phchat .phchat-input:focus {
    border-color: var(--phchat-yellow);
}

#phchat .phchat-input::placeholder {
    color: var(--phchat-soft);
    opacity: 1;
}

#phchat .phchat-send {
    flex: 0 0 auto;
    height: 42px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    background: var(--phchat-yellow);
    color: #1f1726;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

#phchat .phchat-send:disabled {
    opacity: 0.5;
    cursor: default;
}

#phchat .phchat-note {
    flex: 0 0 auto;
    padding: 2px 14px 10px;
    color: var(--phchat-soft);
    font-size: 11.5px;
    line-height: 1.35;
}

#phchat button:focus-visible,
#phchat a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ---- phones: the panel takes the whole screen ---- */

@media (max-width: 600px) {
    #phchat {
        right: 12px;
        bottom: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    #phchat.is-open {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    }

    /* Logged in (testing): keep the header clear of WordPress's admin bar. */
    .admin-bar #phchat.is-open {
        top: 46px;
    }

    #phchat .phchat-panel {
        width: 100%;
        height: 100%;
        max-height: none;
        border: 0;
        border-radius: 0;
    }

    #phchat .phchat-note {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}

@media (prefers-reduced-motion: reduce) {
    #phchat .phchat-open { transition: none; }
    #phchat .phchat-typing span { animation: none; }
}
