/*
 * The conversation on a job.
 *
 * Its own file rather than an addition to wizbrand-orgs-ui.css or
 * wizbrand-advertiser.css, because the component is shared by screens that load
 * one or the other. Putting the rules in either would have left the thread
 * unstyled on half the pages that use it -- which is exactly how the marketplace
 * and onboarding rules ended up in the wrong files before.
 *
 * Everything is scoped under .wz-thread. Nothing here restyles a Bootstrap
 * class, so it cannot reach anything else on the page.
 */

.wz-thread {
    margin-top: 12px;
    border-top: 1px solid #e8ecf3;
    padding-top: 10px;
}

/* ------------------------------------------------------------- the toggle */

.wz-thread__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #44506a;
    font-size: 0.86rem;
    text-align: left;
    cursor: pointer;
}

.wz-thread__toggle:hover,
.wz-thread__toggle:focus-visible {
    background: #f4f7fc;
    border-color: #dde5f2;
}

.wz-thread__label {
    font-weight: 600;
    white-space: nowrap;
}

/*
 * The last thing said, so a closed thread still tells you something. It gives
 * up its width first -- the label and the unread count are the parts that must
 * never be cut.
 */
.wz-thread__last {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #7a879e;
}

.wz-thread__unread {
    flex: 0 0 auto;
    min-width: 20px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #d93025;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
}

.wz-thread__caret {
    flex: 0 0 auto;
    margin-left: auto;
    color: #9aa6bd;
    transition: transform 0.15s ease;
}

.wz-thread.is-open .wz-thread__caret {
    transform: rotate(180deg);
}

.wz-thread.is-open .wz-thread__last {
    display: none;   /* the thread itself is open; the preview is now noise */
}

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

.wz-thread__panel {
    padding: 10px 2px 2px;
}

/*
 * A fixed maximum height with its own scroll.
 *
 * A long thread must not push the job's own actions off the bottom of the
 * screen -- Accept and Submit work are why the creator is on this page.
 */
.wz-thread__list {
    max-height: 300px;
    overflow-y: auto;
    margin: 0 0 10px;
    padding: 0;
    list-style: none;
}

.wz-thread__msg {
    max-width: 82%;
    margin: 0 0 8px;
    padding: 8px 11px;
    border-radius: 12px 12px 12px 3px;
    background: #f1f4f9;
}

/* Yours on the right, in the platform's own colour. */
.wz-thread__msg.is-mine {
    margin-left: auto;
    border-radius: 12px 12px 3px 12px;
    background: #e8f0fe;
}

.wz-thread__who {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 3px;
    color: #5a6782;
    font-size: 0.74rem;
    font-weight: 700;
}

.wz-thread__when {
    color: #97a3b8;
    font-weight: 400;
    white-space: nowrap;
}

/*
 * Line breaks the sender typed are kept, and a long unbroken string -- a
 * pasted URL, which is most of what gets pasted here -- wraps instead of
 * stretching the panel sideways.
 */
.wz-thread__body {
    margin: 0;
    color: #2b3445;
    font-size: 0.86rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* --------------------------------------------------------------- states */

.wz-thread__state {
    margin: 0 0 10px;
    color: #7a879e;
    font-size: 0.82rem;
}

.wz-thread__state--bad {
    color: #b3261e;
}

.wz-thread__retry {
    margin-left: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: #1a56db;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

/* ------------------------------------------------------------- the form */

.wz-thread__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.wz-thread__input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #d5dde9;
    border-radius: 8px;
    color: #2b3445;
    font-size: 0.86rem;
    font-family: inherit;
    line-height: 1.45;
    resize: vertical;
}

.wz-thread__input:focus {
    border-color: #1a56db;
    outline: 2px solid rgba(26, 86, 219, 0.18);
    outline-offset: 0;
}

.wz-thread__send {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    /* 40px is the smallest reliable touch target, and a tablet at 768px
       gets the desktop row -- measured at 38px before this. */
    min-height: 40px;
    padding: 9px 14px;
    border: 0;
    border-radius: 8px;
    background: #1a56db;
    color: #fff;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
}

.wz-thread__send:hover:not(:disabled) {
    background: #164bc0;
}

.wz-thread__send:disabled {
    opacity: 0.6;
    cursor: default;
}

.wz-thread__hint {
    margin: 6px 0 0;
    color: #9aa6bd;
    font-size: 0.73rem;
}

/* --------------------------------------------------------------- phones */

@media (max-width: 575.98px) {
    /*
     * The preview goes first. On a narrow screen there is no room for both it
     * and the label, and "Messages · 2" is the part that decides whether
     * anyone opens the thread at all.
     */
    .wz-thread__last {
        display: none;
    }

    .wz-thread__msg {
        max-width: 92%;
    }

    .wz-thread__list {
        max-height: 240px;
    }

    /* The send button under the box, both full width: a 40px target beside a
       textarea is not reliably hittable with a thumb. */
    .wz-thread__form {
        flex-wrap: wrap;
    }

    .wz-thread__input {
        flex: 1 1 100%;
    }

    .wz-thread__send {
        flex: 1 1 100%;
        justify-content: center;
        padding: 11px 14px;
    }
}

/* ------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
    .wz-thread__caret {
        transition: none;
    }
}

/* ------------------------------------------------- the brand's conversations
 *
 * A list of every job the brand has paid for, which is deliberately a wider set
 * than the delivered-work cards below it. Collapsed unless somebody is waiting,
 * so it never pushes the work off the top of the page.
 */

.wz-convos {
    margin: 0 0 18px;
    border: 1px solid #e3e9f2;
    border-radius: 10px;
    background: #fff;
}

.wz-convos__head {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 14px;
    color: #2b3445;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

/* Safari draws its own triangle through ::-webkit-details-marker. */
.wz-convos__head::-webkit-details-marker {
    display: none;
}

.wz-convos__title {
    flex: 1 1 auto;
}

.wz-convos__badge {
    padding: 2px 9px;
    border-radius: 999px;
    background: #d93025;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.wz-convos__count {
    padding: 2px 9px;
    border-radius: 999px;
    background: #eef2f8;
    color: #5a6782;
    font-size: 0.75rem;
    font-weight: 700;
}

.wz-convos__list {
    margin: 0;
    padding: 0 14px 6px;
    list-style: none;
}

.wz-convos__item {
    padding: 4px 0 10px;
    border-top: 1px solid #f0f3f8;
}

.wz-convos__item:first-child {
    border-top: 0;
}

.wz-convos__job {
    margin: 10px 0 0;
    color: #2b3445;
    font-size: 0.88rem;
    font-weight: 600;
}

.wz-convos__who {
    color: #7a879e;
    font-weight: 400;
}

/* Inside the panel the thread already has a separator above it. */
.wz-convos__item .wz-thread {
    margin-top: 4px;
    border-top: 0;
    padding-top: 0;
}
