/**
 * Community Page Styles
 * Full-size inline chat with sidebar layout
 */

/* Wider content area for community page */
.page-community .page-content {
    max-width: 1200px;
}

/* Two-column layout */
.community-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    margin-top: 8px;
}

/* ========================================
   FULL-PAGE CHAT
   ======================================== */
.community-chat {
    display: flex;
    flex-direction: column;
    height: 600px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    background: #fff;
}

/* Chat header */
.community-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #041E42;
    color: #fff;
    flex-shrink: 0;
}

.community-chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.community-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6b7280;
    flex-shrink: 0;
}

.community-status-dot.connected {
    background: #22c55e;
}

.community-status-dot.reconnecting {
    background: #FFB81C;
    animation: community-pulse 1.2s ease-in-out infinite;
}

@keyframes community-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.community-user-count {
    font-size: 12px;
    font-weight: 400;
    color: #9ca3af;
    margin-left: 4px;
}

/* Connection status bar */
.community-connection-status {
    display: none;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 12px;
}

.community-connection-status.disconnected {
    display: block;
    background: #fef2f2;
    color: #dc2626;
}

.community-connection-status.reconnecting {
    display: block;
    background: #fffbeb;
    color: #d97706;
}

/* Messages area */
.community-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #f8f9fa;
}

.community-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.community-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* Single message */
.community-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 0;
}

.community-msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: #e8ecf1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.community-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.community-msg-avatar .avatar-fallback {
    font-size: 16px;
    font-weight: 700;
    color: #041E42;
}

.community-msg-body {
    flex: 1;
    min-width: 0;
}

.community-msg-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.community-msg-name {
    font-size: 14px;
    font-weight: 700;
    color: #041E42;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.community-msg-time {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

.community-msg-text {
    font-size: 15px;
    line-height: 1.45;
    color: #374151;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* System messages */
.community-system-msg {
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    padding: 6px 0;
    font-style: italic;
}

/* Typing indicator */
.community-chat-typing {
    font-size: 13px;
    color: #6b7280;
    padding: 4px 18px 8px;
    min-height: 26px;
    flex-shrink: 0;
    background: #f8f9fa;
}

.community-typing-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 4px;
    vertical-align: middle;
}

.community-typing-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #9ca3af;
    animation: community-typing-bounce 1.4s ease-in-out infinite;
}

.community-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.community-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes community-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Input area */
.community-chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.community-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    background: #f8f9fa;
    color: #111827;
    transition: border-color 0.15s;
}

.community-chat-input:focus {
    border-color: #041E42;
}

.community-chat-input::placeholder {
    color: #9ca3af;
}

.community-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #041E42;
    color: #FFB81C;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.15s;
}

.community-chat-send:hover:not(:disabled) {
    transform: scale(1.08);
}

.community-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.community-chat-send svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   SIDEBAR
   ======================================== */
.community-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.community-sidebar .info-card h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 700;
    color: #041E42;
}

.community-sidebar .info-card a {
    color: #041E42;
    font-weight: 600;
    text-decoration: none;
}

.community-sidebar .info-card a:hover {
    color: #FFB81C;
}

/* Trivia text with fade transition */
.trivia-text {
    font-size: 14px;
    line-height: 1.55;
    color: #374151;
    transition: opacity 0.4s ease;
    min-height: 60px;
}

.trivia-text.fade-out {
    opacity: 0;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 960px) {
    .community-layout {
        grid-template-columns: 1fr;
    }

    .community-chat {
        height: 70vh;
    }

    .community-sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
}

@media (max-width: 640px) {
    .community-sidebar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .page-community .page-content {
        padding-left: 12px;
        padding-right: 12px;
    }

    .community-chat {
        height: calc(100vh - 200px);
        border-radius: 8px;
    }

    .community-chat-header {
        padding: 12px 14px;
    }

    .community-chat-messages {
        padding: 12px 14px;
    }

    .community-chat-input-area {
        padding: 10px 14px;
    }

    .community-msg-avatar {
        width: 34px;
        height: 34px;
    }

    .community-msg-name {
        max-width: 160px;
    }

    .community-msg-text {
        font-size: 14px;
    }
}
