/* ═══ Palladium.Chat — widget commentaires / chat ═══
   Accent : suit la couleur primaire du site ; surchargable par site via
   --pd-chat-accent (ex. dans le CSS du thème ou du page builder). */

.pd-chat {
    --pdch-accent: var(--pd-chat-accent, var(--bs-primary, #e85d04));
    --pdch-accent-contrast: #fff;
    --pdch-text: var(--bs-body-color, #1f2937);
    --pdch-dim: #6b7280;
    --pdch-line: #e5e7eb;
    --pdch-card: #f3f4f6;
    --pdch-radius: 14px;
    color: var(--pdch-text);
    font-size: .95rem;
    line-height: 1.55;
    max-width: 100%;
}

.pd-chat-loading,
.pd-chat-empty {
    color: var(--pdch-dim);
    padding: 1rem 0;
}

/* ── Composer ── */
.pd-chat-composer {
    background: var(--pdch-card);
    border-radius: var(--pdch-radius);
    padding: .9rem 1rem;
    margin-bottom: 1.25rem;
}

.pd-chat-composer-reply {
    margin-top: .6rem;
    margin-bottom: .25rem;
    padding: .7rem .8rem;
}

.pd-chat-composer .pd-chat-input {
    display: block;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    resize: vertical;
    min-height: 2.4rem;
    color: var(--pdch-text);
    font: inherit;
}

    .pd-chat-composer .pd-chat-input::placeholder {
        color: var(--pdch-dim);
    }

.pd-chat-name {
    display: block;
    width: min(260px, 100%);
    margin-bottom: .5rem;
    padding: .4rem .65rem;
    border: 1px solid var(--pdch-line);
    border-radius: 8px;
    background: #fff;
    color: var(--pdch-text);
    font: inherit;
    font-size: .88rem;
}

.pd-chat-composer-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: .6rem;
    margin-top: .5rem;
    padding-top: .55rem;
    border-top: 1px solid var(--pdch-line);
}

.pd-chat-send {
    background: var(--pdch-accent);
    color: var(--pdch-accent-contrast);
    border: none;
    border-radius: 999px;
    padding: .5rem 1.4rem;
    font-weight: 600;
    font-size: .92rem;
    cursor: pointer;
    transition: filter .15s ease;
}

    .pd-chat-send:hover:not(:disabled) {
        filter: brightness(.92);
    }

    .pd-chat-send:disabled {
        opacity: .6;
        cursor: default;
    }

.pd-chat-send-sm {
    padding: .3rem .9rem;
    font-size: .85rem;
}

.pd-chat-login a {
    color: var(--pdch-accent);
    font-weight: 600;
    text-decoration: none;
}

.pd-chat-pending {
    background: color-mix(in srgb, var(--pdch-accent) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--pdch-accent) 30%, transparent);
    color: var(--pdch-text);
    border-radius: 10px;
    padding: .6rem .9rem;
    margin-bottom: 1rem;
    font-size: .9rem;
}

.pd-chat-error {
    color: #dc2626;
    font-size: .85rem;
    margin-top: .35rem;
}

/* ── Header ── */
.pd-chat-header {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: 1rem 0 .9rem;
    border-top: 1px solid var(--pdch-line);
}

.pd-chat-htitle {
    font-size: 1.15rem;
    font-weight: 700;
}

.pd-chat-count {
    background: var(--pdch-accent);
    color: var(--pdch-accent-contrast);
    border-radius: 999px;
    min-width: 1.7em;
    text-align: center;
    padding: .1em .55em;
    font-size: .8rem;
    font-weight: 700;
}

.pd-chat-sort {
    margin-left: auto;
    border: none;
    background: transparent;
    color: var(--pdch-dim);
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
    outline: none;
}

/* ── Fil ── */
.pd-chat-list {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

.pd-chat-item {
    position: relative;
}

.pd-chat-row {
    display: flex;
    gap: .8rem;
    align-items: flex-start;
}

.pd-chat-avatar {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #9ca3af;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .02em;
    user-select: none;
}

.pd-chat-item-deleted .pd-chat-avatar {
    background: var(--pdch-line);
    color: var(--pdch-dim);
}

.pd-chat-main {
    flex: 1;
    min-width: 0;
}

.pd-chat-meta {
    display: flex;
    align-items: baseline;
    gap: .55rem;
    flex-wrap: wrap;
}

.pd-chat-author {
    font-weight: 700;
}

.pd-chat-date {
    color: var(--pdch-dim);
    font-size: .84rem;
}

.pd-chat-body {
    margin-top: .15rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.pd-chat-deleted {
    color: var(--pdch-dim);
    font-style: italic;
}

/* ── Actions ── */
.pd-chat-actions {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-top: .45rem;
}

.pd-chat-act {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: .3rem .55rem;
    color: var(--pdch-dim);
    font: inherit;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}

    .pd-chat-act:hover:not(:disabled) {
        background: var(--pdch-card);
        color: var(--pdch-text);
    }

    .pd-chat-act:disabled {
        cursor: default;
        opacity: .75;
    }

    .pd-chat-act svg {
        flex: 0 0 auto;
    }

.pd-chat-like.on,
.pd-chat-dislike.on {
    color: var(--pdch-accent);
}

.pd-chat-moreb {
    font-size: 1.1rem;
    line-height: 1;
    padding: .3rem .5rem;
}

/* ── Menu "…" ── */
.pd-chat-menuwrap {
    position: relative;
}

.pd-chat-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 30;
    min-width: 150px;
    background: #fff;
    border: 1px solid var(--pdch-line);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    padding: .3rem;
    display: flex;
    flex-direction: column;
}

    .pd-chat-menu button {
        background: transparent;
        border: none;
        border-radius: 7px;
        text-align: left;
        padding: .45rem .7rem;
        font: inherit;
        font-size: .88rem;
        color: var(--pdch-text);
        cursor: pointer;
    }

        .pd-chat-menu button:hover:not(:disabled) {
            background: var(--pdch-card);
        }

        .pd-chat-menu button:disabled {
            color: var(--pdch-dim);
            cursor: default;
        }

.pd-chat-menu-danger {
    color: #dc2626 !important;
}

/* ── Réponses (fil avec connecteur) ── */
.pd-chat-replies {
    position: relative;
    margin-left: 19px; /* centre de l'avatar parent (40px/2 - 1px) */
    padding-left: 30px;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

    /* coude arrondi vers chaque réponse */
    .pd-chat-replies > .pd-chat-item::before {
        content: "";
        position: absolute;
        left: -30px;
        top: -14px;
        width: 22px;
        height: 32px;
        border-left: 2px solid var(--pdch-line);
        border-bottom: 2px solid var(--pdch-line);
        border-bottom-left-radius: 14px;
    }

    /* ligne verticale qui continue vers les réponses suivantes */
    .pd-chat-replies > .pd-chat-item:not(:last-child)::after {
        content: "";
        position: absolute;
        left: -30px;
        top: 14px;
        bottom: -1.2rem;
        width: 2px;
        background: var(--pdch-line);
    }

    /* avatars plus petits dans les réponses */
    .pd-chat-replies .pd-chat-avatar {
        width: 34px;
        height: 34px;
        font-size: .78rem;
    }

/* profondeur max atteinte : plus d'indentation ni de connecteur */
.pd-chat-replies-flat {
    margin-left: 0;
    padding-left: 0;
}

    .pd-chat-replies-flat > .pd-chat-item::before,
    .pd-chat-replies-flat > .pd-chat-item::after {
        display: none;
    }

/* ── Voir plus ── */
.pd-chat-more {
    margin-top: 1.1rem;
    background: transparent;
    border: 1px solid var(--pdch-line);
    border-radius: 999px;
    padding: .45rem 1.2rem;
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    color: var(--pdch-text);
    cursor: pointer;
}

    .pd-chat-more:hover {
        background: var(--pdch-card);
    }

/* ── Édition inline ── */
.pd-chat-main > .pd-chat-input {
    width: 100%;
    border: 1px solid var(--pdch-line);
    border-radius: 10px;
    padding: .5rem .7rem;
    font: inherit;
    margin-top: .3rem;
    background: #fff;
    color: var(--pdch-text);
}

/* ── Sombre (thèmes qui posent data-bs-theme) ── */
[data-bs-theme="dark"] .pd-chat,
.pd-dark .pd-chat {
    --pdch-text: #e5e7eb;
    --pdch-dim: #9ca3af;
    --pdch-line: #374151;
    --pdch-card: #1f2937;
}

    [data-bs-theme="dark"] .pd-chat .pd-chat-menu,
    .pd-dark .pd-chat .pd-chat-menu {
        background: #111827;
    }

    [data-bs-theme="dark"] .pd-chat .pd-chat-name,
    [data-bs-theme="dark"] .pd-chat .pd-chat-main > .pd-chat-input,
    .pd-dark .pd-chat .pd-chat-name,
    .pd-dark .pd-chat .pd-chat-main > .pd-chat-input {
        background: #111827;
    }
