/* ==========================================================================
   atoms.css — styles for all atom components and widgets
   ========================================================================== */

/* ── Avatar ─────────────────────────────────────────────────────────────── */
.cr-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    text-decoration: none;
    background: var(--bg-secondary, #1a1a2e);
    border: 2px solid var(--border-color, rgba(168,85,247,0.15));
    transition: border-color 0.2s;
}
.cr-avatar:hover { border-color: var(--color-primary, #a855f7); }
.cr-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cr-avatar-xs { width: 24px; height: 24px; }
.cr-avatar-sm { width: 32px; height: 32px; }
.cr-avatar-md { width: 40px; height: 40px; }
.cr-avatar-lg { width: 56px; height: 56px; }
.cr-avatar-xl { width: 80px; height: 80px; }

/* ── Avatar wrap (avatar + online dot container) ────────────────────────── */
.cr-avatar-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

/* ── Online dot ─────────────────────────────────────────────────────────── */
.cr-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-muted, #64748b);
    border: 2px solid var(--bg-primary, #0d0d1a);
    transition: background 0.2s;
}
.cr-online-dot.cr-online { background: #22c55e; }

/* ── User link ───────────────────────────────────────────────────────────── */
.cr-user-link {
    color: var(--text-primary, #e2e8f0);
    text-decoration: none;
    transition: color 0.15s;
}
.cr-user-link:hover { color: var(--color-primary, #a855f7); }
.cr-display-name {
    font-weight: 600;
    font-size: 0.9375rem;
}
.cr-handle {
    font-size: 0.8125rem;
    color: var(--text-tertiary, #64748b);
    display: block;
}
.cr-handle:hover { color: var(--color-primary, #a855f7); }

/* ── Verified badge ─────────────────────────────────────────────────────── */
.cr-verified-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 3px;
    color: #1d9bf0;
    vertical-align: middle;
}
.cr-verified-badge .cr-icon { color: #1d9bf0; }

/* ── Timestamp ──────────────────────────────────────────────────────────── */
.cr-timestamp {
    font-size: 0.8125rem;
    color: var(--text-tertiary, #64748b);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Badge ──────────────────────────────────────────────────────────────── */
.cr-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9999px;
    background: var(--color-primary, #a855f7);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1;
}
.cr-notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
}

/* ── Hashtag / mention links ────────────────────────────────────────────── */
.cr-hashtag,
.cr-mention {
    color: var(--color-primary, #a855f7);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s, text-decoration 0.15s;
}
.cr-hashtag:hover,
.cr-mention:hover { text-decoration: underline; }
.cr-link {
    color: var(--color-primary, #a855f7);
    text-decoration: none;
    word-break: break-all;
}
.cr-link:hover { text-decoration: underline; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.cr-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cr-spinner-ring {
    display: block;
    border-radius: 50%;
    border: 3px solid rgba(168,85,247,0.2);
    border-top-color: var(--color-primary, #a855f7);
    animation: cr-spin 0.8s linear infinite;
}
.cr-spinner-sm .cr-spinner-ring  { width: 16px; height: 16px; border-width: 2px; }
.cr-spinner-md .cr-spinner-ring  { width: 28px; height: 28px; }
.cr-spinner-lg .cr-spinner-ring  { width: 44px; height: 44px; border-width: 4px; }
@keyframes cr-spin { to { transform: rotate(360deg); } }

/* ── Empty state ────────────────────────────────────────────────────────── */
.cr-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-tertiary, #64748b);
    gap: 0.75rem;
}
.cr-empty-icon { font-size: 2.5rem; opacity: 0.5; }
.cr-empty-state p { margin: 0; font-size: 0.9375rem; }

/* ── Action buttons (reaction, comment, bookmark, share) ────────────────── */
.cr-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    border: none;
    background: none;
    color: var(--text-tertiary, #64748b);
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.cr-action-btn:hover { color: var(--text-primary, #e2e8f0); background: var(--bg-hover, rgba(255,255,255,0.05)); }
.cr-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cr-action-btn .cr-count { font-size: 0.8125rem; min-width: 12px; }
.cr-action-btn .cr-action-icon { display: inline-flex; align-items: center; }

/* Reaction button (heart) active state */
.cr-reaction-btn.active { color: #ec4899; }
.cr-reaction-btn:hover  { color: #ec4899; }

/* Bookmark button active state */
.cr-bookmark-btn.active { color: #f59e0b; }
.cr-bookmark-btn:hover  { color: #f59e0b; }

/* Comment button */
.cr-comment-btn:hover { color: #60a5fa; }

/* Share button */
.cr-share-btn:hover { color: #34d399; }

/* Reply button */
.cr-reply-btn {
    font-size: 0.75rem;
    padding: 2px 6px;
    color: var(--text-tertiary, #64748b);
}
.cr-reply-btn:hover { color: var(--color-primary, #a855f7); background: none; }

/* ── Menu button (3-dot) ────────────────────────────────────────────────── */
.cr-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: var(--text-tertiary, #64748b);
    cursor: pointer;
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
    position: relative;
}
.cr-menu-btn:hover { color: var(--text-primary, #e2e8f0); background: var(--bg-hover, rgba(255,255,255,0.06)); }
.cr-menu-sm { width: 26px; height: 26px; }

/* ── Dropdown menu ──────────────────────────────────────────────────────── */
.cr-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1000;
    min-width: 160px;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, rgba(168,85,247,0.2));
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    overflow: hidden;
    animation: cr-dropdown-in 0.12s ease;
}
@keyframes cr-dropdown-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cr-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    color: var(--text-primary, #e2e8f0);
    font-size: 0.875rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}
.cr-dropdown-item:hover { background: rgba(168,85,247,0.08); }
.cr-dropdown-item.cr-danger { color: #ef4444; }
.cr-dropdown-item.cr-danger:hover { background: rgba(239,68,68,0.08); }

/* ── Follow button ──────────────────────────────────────────────────────── */
.cr-follow-btn {
    padding: 6px 16px;
    border: 1.5px solid var(--color-primary, #a855f7);
    background: transparent;
    color: var(--color-primary, #a855f7);
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.cr-follow-btn:hover { background: var(--color-primary, #a855f7); color: #fff; }
.cr-follow-btn.cr-following {
    background: var(--color-primary, #a855f7);
    color: #fff;
}
.cr-follow-btn.cr-following:hover {
    background: #7c3aed;
    border-color: #7c3aed;
}
.cr-follow-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Post card ──────────────────────────────────────────────────────────── */
.cr-post-card {
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, rgba(168,85,247,0.12));
    border-radius: 12px;
    padding: 1rem;
    transition: border-color 0.2s;
    contain: content;
}
.cr-post-card:hover { border-color: rgba(168,85,247,0.25); }

.cr-post-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 0.625rem;
}
.cr-author-block {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.cr-name-line {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.cr-post-body {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary, #e2e8f0);
    margin: 0.5rem 0;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}
.cr-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 0.5rem;
    padding-top: 0.375rem;
    border-top: 1px solid var(--border-color, rgba(168,85,247,0.08));
}

/* ── Inline edit ────────────────────────────────────────────────────────── */
.cr-edit-inline { display: flex; flex-direction: column; gap: 0.5rem; }
.cr-edit-inline-textarea {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-primary, #0d0d1a);
    color: var(--text-primary, #e2e8f0);
    border: 1px solid var(--border-color, rgba(168,85,247,0.25));
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9375rem;
    resize: vertical;
    min-height: 80px;
}
.cr-edit-inline-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.cr-inline-cancel, .cr-inline-submit {
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid;
}
.cr-inline-cancel { background: none; color: var(--text-secondary, #94a3b8); border-color: var(--border-color, rgba(168,85,247,0.2)); }
.cr-inline-submit { background: var(--color-primary, #a855f7); color: #fff; border-color: var(--color-primary, #a855f7); }

/* ── Report form ────────────────────────────────────────────────────────── */
.cr-report-form { display: flex; flex-direction: column; gap: 0.75rem; }
.cr-report-select, .cr-report-desc {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-primary, #0d0d1a);
    color: var(--text-primary, #e2e8f0);
    border: 1px solid var(--border-color, rgba(168,85,247,0.2));
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.875rem;
}

/* ── Media grid ─────────────────────────────────────────────────────────── */
.cr-media-grid {
    display: grid;
    gap: 4px;
    margin: 0.5rem 0;
    border-radius: 10px;
    overflow: hidden;
}
.cr-media-grid-1 { grid-template-columns: 1fr; }
.cr-media-grid-2 { grid-template-columns: 1fr 1fr; }
.cr-media-grid-3 { grid-template-columns: 1fr 1fr; }
.cr-media-grid-3 .cr-media-item:first-child { grid-column: span 2; }
.cr-media-grid-4 { grid-template-columns: 1fr 1fr; }
.cr-media-item { position: relative; overflow: hidden; background: var(--bg-primary, #0d0d1a); }
.cr-media-img {
    width: 100%;
    height: 100%;
    max-height: 300px;
    object-fit: cover;
    display: block;
    cursor: pointer;
    transition: transform 0.2s;
}
.cr-media-img:hover { transform: scale(1.02); }
.cr-media-video { width: 100%; max-height: 300px; object-fit: contain; display: block; background: #000; }

/* ── Inline comment composer slot ───────────────────────────────────────── */
.cr-composer-slot { margin-top: 0.5rem; }
.cr-inline-comment { display: flex; flex-direction: column; gap: 0.375rem; }
.cr-comment-ta {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-primary, #0d0d1a);
    color: var(--text-primary, #e2e8f0);
    border: 1px solid var(--border-color, rgba(168,85,247,0.2));
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
}
.cr-comment-submit-row { display: flex; justify-content: flex-end; }

/* ── Generic buttons ────────────────────────────────────────────────────── */
.cr-btn { padding: 7px 18px; border-radius: 8px; font-size: 0.875rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: background 0.15s, opacity 0.15s; }
.cr-btn-primary { background: var(--color-primary, #a855f7); color: #fff; border-color: var(--color-primary, #a855f7); }
.cr-btn-primary:hover { background: #9333ea; }
.cr-btn-sm { padding: 4px 12px; font-size: 0.8125rem; }

/* ── Comment card ───────────────────────────────────────────────────────── */
.cr-comment-card {
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,0.06));
}
.cr-comment-card.cr-reply { padding-left: 1rem; }
.cr-comment-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 0.375rem;
}
.cr-comment-author { flex: 1; min-width: 0; }
.cr-comment-name-line { display: flex; align-items: center; gap: 3px; }
.cr-comment-display-name { font-weight: 600; font-size: 0.875rem; }
.cr-comment-handle { font-size: 0.75rem; color: var(--text-tertiary, #64748b); display: block; }
.cr-comment-body {
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--text-primary, #e2e8f0);
    margin: 0.25rem 0;
    white-space: pre-wrap;
    word-break: break-word;
}
.cr-comment-actions { display: flex; align-items: center; gap: 4px; margin-top: 0.25rem; }
.cr-replies-container { margin-top: 0.375rem; }
.cr-reply-slot { margin-top: 0.375rem; }

/* ── User card ──────────────────────────────────────────────────────────── */
.cr-user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border-color, rgba(168,85,247,0.1));
    background: var(--bg-secondary, #1a1a2e);
    transition: border-color 0.2s;
}
.cr-user-card:hover { border-color: rgba(168,85,247,0.25); }
.cr-user-card-compact { padding: 0.5rem; gap: 8px; }
.cr-user-info { flex: 1; min-width: 0; }
.cr-user-bio {
    font-size: 0.8125rem;
    color: var(--text-secondary, #94a3b8);
    margin: 0.25rem 0 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.cr-user-stats { display: flex; gap: 1rem; margin-top: 0.375rem; }
.cr-stat { font-size: 0.8125rem; color: var(--text-secondary, #94a3b8); }
.cr-stat-count { color: var(--text-primary, #e2e8f0); font-weight: 700; }

/* ── Conversation item ──────────────────────────────────────────────────── */
.cr-conversation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,0.06));
}
.cr-conversation-item:hover { background: rgba(168,85,247,0.05); }
.cr-conversation-item.cr-active { background: rgba(168,85,247,0.1); }
.cr-conv-content { flex: 1; min-width: 0; }
.cr-conv-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cr-conv-name { font-weight: 600; font-size: 0.9rem; color: var(--text-primary, #e2e8f0); truncate: ellipsis; overflow: hidden; white-space: nowrap; }
.cr-conv-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cr-conv-preview {
    font-size: 0.8125rem;
    color: var(--text-tertiary, #64748b);
    margin: 2px 0 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.cr-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9999px;
    background: var(--color-primary, #a855f7);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
}

/* ── Message bubble ─────────────────────────────────────────────────────── */
.cr-message-bubble {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 0.375rem;
}
.cr-message-bubble.cr-own { flex-direction: row-reverse; }
.cr-bubble {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: 16px;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, rgba(168,85,247,0.12));
    word-break: break-word;
}
.cr-message-bubble.cr-own .cr-bubble {
    background: var(--color-primary, #a855f7);
    color: #fff;
    border-color: transparent;
    border-bottom-right-radius: 4px;
}
.cr-message-bubble.cr-other .cr-bubble { border-bottom-left-radius: 4px; }
.cr-bubble-text { margin: 0; font-size: 0.9rem; line-height: 1.5; }
.cr-bubble-footer { display: flex; align-items: center; gap: 4px; margin-top: 3px; justify-content: flex-end; }
.cr-bubble-footer .cr-timestamp { font-size: 0.7rem; opacity: 0.6; }
.cr-read-receipt { font-size: 0.7rem; opacity: 0.7; }
.cr-bubble-image { max-width: 240px; border-radius: 8px; display: block; }

/* ── Notification item ──────────────────────────────────────────────────── */
.cr-notification-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 0.75rem;
    cursor: pointer;
    border-radius: 8px;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,0.06));
    transition: background 0.15s;
    position: relative;
}
.cr-notification-item:hover { background: rgba(168,85,247,0.05); }
.cr-notification-item.cr-unread { background: rgba(168,85,247,0.04); }
.cr-notif-content { flex: 1; min-width: 0; }
.cr-notif-desc { margin: 0 0 2px; font-size: 0.875rem; line-height: 1.4; color: var(--text-primary, #e2e8f0); }
.cr-notif-actor { font-weight: 600; color: var(--text-primary, #e2e8f0); text-decoration: none; }
.cr-notif-actor:hover { color: var(--color-primary, #a855f7); }
.cr-notif-preview {
    font-size: 0.8125rem;
    color: var(--text-tertiary, #64748b);
    margin: 2px 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.cr-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary, #a855f7);
    flex-shrink: 0;
    margin-top: 4px;
}
