/* =============================================
   COMMUNITY CHAT — Page Layout
   Bubbles/input/reply-bar styling all come from chat.css
   (reused unchanged). This file only adds what's new:
   full-screen layout, header, sender-name labels on peer
   bubbles, the typing row, the image blur effect, the
   message-area shimmer skeleton, and the admin Pending
   Requests list.
   ============================================= */

html,
body {
    height: 100%;
}

.cchat-screen {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 720px;
    margin: 0 auto;
    background: var(--bg-base);
}

/* ---- HEADER ---- */
.cchat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    flex-shrink: 0;
}

.cchat-icon-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-elevated);
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.cchat-icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-1);
}

.cchat-leave-btn:hover {
    color: var(--red);
}

.cchat-header-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--accent), #7a4dff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    text-transform: uppercase;
}

.cchat-header-info {
    flex: 1;
    min-width: 0;
}

.cchat-header-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cchat-header-meta {
    font-size: 12px;
    color: var(--text-2);
    margin-top: 1px;
}

.cchat-display {
    flex: 1;
}

.msg-sender-name {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--accent);
    margin: 0 2px 3px;
    padding: 0 2px;
}

.my-msg .msg-sender-name {
    display: none;
}

.peer-msg {
    flex-direction: column;
    align-items: flex-start;
}

.my-msg {
    flex-direction: column;
    align-items: flex-end;
}

/* ---- MESSAGE-AREA SHIMMER SKELETON — new ----
   Shown by default (see the HTML) until the first real Firestore
   snapshot resolves (community-chat-core.js's renderMessagesList()
   removes it, whether that snapshot has messages or is genuinely
   empty — both count as "resolved," same principle as the
   communities list's row skeleton). Reuses the comm-shimmer keyframe
   already defined in communities.css, which this page also loads —
   no duplicate animation definition needed. Alternating left/right
   bubble shapes at varied widths read as "chat bubbles loading"
   rather than a generic block, closer to what's about to render than
   a plain spinner or text placeholder would be. */
.cchat-msg-skeleton {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.cchat-skel-bubble {
    position: relative;
    overflow: hidden;
    height: 38px;
    max-width: 78%;
    border-radius: 16px;
    background: var(--bg-elevated);
}

.cchat-skel-bubble-left {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.cchat-skel-bubble-right {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.cchat-skel-bubble::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg,
            transparent,
            var(--bg-hover) 45%,
            var(--bg-hover) 55%,
            transparent);
    animation: comm-shimmer 1.6s ease-in-out infinite;
    will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
    .cchat-skel-bubble::after {
        animation: none;
    }
}

/* ---- TYPING ROW ---- */
.cchat-typing-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    flex-shrink: 0;
}

.cchat-typing-row[hidden] {
    display: none;
}

#cchat-typing-text {
    font-size: 12px;
    color: var(--text-2);
    margin-left: 4px;
}

.cchat-typing-row .typing-dot {
    background: var(--text-3);
}

/* ---- IMAGE BLUR (2 minutes after send/receive) ---- */
.cchat-image-blurred {
    filter: blur(18px);
    cursor: default !important;
    transform: scale(1.03);
}

.cchat-image-blurred-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    pointer-events: none;
}

.image-bubble {
    position: relative;
    display: inline-block;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 480px) {
    .cchat-header {
        padding: 10px 12px;
    }

    .cchat-header-name {
        font-size: 14px;
    }
}

/* ---- COMMUNITY INFO DIALOG ---- */
.cinfo-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.cinfo-row:first-of-type {
    padding-top: 4px;
}

.cinfo-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
}

.cinfo-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-1);
    text-align: right;
}

.cinfo-value-mono {
    font-family: 'Courier New', monospace;
    font-size: 11.5px;
    font-weight: 400;
    color: var(--text-2);
    word-break: break-all;
    max-width: 60%;
}

/* ---- PENDING REQUESTS (admin-only) ---- */
.cinfo-requests-section {
    padding-top: 14px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
}

.cinfo-requests-section[hidden] {
    display: none;
}

.cinfo-requests-section .cinfo-label {
    display: block;
    margin-bottom: 10px;
}

.cinfo-requests-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cinfo-requests-empty {
    font-size: 12.5px;
    color: var(--text-3);
    padding: 6px 0;
}

.cinfo-request-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-md);
    border-radius: var(--r-sm);
    padding: 9px 11px;
    transition: opacity 0.15s ease;
}

.cinfo-request-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.cinfo-request-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.cinfo-request-actions .comm-btn {
    padding: 6px 12px;
    font-size: 12px;
}

.cinfo-link-section {
    padding-top: 14px;
}

.cinfo-link-section .cinfo-label {
    display: block;
    margin-bottom: 8px;
}

.cinfo-link-box {
    display: flex;
    gap: 8px;
}

.cinfo-link-box input {
    flex: 1;
    min-width: 0;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--text-2);
    background: var(--bg-elevated);
    border: 1px solid var(--border-md);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cinfo-link-box input:focus {
    outline: none;
}

.cinfo-link-box .comm-btn {
    padding: 10px 16px;
    font-size: 13px;
}

.cinfo-link-hint {
    font-size: 11.5px;
    color: var(--text-3);
    margin-top: 8px;
}

/* =============================================
   LOADING OVERLAY
   ============================================= */
.cchat-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: var(--bg-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.cchat-loading-overlay[hidden] {
    display: none;
}

.cchat-loading-overlay p {
    font-size: 13.5px;
    color: var(--text-2);
}

.cchat-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--border-md);
    border-top-color: var(--accent);
    animation: cchat-spin 0.75s linear infinite;
}

@keyframes cchat-spin {
    to {
        transform: rotate(360deg);
    }
}

/* =============================================
   DANGER BUTTON (leave confirmation)
   ============================================= */
.comm-btn-danger {
    background: var(--red);
    color: #fff;
}

.comm-btn-danger:hover {
    background: #dc2649;
}

/* =============================================
   MEMBER PROFILE POPUP
   ============================================= */
.cmember-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #7a4dff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 24px;
    color: #fff;
    margin: 4px auto 14px;
}

.cmember-name {
    text-align: center;
    font-size: 17px;
    margin-bottom: 20px;
}

.cmember-friend-status {
    text-align: center;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--green);
    margin: -12px 0 16px;
}