/* Tawasul chat UI (من chat-send-patch — مُحمَّل من Chat.cshtml) */
#users-conversation li:last-child {
    animation: tw-msg-appear 0.2s ease-out;
}
@keyframes tw-msg-appear {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
#users-conversation li:not(.right) .conversation-list {
    display: flex;
    flex-direction: row-reverse;
}
#users-conversation li:not(.right) .ctext-wrap-content {
    background: #d9fdd3;
    border-radius: 10px 2px 10px 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
[data-bs-theme="dark"] #users-conversation li:not(.right) .ctext-wrap-content {
    background: #1e3a2a;
}
#users-conversation li.right .ctext-wrap-content {
    border-radius: 2px 10px 10px 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
#users-conversation .chat-time {
    font-size: 0.72rem;
    color: #8696a0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 3px;
    gap: 2px;
}
#users-conversation li.tw-sending .ctext-wrap-content {
    opacity: 0.75;
}
#users-conversation .chat-day-title {
    text-align: center;
    margin: 10px 0 6px;
    position: relative;
}
#users-conversation .chat-day-title .title {
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 20px;
    padding: 3px 14px;
    font-size: .72rem;
    color: #667781;
    font-weight: 500;
    display: inline-block;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
[data-bs-theme="dark"] #users-conversation .chat-day-title .title {
    background: rgba(32,44,51,.9);
    color: #8696a0;
    border-color: rgba(255,255,255,.08);
}
#users-conversation .message-box-drop {
    opacity: 0;
    transition: opacity .15s;
}
#users-conversation .ctext-wrap:hover .message-box-drop {
    opacity: 1;
}
#users-conversation img.img-fluid {
    max-width: 220px;
    border-radius: 8px;
    transition: opacity .2s;
}
#users-conversation img.img-fluid:hover {
    opacity: 0.92;
}
#users-conversation audio {
    width: 220px;
    height: 36px;
    margin-top: 4px;
    border-radius: 6px;
}
#users-conversation a[href]:not(.chat-message-link):not([href^="javascript"]) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0,0,0,.04);
    border-radius: 8px;
    text-decoration: none;
    font-size: .85rem;
    margin-top: 4px;
    border: 1px solid rgba(0,0,0,.06);
}
#users-conversation a[href]:not(.chat-message-link):not([href^="javascript"]):hover {
    background: rgba(0,0,0,.08);
}
#users-conversation .replymessage-block {
    background: rgba(0,0,0,.04);
    border-radius: 6px;
    border-left: 3px solid #06cf9c;
    padding: 5px 8px;
    margin-bottom: 6px;
}
[data-bs-theme="dark"] #users-conversation .replymessage-block {
    background: rgba(255,255,255,.05);
}

/* WhatsApp-like quoted reply (يربط بـ data-reply-target-id للتمرير للرسالة الأصلية) */
#users-conversation .tawasul-reply-quote {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 0 6px 0;
    padding: 6px 10px;
    border: 0;
    border-radius: 6px;
    text-align: start;
    font: inherit;
    line-height: 1.35;
    background: rgba(11, 20, 26, 0.06);
    border-inline-start: 4px solid #06cf9c;
}
#users-conversation li.right .tawasul-reply-quote--incoming {
    background: rgba(11, 20, 26, 0.06);
    border-inline-start-color: #06cf9c;
}
#users-conversation li:not(.right) .tawasul-reply-quote--outgoing {
    background: rgba(11, 20, 26, 0.08);
    border-inline-start-color: #008069;
}
#users-conversation .tawasul-reply-author {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #06cf9c;
    margin-bottom: 2px;
}
#users-conversation li:not(.right) .tawasul-reply-quote--outgoing .tawasul-reply-author {
    color: #008069;
}
#users-conversation .tawasul-reply-snippet {
    display: block;
    font-size: 0.875rem;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#users-conversation .tawasul-reply-quote--clickable {
    cursor: pointer;
}
#users-conversation .tawasul-reply-quote--clickable:hover {
    filter: brightness(0.96);
}
#users-conversation .tawasul-reply-quote--clickable:focus-visible {
    outline: 2px solid rgba(6, 207, 156, 0.5);
    outline-offset: 1px;
}
[data-bs-theme="dark"] #users-conversation .tawasul-reply-quote {
    background: rgba(255, 255, 255, 0.06);
}
[data-bs-theme="dark"] #users-conversation .tawasul-reply-snippet {
    color: #aebac1;
}

#users-conversation li.tawasul-msg-flash {
    animation: tawasul-msg-flash 1.4s ease;
}
@keyframes tawasul-msg-flash {
    0%, 100% { opacity: 1; }
    20% { opacity: 1; filter: drop-shadow(0 0 8px rgba(6, 207, 156, 0.75)); }
    50% { filter: drop-shadow(0 0 4px rgba(6, 207, 156, 0.4)); }
}

#users-conversation .text-muted.small[style*="italic"] {
    font-size: .75rem;
    margin-bottom: 4px;
}
#tw-scroll-btn {
    position: absolute;
    bottom: 72px;
    right: 20px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    border: none;
    box-shadow: 0 2px 10px rgba(0,0,0,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 50;
    color: #3b4a54;
    font-size: 1.1rem;
    animation: tw-pop .2s ease;
    transition: transform .15s, box-shadow .15s;
}
#tw-scroll-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(0,0,0,.22);
}
@keyframes tw-pop {
    from { transform: scale(.6); opacity: 0; }
    to   { transform: scale(1);  opacity: 1; }
}

/* —— لوحة المرفقات (ملفات / صور / صوت) + حاوية أدوات الدردشة —— */
.tawasul-chat-tools-accordion {
    margin-top: 0.35rem;
}

.tawasul-chat-tools-accordion .tawasul-attach-strip,
.tawasul-chat-tools-accordion .tawasul-templates-strip {
    margin-top: 0;
}

.tawasul-attach-strip__surface {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
    border: 1px solid rgba(11, 20, 26, 0.06) !important;
    box-shadow: 0 4px 24px rgba(11, 20, 26, 0.06), 0 1px 3px rgba(11, 20, 26, 0.04) !important;
}

[data-bs-theme="dark"] .tawasul-attach-strip__surface {
    background: linear-gradient(180deg, rgba(32, 44, 51, 0.98) 0%, rgba(26, 35, 40, 0.96) 100%);
    border-color: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25) !important;
}

.tawasul-attach-strip__close {
    position: absolute;
    top: 0.65rem;
    inset-inline-end: 0.5rem;
    z-index: 3;
    opacity: 0.55;
    transform: scale(0.92);
}

.tawasul-attach-strip__close:hover {
    opacity: 1;
}

.tawasul-attach-strip__head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
    padding-inline-end: 2rem;
}

.tawasul-attach-strip__head-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.12), rgba(13, 202, 240, 0.1));
    color: #0d6efd;
    font-size: 1.05rem;
}

[data-bs-theme="dark"] .tawasul-attach-strip__head-icon {
    background: linear-gradient(135deg, rgba(13, 202, 240, 0.2), rgba(13, 110, 253, 0.15));
    color: #6ea8fe;
}

.tawasul-attach-strip__head-text {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #667781;
}

[data-bs-theme="dark"] .tawasul-attach-strip__head-text {
    color: #8696a0;
}

.tawasul-attach-swiper {
    margin-inline: -0.15rem;
    padding-bottom: 0.15rem;
}

.tawasul-attach-swiper .swiper-slide.tawasul-attach-slide {
    width: 100px;
    height: auto;
}

@media (min-width: 576px) {
    .tawasul-attach-swiper .swiper-slide.tawasul-attach-slide {
        width: 108px;
    }
}

.tawasul-attach-card {
    height: 100%;
}

.tawasul-attach-card__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    width: 100%;
    margin: 0;
    padding: 0.65rem 0.35rem 0.5rem;
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none !important;
    color: inherit;
    background: #fff;
    border: 1px solid rgba(11, 20, 26, 0.08);
    box-shadow: 0 2px 8px rgba(11, 20, 26, 0.05);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

[data-bs-theme="dark"] .tawasul-attach-card__btn {
    background: rgba(42, 57, 66, 0.85);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.tawasul-attach-card__btn:hover {
    transform: translateY(-2px);
    border-color: rgba(13, 110, 253, 0.35);
    box-shadow: 0 6px 16px rgba(11, 20, 26, 0.1);
}

[data-bs-theme="dark"] .tawasul-attach-card__btn:hover {
    border-color: rgba(110, 168, 254, 0.4);
}

.tawasul-attach-card__btn:focus-visible {
    outline: 2px solid rgba(13, 110, 253, 0.45);
    outline-offset: 2px;
}

.tawasul-attach-card__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    font-size: 1.35rem;
    transition: transform 0.15s ease;
}

.tawasul-attach-card__btn:hover .tawasul-attach-card__icon {
    transform: scale(1.06);
}

.tawasul-attach-card__icon--doc {
    background: linear-gradient(145deg, rgba(13, 110, 253, 0.14), rgba(13, 110, 253, 0.06));
    color: #0d6efd;
}

.tawasul-attach-card__icon--gallery {
    background: linear-gradient(145deg, rgba(0, 128, 105, 0.16), rgba(6, 207, 156, 0.08));
    color: #008069;
}

.tawasul-attach-card__icon--audio {
    background: linear-gradient(145deg, rgba(111, 66, 193, 0.16), rgba(214, 51, 132, 0.08));
    color: #6f42c1;
}

[data-bs-theme="dark"] .tawasul-attach-card__icon--doc {
    background: linear-gradient(145deg, rgba(13, 110, 253, 0.28), rgba(13, 110, 253, 0.1));
    color: #9ec5fe;
}

[data-bs-theme="dark"] .tawasul-attach-card__icon--gallery {
    background: linear-gradient(145deg, rgba(6, 207, 156, 0.22), rgba(0, 128, 105, 0.12));
    color: #06cf9c;
}

[data-bs-theme="dark"] .tawasul-attach-card__icon--audio {
    background: linear-gradient(145deg, rgba(111, 66, 193, 0.28), rgba(214, 51, 132, 0.12));
    color: #c29ffa;
}

.tawasul-attach-card__label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    color: #3b4a54;
}

[data-bs-theme="dark"] .tawasul-attach-card__label {
    color: #e9edef;
}

/* —— قائمة قوالب الدردشة (Tawasul) —— */
.tawasul-templates-strip {
    margin-top: 0.35rem;
}

.tawasul-templates-strip__surface {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
    border: 1px solid rgba(11, 20, 26, 0.06) !important;
    box-shadow: 0 4px 24px rgba(11, 20, 26, 0.06), 0 1px 3px rgba(11, 20, 26, 0.04) !important;
}

[data-bs-theme="dark"] .tawasul-templates-strip__surface {
    background: linear-gradient(180deg, rgba(32, 44, 51, 0.98) 0%, rgba(26, 35, 40, 0.96) 100%);
    border-color: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25) !important;
}

.tawasul-templates-strip__close {
    position: absolute;
    top: 0.65rem;
    inset-inline-end: 0.5rem;
    z-index: 3;
    opacity: 0.55;
    transform: scale(0.92);
}

.tawasul-templates-strip__close:hover {
    opacity: 1;
}

.tawasul-templates-strip__head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
    padding-inline-end: 2rem;
}

.tawasul-templates-strip__head-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(0, 128, 105, 0.12), rgba(6, 207, 156, 0.1));
    color: #008069;
    font-size: 1.05rem;
}

[data-bs-theme="dark"] .tawasul-templates-strip__head-icon {
    background: linear-gradient(135deg, rgba(6, 207, 156, 0.18), rgba(0, 128, 105, 0.12));
    color: #06cf9c;
}

.tawasul-templates-strip__head-text {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #667781;
}

[data-bs-theme="dark"] .tawasul-templates-strip__head-text {
    color: #8696a0;
}

.tawasul-templates-swiper {
    margin-inline: -0.15rem;
    padding-bottom: 0.15rem;
}

.tawasul-templates-swiper .swiper-slide.tawasul-template-slide {
    width: 112px;
    height: auto;
}

@media (min-width: 576px) {
    .tawasul-templates-swiper .swiper-slide.tawasul-template-slide {
        width: 122px;
    }
}

.tawasul-template-card {
    position: relative;
    display: block;
    text-decoration: none !important;
    color: inherit;
    border-radius: 14px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.tawasul-template-card:hover {
    transform: translateY(-2px);
}

.tawasul-template-card:focus-visible {
    outline: 2px solid rgba(6, 207, 156, 0.55);
    outline-offset: 2px;
}

.tawasul-template-card__inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(11, 20, 26, 0.08);
    box-shadow: 0 2px 8px rgba(11, 20, 26, 0.06);
    min-height: 118px;
}

[data-bs-theme="dark"] .tawasul-template-card__inner {
    background: rgba(42, 57, 66, 0.85);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.tawasul-template-card:hover .tawasul-template-card__inner {
    border-color: rgba(0, 128, 105, 0.35);
    box-shadow: 0 6px 18px rgba(11, 20, 26, 0.1);
}

[data-bs-theme="dark"] .tawasul-template-card:hover .tawasul-template-card__inner {
    border-color: rgba(6, 207, 156, 0.35);
}

.tawasul-template-card__media {
    position: relative;
    aspect-ratio: 16 / 10;
    background: linear-gradient(145deg, #eef2f6 0%, #e2e8f0 100%);
    overflow: hidden;
}

[data-bs-theme="dark"] .tawasul-template-card__media {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.03) 100%);
}

.tawasul-template-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tawasul-template-card__media--empty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tawasul-template-card__placeholder-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: rgba(0, 128, 105, 0.45);
}

[data-bs-theme="dark"] .tawasul-template-card__placeholder-icon {
    color: rgba(6, 207, 156, 0.45);
}

.tawasul-template-card__title {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    padding: 0.45rem 0.5rem 0.5rem;
    color: #111b21;
    text-align: center;
    max-width: 100%;
}

[data-bs-theme="dark"] .tawasul-template-card__title {
    color: #e9edef;
}

.tawasul-template-card__send-hint {
    position: absolute;
    top: 0.35rem;
    inset-inline-end: 0.35rem;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #fff;
    background: linear-gradient(135deg, #008069, #06cf9c);
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.18s ease, transform 0.18s ease;
    box-shadow: 0 2px 6px rgba(0, 128, 105, 0.35);
    pointer-events: none;
    z-index: 1;
}

.tawasul-template-card:hover .tawasul-template-card__send-hint {
    opacity: 1;
    transform: scale(1);
}

.tawasul-template-card.sending .tawasul-template-card__send-hint {
    opacity: 0;
}

.tawasul-template-card .spinner-container {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(2px);
}

[data-bs-theme="dark"] .tawasul-template-card .spinner-container {
    background: rgba(32, 44, 51, 0.82);
}

.tawasul-template-card.sending .tawasul-template-card__inner {
    opacity: 0.55;
    pointer-events: none;
}
