/* services/frontend/css/forum.css — Telegram-like Community (Redesigned) */

/* --- CSS Custom Properties for community section --- */
:root {
    --chat-bubble-mine: linear-gradient(135deg, #1d3557 0%, #162d4a 100%);
    --chat-bubble-other: rgba(30, 41, 59, 0.55);
    --chat-bubble-radius: 1.25rem;
    --chat-bubble-tail: 0.3rem;
    --chat-panel-bg: #0b1121;
    --chat-header-bg: rgba(11, 17, 33, 0.92);
    --chat-composer-bg: rgba(11, 17, 33, 0.92);
    --chat-border: rgba(255, 255, 255, 0.07);
    --chat-transition: 0.2s ease;
    --chat-transition-layout: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sender-hue-1: #60a5fa;
    --sender-hue-2: #a78bfa;
    --sender-hue-3: #34d399;
    --sender-hue-4: #fb923c;
    --sender-hue-5: #f472b6;
    --sender-hue-6: #facc15;
    --sender-hue-7: #22d3ee;
}

/* --- Community sidebar header --- */
.community-header {
    padding: 0.75rem 1rem 0.5rem;
    border-bottom: 1px solid var(--chat-border);
    background: var(--chat-header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.community-header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.community-header p {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.65rem;
    color: #64748b;
    margin-top: 0.125rem;
    letter-spacing: 0.02em;
    font-weight: 400;
}

/* --- Chat list (main screen) --- */
.chat-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background var(--chat-transition), transform 0.1s, border-color var(--chat-transition);
    user-select: none;
    position: relative;
    border: 1px solid transparent;
}
.chat-list-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.04);
}
.chat-list-item:active { transform: scale(0.985); }
.chat-list-item.active {
    background: rgba(88, 0, 0, 0.08);
    border-color: rgba(173, 0, 11, 0.2);
    box-shadow: inset 3px 0 0 0 #AD000B;
}
.chat-list-item.active .chat-list-title {
    color: #ffffff;
    font-weight: 700;
}

.chat-list-avatar {
    width: 3.25rem; height: 3.25rem;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.9));
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    position: relative;
}
.chat-list-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-list-type-icon {
    position: absolute; bottom: -1px; right: -1px;
    font-size: 0.7rem; line-height: 1;
    background: var(--chat-panel-bg);
    border-radius: 50%;
    padding: 2px;
    border: 1px solid var(--chat-panel-bg);
}

.chat-list-body { flex: 1; min-width: 0; }
.chat-list-top { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.chat-list-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.825rem; font-weight: 600; color: #e2e8f0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    letter-spacing: 0.01em;
}
.chat-list-time {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.6rem; color: #475569; flex-shrink: 0;
    font-weight: 500; letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}
.chat-list-preview {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem; color: #64748b;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 2px;
    display: flex; align-items: center;
    letter-spacing: 0.01em;
    font-weight: 400;
}
.chat-list-preview b { color: #94a3b8; font-weight: 500; }

.chat-unread-badge {
    min-width: 1.25rem; height: 1.25rem;
    border-radius: 9999px;
    background: linear-gradient(135deg, #AD000B, #8a0009);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 0.35rem;
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(173, 0, 11, 0.4);
    animation: unreadPulse 2s ease-in-out infinite;
}

@keyframes unreadPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(173, 0, 11, 0.4); }
    50% { box-shadow: 0 0 14px rgba(173, 0, 11, 0.7); }
}

.chat-list-views {
    display: flex; align-items: center; gap: 3px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.6rem; color: #334155;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* --- Chat header --- */
.chat-header {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: var(--chat-header-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    z-index: 10;
    position: relative;
    border-bottom: none;
}
.chat-header::after {
    content: '';
    position: absolute; bottom: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08) 20%, rgba(255,255,255,0.08) 80%, transparent);
}
.chat-header-title {
    font-size: 0.875rem; font-weight: 700; color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

/* --- Pinned message banner --- */
.pinned-banner {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(88, 0, 0, 0.08);
    border-bottom: 1px solid rgba(173, 0, 11, 0.15);
    font-size: 0.75rem; color: #f87171;
    cursor: pointer;
    transition: background var(--chat-transition);
}
.pinned-banner:hover { background: rgba(88, 0, 0, 0.12); }

/* --- Chat bubbles --- */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    scroll-behavior: smooth;
    position: relative;
}

.chat-bubble-wrap {
    display: flex; flex-direction: column;
    max-width: 80%;
    margin-bottom: 0.25rem;
    animation: bubbleIn 0.25s ease-out;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.chat-bubble-wrap.is-mine { align-self: flex-end; }
.chat-bubble-wrap.is-other { align-self: flex-start; }
.chat-bubble-wrap.is-grouped { margin-bottom: 0.0625rem; }
.chat-bubble-wrap.is-grouped .bubble-sender { display: none; }

@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-bubble {
    padding: 0.5rem 0.75rem;
    border-radius: var(--chat-bubble-radius);
    font-size: 0.875rem;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
}
.chat-bubble.is-mine {
    background: var(--chat-bubble-mine);
    border-bottom-right-radius: var(--chat-bubble-tail);
    color: #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.chat-bubble.is-other {
    background: var(--chat-bubble-other);
    border-bottom-left-radius: var(--chat-bubble-tail);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
}
.chat-bubble.search-highlight {
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.6), 0 0 12px rgba(251, 191, 36, 0.2);
    animation: searchGlow 1.5s ease-in-out infinite;
}

@keyframes searchGlow {
    0%, 100% { box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.6), 0 0 12px rgba(251, 191, 36, 0.2); }
    50% { box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.8), 0 0 20px rgba(251, 191, 36, 0.35); }
}

.bubble-sender {
    font-size: 0.7rem; font-weight: 700;
    margin-bottom: 0.125rem;
    color: var(--sender-hue-1);
}
.bubble-sender.is-expert { color: #f87171; }

.bubble-time {
    font-size: 0.6rem;
    color: #475569;
    margin-top: 0.125rem;
    display: flex; align-items: center; gap: 0.25rem;
    justify-content: flex-end;
}
.bubble-time .edited-tag { font-style: italic; opacity: 0.7; }
.bubble-time .read-checks { letter-spacing: -2px; }
.bubble-time .read-checks.is-read { color: #3b82f6; }

.bubble-reply-preview {
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    border-left: 2px solid #AD000B;
    background: rgba(173, 0, 11, 0.06);
    border-radius: 0.25rem;
    font-size: 0.7rem;
    color: #f87171;
    cursor: pointer;
    max-height: 2.5rem;
    overflow: hidden;
    transition: background var(--chat-transition);
}
.bubble-reply-preview:hover { background: rgba(173, 0, 11, 0.1); }

/* --- Chat start message (original post) --- */
.chat-start-message {
    align-self: center;
    max-width: 90%;
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--chat-border);
    border-radius: 1rem;
    position: relative;
}
.chat-start-author {
    display: flex; align-items: center; gap: 0.625rem;
    margin-bottom: 0.625rem;
}
.chat-start-avatar {
    width: 2rem; height: 2rem;
    border-radius: 50%;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    font-size: 0.65rem; font-weight: 700; color: #64748b;
    flex-shrink: 0;
}
.chat-start-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-start-name {
    font-size: 0.75rem; font-weight: 700; color: #94a3b8;
    display: block;
}
.chat-start-date {
    font-size: 0.6rem; color: #475569;
    display: block; margin-top: 1px;
}
.chat-start-title {
    font-size: 0.95rem; font-weight: 800; color: #f1f5f9;
    margin-bottom: 0.375rem;
    line-height: 1.3;
}
.chat-start-content {
    font-size: 0.8rem; color: #94a3b8;
    line-height: 1.5;
    white-space: pre-line;
}

/* --- Date separator --- */
.date-separator {
    display: flex; align-items: center; justify-content: center;
    padding: 0.75rem 0;
    align-self: center;
    width: 100%;
}
.date-separator span {
    font-size: 0.65rem;
    font-weight: 600;
    color: #475569;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    padding: 0.25rem 0.875rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* --- Reactions --- */
.reactions-row {
    display: flex; flex-wrap: wrap; gap: 0.3rem;
    margin-top: 0.35rem;
}
.reaction-badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    cursor: pointer;
    transition: all var(--chat-transition);
}
.reaction-badge:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
}
.reaction-badge.is-mine {
    border-color: rgba(173, 0, 11, 0.4);
    background: rgba(173, 0, 11, 0.1);
    color: #f1f5f9;
}
.reaction-badge .count { font-size: 0.6rem; color: #64748b; font-weight: 700; }
.reaction-badge.is-mine .count { color: rgba(255, 255, 255, 0.6); }

/* --- Reaction picker --- */
.emoji-picker-popup {
    display: flex;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    backdrop-filter: blur(24px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 100;
    animation: emojiPopIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes emojiPopIn {
    from { opacity: 0; transform: translate(-50%, 0) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.emoji-picker-popup button {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.3rem 0.65rem;
    border-radius: 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.emoji-picker-popup button:hover {
    background: rgba(173, 0, 11, 0.15);
    border-color: rgba(173, 0, 11, 0.4);
    color: #f1f5f9;
}
.emoji-picker-popup button:active { transform: scale(0.95); }

/* --- Context menu --- */
.context-menu {
    position: fixed;
    background: rgba(15, 23, 42, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.875rem;
    padding: 0.375rem;
    min-width: 11rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255,255,255,0.03) inset;
    backdrop-filter: blur(24px);
    z-index: 200;
    animation: ctxIn 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ctxIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.context-menu-item {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem; color: #e2e8f0;
    cursor: pointer; transition: all 0.12s;
    border: none; background: none; width: 100%; text-align: left;
    border-radius: 0.5rem;
}
.context-menu-item:hover { background: rgba(255, 255, 255, 0.06); }
.context-menu-item:active { transform: scale(0.97); }
.context-menu-item.danger { color: #f87171; }
.context-menu-item.danger:hover { background: rgba(248, 113, 113, 0.08); }

/* --- Composer --- */
.chat-composer {
    padding: 0.5rem 0.75rem;
    background: var(--chat-composer-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    position: relative;
}
.chat-composer::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08) 20%, rgba(255,255,255,0.08) 80%, transparent);
}
.chat-composer-reply {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    margin-bottom: 0.375rem;
    background: rgba(173, 0, 11, 0.06);
    border-left: 2px solid #AD000B;
    border-radius: 0.375rem;
    font-size: 0.7rem; color: #f87171;
}
.chat-composer-input {
    flex: 1;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 1.25rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    color: #e2e8f0;
    outline: none;
    resize: none;
    max-height: 8rem;
    overflow-y: auto;
    transition: border-color var(--chat-transition), box-shadow var(--chat-transition);
    font-family: inherit;
}
.chat-composer-input:focus {
    border-color: rgba(173, 0, 11, 0.3);
    box-shadow: 0 0 0 3px rgba(173, 0, 11, 0.08);
}
.chat-composer-input::placeholder { color: #334155; }

.composer-btn {
    width: 2.5rem; height: 2.5rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; border: none;
    cursor: pointer; transition: all var(--chat-transition);
    flex-shrink: 0;
}
.composer-btn.attach { background: transparent; color: #475569; }
.composer-btn.attach:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    transform: rotate(15deg);
}
.composer-btn.send {
    background: linear-gradient(135deg, #AD000B, #8a0009);
    color: #fff;
    box-shadow: 0 2px 10px rgba(173, 0, 11, 0.3);
}
.composer-btn.send:hover {
    background: linear-gradient(135deg, #c00, #AD000B);
    box-shadow: 0 4px 16px rgba(173, 0, 11, 0.5);
    transform: scale(1.05);
}
.composer-btn.send:active { transform: scale(0.95); }

/* --- Pending files --- */
.pending-files {
    display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.375rem;
    padding: 0.25rem 0;
}
.pending-file {
    display: flex; align-items: center; gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    background: rgba(173, 0, 11, 0.08);
    border: 1px solid rgba(173, 0, 11, 0.15);
    border-radius: 0.5rem;
    font-size: 0.7rem; color: #f87171;
}
.pending-file-thumb {
    width: 2rem; height: 2rem;
    border-radius: 0.25rem;
    object-fit: cover;
}
.pending-file button {
    background: none; border: none;
    color: #f87171; cursor: pointer; font-size: 0.85rem;
    opacity: 0.7; transition: opacity 0.15s;
}
.pending-file button:hover { opacity: 1; }

/* --- Drag-and-drop overlay --- */
.drop-zone-overlay {
    position: absolute; inset: 0;
    background: rgba(173, 0, 11, 0.08);
    backdrop-filter: blur(4px);
    border: 2px dashed rgba(173, 0, 11, 0.4);
    border-radius: 0.75rem;
    display: flex; align-items: center; justify-content: center;
    z-index: 30;
    animation: fadeIn 0.2s ease-out;
}
.drop-zone-overlay span {
    font-size: 0.875rem;
    font-weight: 700;
    color: #f87171;
    background: rgba(15, 23, 42, 0.8);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(173, 0, 11, 0.2);
}

/* --- Attachment in bubble --- */
.bubble-attachment img {
    max-width: 100%; max-height: 220px;
    border-radius: 0.625rem; margin-top: 0.375rem;
    cursor: pointer;
    transition: opacity var(--chat-transition);
}
.bubble-attachment img:hover { opacity: 0.9; }
.bubble-attachment a {
    display: inline-flex; align-items: center; gap: 0.25rem;
    color: #f87171; font-size: 0.75rem;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    background: rgba(173, 0, 11, 0.06);
    border-radius: 0.375rem;
    margin-top: 0.25rem;
    transition: background var(--chat-transition);
}
.bubble-attachment a:hover { background: rgba(173, 0, 11, 0.12); }

/* --- Participants drawer --- */
.participants-drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 20rem; max-width: 85vw;
    background: rgba(11, 17, 33, 0.97);
    border-left: 1px solid var(--chat-border);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    z-index: 150;
    display: flex; flex-direction: column;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.4);
}

/* --- Search bar in chat --- */
.chat-search-bar {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(30, 41, 59, 0.5);
    border-bottom: 1px solid var(--chat-border);
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-search-bar input {
    flex: 1; background: transparent; border: none; outline: none;
    color: #e2e8f0; font-size: 0.875rem; font-family: inherit;
}
.chat-search-bar input::placeholder { color: #334155; }

/* --- Filter chips --- */
.filter-chip {
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--chat-transition);
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(30, 41, 59, 0.4);
    color: #64748b;
    flex-shrink: 0;
    display: inline-flex; align-items: center; gap: 0.3rem;
}
@media (min-width: 768px) {
    .filter-chip {
        padding: 0.25rem 0.6rem;
        font-size: 0.7rem;
    }
}
.filter-chip.active {
    position: relative;
    background: transparent;
    color: #ffffff;
    border-color: rgba(173, 0, 11, 0.3);
    box-shadow: 0 4px 20px rgba(173, 0, 11, 0.5);
    transform: translateY(-1px);
    font-weight: 600;
}
.filter-chip.active::after {
    content: '';
    position: absolute; bottom: 0; left: 10%; right: 10%; height: 40%;
    background: linear-gradient(to top, rgba(173, 0, 11, 0.8), rgba(173, 0, 11, 0.2));
    border-radius: 0 0 9999px 9999px;
    z-index: -1; filter: blur(6px);
}
.filter-chip:not(.active):hover {
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    border-color: rgba(255, 255, 255, 0.1);
}

/* --- Category badges --- */
.badge-cat {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.04em;
    border: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(15, 23, 42, 0.5);
}
.badge-cat::before { content: ''; width: 4px; height: 4px; border-radius: 50%; }
.badge-avia::before    { background: #7dd3fc; box-shadow: 0 0 5px #0c4a6e; }
.badge-rail::before    { background: #fbcfe8; box-shadow: 0 0 5px #831843; }
.badge-auto::before    { background: #86efac; box-shadow: 0 0 5px #14532d; }
.badge-water::before   { background: #a5b4fc; box-shadow: 0 0 5px #312e81; }
.badge-metro::before   { background: #fdba74; box-shadow: 0 0 5px #7c2d12; }
.badge-general::before { background: #cbd5e1; box-shadow: 0 0 5px #334155; }
.badge-avia    { color: #7dd3fc; }
.badge-rail    { color: #fbcfe8; }
.badge-auto    { color: #86efac; }
.badge-water   { color: #a5b4fc; }
.badge-metro   { color: #fdba74; }
.badge-general { color: #cbd5e1; }

/* --- Post content typography --- */
.post-content { line-height: 1.6; font-size: 0.875rem; color: var(--text-main); }
.post-content h1, .post-content h2, .post-content h3 { color: var(--text-header); font-weight: 700; margin-top: 1rem; margin-bottom: 0.5rem; }
.post-content p { margin-bottom: 0.75rem; }
.post-content p:last-child { margin-bottom: 0; }

/* --- Create modal discussion type selector --- */
.type-selector { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.type-selector-btn {
    display: flex; align-items: center; gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.8rem; font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(30, 41, 59, 0.4);
    color: #64748b;
    cursor: pointer; transition: all 0.15s;
}
.type-selector-btn:hover { border-color: rgba(255, 255, 255, 0.15); color: #94a3b8; }
.type-selector-btn.active {
    border-color: rgba(173, 0, 11, 0.4);
    background: rgba(173, 0, 11, 0.08);
    color: #fff;
    box-shadow: 0 0 12px rgba(173, 0, 11, 0.2);
}

/* --- Sidebar toolbar --- */
.sidebar-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}
.sidebar-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.375rem;
    width: 100%;
}
.sidebar-new-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 1rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1.5px solid #AD000B;
    color: #f87171;
    background: transparent;
    cursor: pointer;
    transition: all var(--chat-transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.sidebar-new-btn:hover {
    background: rgba(173, 0, 11, 0.1);
    box-shadow: 0 0 16px rgba(173, 0, 11, 0.25);
    transform: translateY(-1px);
}

/* --- Skeleton loading --- */
.chat-list-skeleton {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.625rem 0.75rem;
}
.skeleton-avatar {
    width: 3.25rem; height: 3.25rem;
    border-radius: 50%;
    flex-shrink: 0;
}
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.skeleton-line {
    height: 0.625rem;
    border-radius: 0.25rem;
}
.skeleton-line.short { width: 40%; }
.skeleton-avatar, .skeleton-line {
    background: linear-gradient(90deg, rgba(30,41,59,0.5) 25%, rgba(51,65,85,0.3) 50%, rgba(30,41,59,0.5) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Empty state --- */
.community-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 1rem;
    border: 1px dashed rgba(255, 255, 255, 0.06);
}
.community-empty-state .empty-icon {
    font-size: 2.5rem;
    opacity: 0.3;
    margin-bottom: 0.75rem;
}
.community-empty-state p {
    color: #475569;
    font-size: 0.8rem;
    font-weight: 500;
}
.community-empty-state .empty-cta {
    display: inline-flex; align-items: center; gap: 0.375rem;
    margin-top: 1rem;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    font-size: 0.75rem; font-weight: 700;
    border: 1px solid rgba(173, 0, 11, 0.3);
    color: #f87171;
    background: rgba(173, 0, 11, 0.06);
    cursor: pointer;
    transition: all var(--chat-transition);
}
.community-empty-state .empty-cta:hover {
    background: rgba(173, 0, 11, 0.12);
    box-shadow: 0 0 12px rgba(173, 0, 11, 0.2);
}

/* --- Scroll to bottom FAB --- */
.scroll-to-bottom-fab {
    position: fixed;
    bottom: 4.5rem; right: 1rem;
    width: 2.25rem; height: 2.25rem;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: #94a3b8;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: all var(--chat-transition);
    z-index: 20;
    animation: fabIn 0.2s ease-out;
}
.scroll-to-bottom-fab:hover {
    background: rgba(173, 0, 11, 0.15);
    border-color: rgba(173, 0, 11, 0.3);
    color: #f87171;
    transform: scale(1.1);
}
.scroll-to-bottom-fab .new-msg-count {
    position: absolute; top: -0.375rem; right: -0.375rem;
    min-width: 1rem; height: 1rem;
    border-radius: 9999px;
    background: #AD000B;
    color: #fff;
    font-size: 0.55rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 0.25rem;
}

@keyframes fabIn {
    from { opacity: 0; transform: scale(0.5) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Community layout wrapper --- */
.community-layout-wrap {
    display: flex;
    flex-direction: column;
}

/* --- Chat panel (mobile: fullscreen overlay with slide) --- */
.community-chat-panel {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: var(--chat-panel-bg);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.3s;
    visibility: hidden;
    pointer-events: none;
}
.community-chat-panel.panel-visible {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0s;
}

/* --- Desktop empty state (hidden on mobile) --- */
.community-chat-empty {
    display: none;
}

/* --- Desktop two-panel layout --- */
@media (min-width: 768px) {
    .community-layout-wrap {
        flex-direction: row;
        height: calc(100vh - 6.5rem);
        margin: 6.5rem auto 0;
        width: 95%;
        max-width: 80rem;
        border-radius: 1rem;
        overflow: hidden;
        border: 1px solid var(--chat-border);
    }
    .community-sidebar {
        width: 26rem;
        flex-shrink: 0;
        border-right: 1px solid var(--chat-border);
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,0.08) transparent;
    }
    .community-sidebar::-webkit-scrollbar { width: 3px; }
    .community-sidebar::-webkit-scrollbar-track { background: transparent; }
    .community-sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.08);
        border-radius: 3px;
    }
    .community-sidebar::-webkit-scrollbar-thumb:hover {
        background: rgba(255,255,255,0.15);
    }
    .community-chat-panel {
        position: static;
        inset: auto;
        z-index: auto;
        flex: 1;
        min-width: 0;
        border-left: 1px solid var(--chat-border);
        transform: none;
        transition: none;
        visibility: hidden;
        pointer-events: none;
    }
    .community-chat-panel.panel-visible {
        visibility: visible;
        pointer-events: auto;
    }
    .chat-bubble-wrap {
        -webkit-user-select: text;
        user-select: text;
        -webkit-touch-callout: default;
    }
    .community-chat-empty {
        display: block;
        flex: 1;
        min-width: 0;
    }
    .sidebar-toolbar {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }
    .sidebar-filters {
        flex: 1;
        flex-wrap: wrap;
        justify-content: center;
    }
    .sidebar-new-btn {
        padding: 0.35rem 0.75rem;
        border-radius: 0.5rem;
        font-size: 0.7rem;
    }
    .community-header {
        padding: 0.625rem 1rem 0.5rem;
    }
}

/* --- Scrollbar --- */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* --- Pull to refresh --- */
.pull-to-refresh-indicator {
    display: flex; align-items: center; justify-content: center;
    padding: 0.5rem;
    overflow: hidden;
    transition: height 0.2s ease;
}
.pull-to-refresh-indicator svg {
    width: 1.25rem; height: 1.25rem;
    color: #475569;
    transition: transform 0.2s ease;
}
.pull-to-refresh-indicator.refreshing svg {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Animations --- */
@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.chat-slide-in { animation: slideInUp 0.3s ease-out; }
.fade-in { animation: fadeIn 0.2s ease-out; }

@keyframes longPressRipple {
    from { transform: scale(0); opacity: 0.4; }
    to { transform: scale(2.5); opacity: 0; }
}

/* --- Mobile touch improvements --- */
@media (max-width: 767px) {
    .chat-list-item { min-height: 3.5rem; }
    .context-menu-item { padding: 0.625rem 1rem; min-height: 2.75rem; }
    .composer-btn { width: 2.75rem; height: 2.75rem; }
    .chat-header button { min-width: 2.75rem; min-height: 2.75rem; }
}

