/* Reply quote (quoted message preview inside bubble) */
.chat-reply-quote {
    border-right: 3px solid #25d366;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 6px;
    max-width: 100%;
}

.chat-reply-quote.is-mine {
    border-right-color: #128c7e;
    background: rgba(255, 255, 255, 0.35);
}

.chat-reply-quote-label {
    font-size: 11px;
    font-weight: 700;
    color: #128c7e;
    margin-bottom: 2px;
}

.chat-reply-quote-text {
    font-size: 12px;
    color: #54656f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Reply button — always visible, inside message footer */
.chat-reply-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    min-height: 28px;
    padding: 4px 10px;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.07);
    color: #475569;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    opacity: 1;
    transition: background 0.15s, color 0.15s, transform 0.12s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.chat-reply-trigger:hover,
.chat-reply-trigger:focus {
    background: rgba(37, 211, 102, 0.18);
    color: #0f766e;
    outline: none;
}

.chat-reply-trigger:active {
    transform: scale(0.96);
}

.chat-reply-trigger-icon {
    font-size: 13px;
    line-height: 1;
}

.chat-reply-trigger-text {
    line-height: 1;
}

/* Footer row: reply + time/meta */
.chat-msg-footer,
.wa-bubble .meta-line.chat-msg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
    min-height: 28px;
    width: 100%;
}

.chat-msg-footer-meta {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
    margin-inline-start: auto;
}

/* Staff internal chat */
.staff-chat-msg {
    position: relative;
}

.staff-chat-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.staff-chat-msg.is-mine .staff-chat-footer {
    border-top-color: rgba(15, 23, 42, 0.08);
}

.staff-chat-footer .staff-chat-time {
    margin-top: 0 !important;
    text-align: left;
}

/* WhatsApp-style patient chat rows */
.wa-bubble-row {
    position: relative;
    display: flex;
    margin-bottom: 8px;
    padding-inline: 4px;
}

.wa-bubble-row.mine {
    justify-content: flex-end;
}

.wa-bubble-row.theirs {
    justify-content: flex-start;
}

.wa-bubble-row .wa-bubble {
    max-width: min(82%, 520px);
}

/* Chatbot widget messages */
.clinic-cw-msg {
    position: relative;
    display: flex;
    flex-direction: column;
}

.clinic-cw-msg-footer {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.clinic-cw-msg.user .clinic-cw-msg-footer {
    border-top-color: rgba(15, 23, 42, 0.06);
}

.clinic-cw-msg.bot .clinic-cw-msg-footer,
.clinic-cw-msg.admin .clinic-cw-msg-footer {
    border-top-color: rgba(255, 255, 255, 0.25);
}

.clinic-cw-msg-footer .chat-reply-trigger {
    background: rgba(255, 255, 255, 0.55);
}

.clinic-cw-msg.user .clinic-cw-msg-footer .chat-reply-trigger {
    background: rgba(15, 23, 42, 0.06);
}

/* Admin chatbot thread */
.admin-chat-msg {
    position: relative;
    display: flex;
    justify-content: flex-start;
    margin: 10px 0;
}

.admin-chat-msg.is-outgoing {
    justify-content: flex-end;
}

.admin-chat-bubble {
    max-width: min(82%, 560px);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
}

.admin-chat-bubble.is-admin {
    background: #dbeafe;
}

.admin-chat-bubble.is-bot {
    background: #dcfce7;
}

.admin-chat-bubble-head {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
}

.admin-chat-bubble .chat-msg-footer {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(15, 23, 42, 0.07);
}

/* Composer reply preview bar */
.chat-reply-bar {
    display: none;
    align-items: center;
    gap: 8px;
    background: #f0f2f5;
    border-right: 3px solid #25d366;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
    width: 100%;
}

.chat-reply-bar.is-visible {
    display: flex;
}

.chat-reply-bar-main {
    flex: 1;
    min-width: 0;
}

.chat-reply-bar-label {
    font-size: 11px;
    font-weight: 700;
    color: #128c7e;
}

.chat-reply-bar-preview {
    font-size: 12px;
    color: #54656f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-reply-bar-cancel {
    border: 0;
    background: transparent;
    color: #64748b;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    min-width: 32px;
    min-height: 32px;
}

.clinic-cw-compose-wrap {
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.clinic-cw-compose-wrap .chat-reply-bar {
    margin: 8px 10px 0;
    width: auto;
}

/* Mobile: larger tap target */
@media (max-width: 767px) {
    .chat-reply-trigger {
        min-height: 32px;
        padding: 6px 12px;
        font-size: 12px;
    }

    .wa-bubble-row .wa-bubble {
        max-width: 88%;
    }

    .admin-chat-bubble {
        max-width: 90%;
    }

    .clinic-cw-msg {
        max-width: 88% !important;
    }
}

@media (max-width: 480px) {
    .chat-reply-trigger-text {
        display: inline;
    }

    .wa-bubble-row {
        padding-inline: 2px;
    }
}
