/* Tigule conversation detail — modern chat shell */
:root {
    --conv-mobile-nav-height: calc(3.6rem + env(safe-area-inset-bottom, 0));
}

.conv-page {
    max-width: 840px;
    margin: 0 auto;
    padding-top: 1rem;
    padding-bottom: 1.5rem;
}

.conv-shell {
    display: flex;
    flex-direction: column;
    min-height: min(78vh, 720px);
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 20px;
    border: 1px solid #e8eaed;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

/* Header */
.conv-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: linear-gradient(135deg, #C8102E 0%, #9e0c24 55%, #5a0815 100%);
    color: #fff;
    flex-shrink: 0;
}

.conv-header h1,
.conv-header .conv-header__name {
    color: #fff !important;
}

.conv-header__back {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.conv-header__back:hover {
    background: rgba(255, 255, 255, 0.24);
    color: #fff;
    transform: translateX(-1px);
}

.conv-header__avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 0.02em;
    border: 2px solid rgba(255, 255, 255, 0.35);
}

.conv-header__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.conv-header__meta {
    flex: 1;
    min-width: 0;
}

.conv-header__name {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-header__sub {
    margin: 0.15rem 0 0;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.82);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-header__actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.conv-header__btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.conv-header__btn:hover {
    background: rgba(255, 255, 255, 0.26);
    color: #fff;
}

.conv-header__btn--danger:hover {
    background: rgba(220, 53, 69, 0.55);
}

/* Banners */
.conv-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.65rem 1rem;
    font-size: 0.82rem;
    line-height: 1.45;
    flex-shrink: 0;
}

.conv-banner i {
    margin-top: 0.1rem;
    flex-shrink: 0;
}

.conv-banner--warn {
    background: #fff8e6;
    color: #7a5a00;
    border-bottom: 1px solid #ffe08a;
}

.conv-banner--danger {
    background: #fff1f2;
    color: #9f1239;
    border-bottom: 1px solid #fecdd3;
}

.conv-banner strong {
    display: block;
    font-size: 0.84rem;
    margin-bottom: 0.1rem;
}

.conv-banner__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.45rem;
}

.conv-banner__actions .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
}

/* Listing context strip */
.conv-listing {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: #fafbfc;
    border-bottom: 1px solid #ececec;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.conv-listing:hover {
    background: #f3f4f6;
    color: inherit;
}

.conv-listing__thumb {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    background: #e9ecef;
}

.conv-listing__thumb--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
}

.conv-listing__body {
    flex: 1;
    min-width: 0;
}

.conv-listing__title {
    display: block;
    font-size: 0.88rem;
    font-weight: 700;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-listing__meta {
    display: block;
    font-size: 0.78rem;
    color: #6b7280;
    margin-top: 0.1rem;
}

.conv-listing__chevron {
    color: #C8102E;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* Message area */
.conv-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 1.1rem;
    background:
        radial-gradient(circle at 20% 10%, rgba(200, 16, 46, 0.03) 0%, transparent 45%),
        linear-gradient(180deg, #f7f8fa 0%, #eef1f5 100%);
    scroll-behavior: smooth;
}

.conv-row {
    display: flex;
    margin-bottom: 0.55rem;
}

.conv-row--out {
    justify-content: flex-end;
}

.conv-row--in {
    justify-content: flex-start;
}

.conv-bubble {
    max-width: min(78%, 520px);
    min-width: 0;
    padding: 0.65rem 0.85rem;
    position: relative;
}

.conv-bubble--out {
    background: linear-gradient(135deg, #C8102E 0%, #a00d25 100%);
    color: #fff;
    border-radius: 18px 18px 6px 18px;
    box-shadow: 0 4px 14px rgba(200, 16, 46, 0.22);
}

.conv-bubble--in {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-radius: 18px 18px 18px 6px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.conv-bubble--unread {
    border-left: 3px solid #C8102E;
    background: linear-gradient(90deg, #fff5f6 0%, #fff 100%);
}

.conv-bubble__text {
    font-size: 0.92rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.conv-bubble__text a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.conv-bubble--out .conv-bubble__text a {
    color: #fff;
}

.conv-bubble--in .conv-bubble__text a {
    color: #C8102E;
}

.conv-bubble__meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-top: 0.35rem;
    font-size: 0.68rem;
    opacity: 0.78;
}

.conv-bubble--out .conv-bubble__meta {
    color: rgba(255, 255, 255, 0.88);
}

.conv-bubble--in .conv-bubble__meta {
    color: #9ca3af;
}

.conv-bubble__status i {
    font-size: 0.72rem;
}

.conv-bubble__status .fa-check-double {
    color: #bfdbfe;
}

.conv-empty {
    padding: 1rem 0.25rem;
    color: #9ca3af;
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    text-align: left;
}

.conv-empty i {
    font-size: 1.15rem;
    margin-bottom: 0;
    margin-top: 0.1rem;
    opacity: 0.55;
    flex-shrink: 0;
}

.conv-empty p {
    margin: 0;
    font-size: 0.86rem;
    line-height: 1.45;
}

/* Composer */
.conv-composer {
    padding: 0.75rem 1rem 1rem;
    background: #fff;
    border-top: 1px solid #ececec;
    flex-shrink: 0;
}

.conv-composer .conversation-quick-replies {
    margin-bottom: 0.65rem;
}

.conv-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 22px;
    padding: 0.4rem 0.45rem 0.4rem 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.conv-input-wrap:focus-within {
    border-color: rgba(200, 16, 46, 0.45);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
    background: #fff;
}

.conv-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    min-height: 24px;
    max-height: 120px;
    padding: 0.35rem 0;
    font-size: 0.92rem;
    line-height: 1.45;
    outline: none;
}

.conv-input::placeholder {
    color: #9ca3af;
}

.conv-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #C8102E 0%, #a00d25 100%);
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.3);
}

.conv-send-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 16px rgba(200, 16, 46, 0.38);
}

.conv-send-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.conv-composer__hint {
    font-size: 0.7rem;
    color: #9ca3af;
    margin: 0.4rem 0 0 0.5rem;
}

@media (max-width: 768.98px) {
    /* Full-screen chat: hide site chrome (like community threads) */
    body.messaging-chat-page {
        overflow: hidden;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    body.messaging-chat-page main {
        padding-bottom: 0 !important;
    }

    body.messaging-chat-page .navbar,
    body.messaging-chat-page #referralBanner,
    body.messaging-chat-page .mobile-bottom-nav,
    body.messaging-chat-page .site-footer,
    body.messaging-chat-page #goToTopBtn,
    body.messaging-chat-page #fabContainer,
    body.messaging-chat-page .container.mt-3:has(.global-flash-message) {
        display: none !important;
    }

    body.messaging-chat-page .conv-page {
        padding: 0 !important;
        max-width: 100%;
    }

    body.messaging-chat-page .conv-shell {
        position: fixed;
        inset: 0;
        z-index: 1045;
        min-height: 0;
        max-height: none;
        height: auto;
        border-radius: 0;
        border: none;
        box-shadow: none;
        display: flex;
        flex-direction: column;
    }

    body.messaging-chat-page .conv-header,
    body.messaging-chat-page .conv-banner,
    body.messaging-chat-page .conv-listing {
        flex-shrink: 0;
    }

    body.messaging-chat-page .conv-header {
        padding-top: calc(0.75rem + env(safe-area-inset-top, 0));
    }

    body.messaging-chat-page .conv-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0.65rem 0.85rem;
    }

    body.messaging-chat-page .conv-composer {
        flex-shrink: 0;
        padding: 0.55rem 0.85rem calc(0.65rem + env(safe-area-inset-bottom, 0));
        background: #fff;
        border-top: 1px solid #ececec;
        box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
    }

    .conv-page {
        padding: 0 !important;
        max-width: 100%;
    }

    .conv-shell {
        min-height: 0;
        max-height: none;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
    }

    .conv-header {
        padding: 0.75rem 0.85rem;
        gap: 0.6rem;
    }

    .conv-header__back,
    .conv-header__btn {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .conv-header__avatar {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .conv-header__name {
        font-size: 0.92rem;
        line-height: 1.25;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .conv-header__sub {
        font-size: 0.72rem;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .conv-listing {
        display: none;
    }

    .conv-bubble {
        max-width: 88%;
    }

    .conv-composer__hint {
        display: none;
    }

    .conv-composer .conversation-quick-replies {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin-right: -0.25rem;
        padding-bottom: 0.15rem;
        margin-bottom: 0.5rem;
    }

    .conv-composer .conversation-quick-replies::-webkit-scrollbar {
        display: none;
    }

    .conv-composer .conversation-quick-reply {
        flex-shrink: 0;
        font-size: 0.74rem;
        padding: 0.32rem 0.65rem;
    }

    .conv-send-btn {
        width: 38px;
        height: 38px;
    }
}

/* Hide Tigule Assistant on active conversation UI */
body:has(.conv-shell) .tigule-assistant-widget,
body:has(.conv-shell) #tigule-assistant-backdrop {
    display: none !important;
}
