/* ==========================================================================
   A conversation read as on a ticket (Zammad-like): the customer on the left,
   us on the right, with initials. The event page (.ev-page) and the
   conversations of the Messagerie (.ev-conversation).
   ========================================================================== */
.ev-page, .ev-conversation {
    --ev-bg: var(--body-bg, #ffffff);
    --ev-soft: #f9fafb;
    --ev-border: var(--border-color, #e5e7eb);
    --ev-border-soft: #eef0f3;
    --ev-text: var(--text-color, #111827);
    --ev-muted: #6b7280;
    --ev-accent: #4f46e5;
    --ev-accent-soft: #eef2ff;
    --ev-accent-text: #3730a3;
    --ev-note: #fffbeb;
    --ev-note-border: #f59e0b;
    --ev-wa: #f0fdf4;
    --ev-wa-border: #bbf7d0;
    --ev-danger: #b91c1c;
}
.ea-dark-scheme :is(.ev-page, .ev-conversation) {
    --ev-soft: rgba(255, 255, 255, 0.04);
    --ev-border-soft: rgba(255, 255, 255, 0.08);
    --ev-muted: #9ca3af;
    --ev-accent: #818cf8;
    --ev-accent-soft: rgba(129, 140, 248, 0.15);
    --ev-accent-text: #c7d2fe;
    --ev-note: rgba(245, 158, 11, 0.1);
    --ev-wa: rgba(34, 197, 94, 0.08);
    --ev-wa-border: rgba(34, 197, 94, 0.3);
    --ev-danger: #f87171;
}
.ev-conversation { color: var(--ev-text); }
:is(.ev-page, .ev-conversation) .ev-muted { color: var(--ev-muted); }
:is(.ev-page, .ev-conversation) .ev-muted-note { color: var(--ev-muted); font-size: 0.78rem; }
:is(.ev-page, .ev-conversation) .ev-link { background: none; border: 0; padding: 0; color: var(--ev-accent); font-size: 0.78rem; cursor: pointer; }
:is(.ev-page, .ev-conversation) .ev-link:hover { text-decoration: underline; }
.ev-conversation :is(.ev-link, summary, .ev-msg-time):focus-visible { outline: 2px solid var(--ev-accent); outline-offset: 2px; }

.ev-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ev-items > li[hidden] { display: none; }
.ev-day { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; color: var(--ev-muted); font-size: 0.75rem; font-weight: 600; }
.ev-day::before, .ev-day::after { content: ''; flex: 1; height: 1px; background: var(--ev-border); }
.ev-empty { text-align: center; color: var(--ev-muted); font-size: 0.9rem; padding: 24px 0; }

/* ---- The conversation: the customer on the left, us on the right ---- */
.ev-msg { display: flex; align-items: flex-start; gap: 10px; margin-top: 6px; }
.ev-msg.right { flex-direction: row-reverse; }
.ev-msg.continued { margin-top: -4px; }
.ev-avatar {
    width: 34px; height: 34px; flex: none; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--avatar, #6b7280); color: #ffffff; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; user-select: none;
}
.ev-msg.continued .ev-avatar { visibility: hidden; height: 0; }
.ev-msg-col { min-width: 0; max-width: min(78%, 760px); display: flex; flex-direction: column; gap: 4px; }
.ev-msg.right .ev-msg-col { align-items: flex-end; }
.ev-msg.left .ev-msg-col { align-items: flex-start; }

.ev-bubble {
    position: relative; max-width: 100%; display: flex; flex-direction: column; gap: 8px;
    padding: 9px 13px; border-radius: 14px; border: 1px solid var(--ev-border);
    background: var(--ev-bg); color: var(--ev-text);
}
.ev-msg.left .ev-bubble { border-top-left-radius: 4px; }
.ev-msg.right .ev-bubble { border-top-right-radius: 4px; background: var(--ev-accent-soft); border-color: transparent; }
.ev-msg.continued.left .ev-bubble { border-top-left-radius: 14px; }
.ev-msg.continued.right .ev-bubble { border-top-right-radius: 14px; }
.ev-msg-text, .ev-email-text { font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Emails: the bubble opens the detail */
.ev-email .ev-bubble { cursor: pointer; transition: box-shadow 0.15s; }
.ev-email .ev-bubble:hover { box-shadow: 0 0 0 2px var(--ev-border-soft); }
.ev-email.unread .ev-bubble { border-color: var(--ev-accent); }
.ev-email.failed .ev-bubble { border-color: #fca5a5; }
.ev-email-text.is-long:not(.expanded) {
    max-height: calc(1.5em * 12); overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent);
    mask-image: linear-gradient(to bottom, #000 70%, transparent);
}
:is(.ev-page, .ev-conversation) .ev-email-more { align-self: flex-start; font-size: 0.8rem; }
.ev-email-empty { margin: 0; font-size: 0.85rem; font-style: italic; color: var(--ev-muted); }
/* "⋯": signature and quoted conversation */
.ev-email-rest > summary {
    display: inline-flex; align-items: center; justify-content: center; list-style: none; cursor: pointer;
    min-width: 30px; height: 16px; padding: 0 6px; border-radius: 999px; line-height: 1;
    background: var(--ev-border-soft); color: var(--ev-muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 1px;
}
.ev-msg.right .ev-email-rest > summary { background: rgba(255, 255, 255, 0.6); }
.ea-dark-scheme .ev-msg.right .ev-email-rest > summary { background: rgba(255, 255, 255, 0.1); }
.ev-email-rest > summary::-webkit-details-marker { display: none; }
.ev-email-rest > summary:hover { color: var(--ev-text); }
.ev-email-rest-text {
    margin-top: 8px; padding-left: 10px; border-left: 3px solid var(--ev-border);
    font-size: 0.82rem; line-height: 1.45; color: var(--ev-muted);
    white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow-y: auto; cursor: auto;
}
.ev-attachments { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.8rem; }
.ev-attachments li { display: flex; border: 1px solid var(--ev-border); border-radius: 6px; background: var(--ev-bg); max-width: 100%; }
.ev-attachments li > a, .ev-attachments li > span { padding: 3px 8px; color: var(--ev-text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-attachments li > a:hover { color: var(--ev-accent); }
.ev-attachments .fa-paperclip { color: var(--ev-muted); }

/* Who sent it to whom: the head of the bubble, on click */
.ev-email-details {
    margin: -1px 0 2px; padding-bottom: 8px; border-bottom: 1px solid var(--ev-border);
    font-size: 0.8rem; color: var(--ev-muted); cursor: auto;
    display: flex; flex-direction: column; gap: 6px;
}
.ev-msg.right .ev-email-details { border-bottom-color: rgba(79, 70, 229, 0.18); }
.ea-dark-scheme .ev-msg.right .ev-email-details { border-bottom-color: rgba(255, 255, 255, 0.1); }
.ev-email-details[hidden] { display: none; }
.ev-email-details dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0; }
.ev-email-details dt { font-weight: 600; color: var(--ev-muted); }
.ev-email-details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--ev-text); }
.ev-email-details dd .ev-muted { color: var(--ev-muted); }
.ev-email-details-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; }
:is(.ev-page, .ev-conversation) .ev-email-details-actions .ev-link { font-size: 0.78rem; }
.ev-email-original[hidden] { display: none; }
.ev-msg.original-open .ev-msg-col, .ev-msg.original-open .ev-bubble { width: 100%; }
.ev-email-frame { display: block; width: 100%; height: 380px; border: 1px solid var(--ev-border); border-radius: 8px; background: #ffffff; resize: vertical; }

/* Under the bubble: reply, state, channel and time */
.ev-msg-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 0 4px; font-size: 0.76rem; color: var(--ev-muted); }
.ev-msg.right .ev-msg-meta { justify-content: flex-end; }
:is(.ev-page, .ev-conversation) .ev-msg-meta .ev-link { font-size: 0.78rem; }
:is(.ev-page, .ev-conversation) .ev-msg-reply { font-weight: 600; }
:is(.ev-page, .ev-conversation) .ev-msg-time { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; cursor: pointer; }
:is(.ev-page, .ev-conversation) .ev-msg-time:hover { color: var(--ev-text); }
.ev-msg.details-open .ev-msg-time { color: var(--ev-accent); }
.ev-badge { font-size: 0.68rem; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.ev-badge-new { background: var(--ev-accent); color: #ffffff; }
.ev-badge-danger { background: #fee2e2; color: #991b1b; }

/* WhatsApp: a green edge, the time inside the bubble */
.ev-bubble-wa { border-left: 3px solid #22c55e; }
.ev-msg.right .ev-bubble-wa { border-left: 0; border-right: 3px solid #22c55e; background: var(--ev-wa); }
.ev-msg.right .ev-bubble-wa, .ev-msg.left .ev-bubble-wa { gap: 2px; padding-bottom: 5px; }
.ev-bubble-time { align-self: flex-end; font-size: 0.7rem; color: var(--ev-muted); white-space: nowrap; }
.ev-bubble-time .fa-whatsapp { color: #16a34a; }
/* WhatsApp files: templates/admin/whatsapp/_styles.html.twig (the Messagerie too) */

/* Customer request without its email (platform), older activities */
.ev-bubble-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ev-muted); }
.ev-request-link { font-size: 0.8rem; }

/* Internal notes: ours, in yellow */
.ev-msg.right .ev-bubble-note { background: var(--ev-note); border: 1px dashed var(--ev-note-border); }
.ev-bubble-note .ev-bubble-label { color: #b45309; }
.ea-dark-scheme .ev-bubble-note .ev-bubble-label { color: #fbbf24; }
.ev-bubble-note .activity-content.editing, .ev-bubble-call .activity-content.editing { display: none; }
.ev-bubble-call .activity-content:empty { display: none; }
:is(.ev-page, .ev-conversation) .activity-edit-form { display: none; }
:is(.ev-page, .ev-conversation) .activity-edit-form.active { display: flex; flex-direction: column; gap: 6px; min-width: min(520px, 70vw); }
:is(.ev-page, .ev-conversation) .activity-edit-actions { display: flex; justify-content: flex-end; gap: 6px; }

@media (max-width: 640px) {
    .ev-msg-col { max-width: calc(100% - 34px); }
    .ev-avatar { width: 28px; height: 28px; font-size: 0.7rem; }
    .ev-email-details dl { grid-template-columns: 1fr; gap: 0; }
    .ev-email-details dt { padding-top: 4px; }
}

/* Why an email did not leave */
.ev-email-error { margin: 0; padding: 6px 10px; border-radius: 8px; background: #fef2f2; color: #991b1b; font-size: 0.85rem; }
.ea-dark-scheme .ev-email-error { background: rgba(220, 38, 38, 0.15); color: #fca5a5; }
