/* =============================================================
   SOCIAL SYSTEM — Friends & Chat Widget
   ============================================================= */

#social-widget {
    position: relative;
    z-index: 100000;
}

/* ── Notification ping animation ─────────────────────────────── */
@keyframes social-ping {
    0%   { transform: scale(1);    box-shadow: 0 4px 20px rgba(255,0,60,0.5), 0 0 0 0   rgba(255,0,60,0.8); }
    40%  { transform: scale(1.18); box-shadow: 0 6px 30px rgba(255,0,60,0.7), 0 0 0 12px rgba(255,0,60,0.0); }
    70%  { transform: scale(0.95); }
    100% { transform: scale(1);    box-shadow: 0 4px 20px rgba(255,0,60,0.5), 0 0 0 0   rgba(255,0,60,0); }
}

.social-toggle-btn.incoming {
    animation: social-ping 0.55s cubic-bezier(0.36,0.07,0.19,0.97);
}

/* ── Floating toggle button ──────────────────────────────────── */
.social-toggle-btn {
    position: fixed;
    bottom: 60px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff003c, #ff6b6b);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100001;
    box-shadow: 0 4px 20px rgba(255, 0, 60, 0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    color: #fff;
    font-size: 1.2rem;
}

.social-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(255, 0, 60, 0.7);
}

.social-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ffd700;
    color: #000;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.65rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    display: none;
}

.social-badge.visible { display: flex; }

/* ── Social Panel ────────────────────────────────────────────── */
.social-panel {
    position: fixed;
    bottom: 115px;
    right: 20px;
    width: 300px;
    max-height: 480px;
    background: #0a0a0a;
    border: 1px solid var(--border-dim);
    border-radius: 8px;
    z-index: 100002;
    display: flex;
    flex-direction: column;
    transform: scale(0.8) translateY(20px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 0, 60, 0.1);
}

.social-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.social-panel-header {
    display: flex;
    border-bottom: 1px solid var(--border-dim);
    flex-shrink: 0;
}

.social-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    position: relative;
}

.social-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(255, 0, 60, 0.04);
}

.social-tab-btn:hover:not(.active) { color: #fff; }

.social-tab-badge {
    position: absolute;
    top: 6px;
    right: 8px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    font-size: 0.55rem;
    font-weight: 900;
    display: none;
    align-items: center;
    justify-content: center;
}
.social-tab-badge.visible { display: flex; }

.social-panel-body {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,0,60,0.3) transparent;
}

/* ── Friend / Request items ──────────────────────────────────── */
.social-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    cursor: pointer;
    transition: background 0.2s;
}

.social-item:hover { background: rgba(255,255,255,0.03); }

.social-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,0,60,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    overflow: hidden;
    flex-shrink: 0;
}

.social-item-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.social-item-info {
    flex: 1;
    min-width: 0;
}

.social-item-name {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.social-item-sub {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.social-item-sub.unread { color: var(--accent); }

.social-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.soc-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: #ccc;
    padding: 4px 8px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s;
}
.soc-btn:hover { border-color: #fff; color: #fff; }
.soc-btn.accept { border-color: rgba(0,255,80,0.4); color: #00ff50; }
.soc-btn.accept:hover { background: rgba(0,255,80,0.1); }
.soc-btn.decline { border-color: rgba(255,0,60,0.4); color: #ff003c; }
.soc-btn.decline:hover { background: rgba(255,0,60,0.1); }

.social-empty {
    text-align: center;
    padding: 30px 20px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 1px;
}

/* ── Chat Window ─────────────────────────────────────────────── */
.chat-window {
    position: fixed;
    bottom: 115px;
    right: 340px;
    width: 300px;
    height: 420px;
    background: #0a0a0a;
    border: 1px solid var(--border-dim);
    border-radius: 8px;
    z-index: 100002;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.9), 0 0 0 1px rgba(255,0,60,0.08);
    transform: scale(0.8) translateY(20px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-dim);
    flex-shrink: 0;
}

.chat-back-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    transition: color 0.2s;
}
.chat-back-btn:hover { color: #fff; }

.chat-peer-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    background: rgba(255,0,60,0.06);
    flex-shrink: 0;
}
.chat-peer-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.chat-peer-name {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: #fff;
    flex: 1;
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1.1rem;
    transition: color 0.2s;
}
.chat-close-btn:hover { color: #fff; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,0,60,0.3) transparent;
}

.chat-msg {
    max-width: 80%;
    padding: 7px 10px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.4;
    word-break: break-word;
}

.chat-msg.mine {
    align-self: flex-end;
    background: rgba(255, 0, 60, 0.15);
    border: 1px solid rgba(255, 0, 60, 0.3);
    color: #fff;
    border-bottom-right-radius: 2px;
}

.chat-msg.theirs {
    align-self: flex-start;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    color: #ccc;
    border-bottom-left-radius: 2px;
}

.chat-msg-time {
    font-size: 0.55rem;
    color: rgba(255,255,255,0.25);
    margin-top: 3px;
    text-align: right;
}

.chat-input-area {
    display: flex;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid var(--border-dim);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-dim);
    color: #fff;
    padding: 8px 10px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus { border-color: rgba(255, 0, 60, 0.5); }

.chat-send-btn {
    background: rgba(255,0,60,0.15);
    border: 1px solid rgba(255,0,60,0.4);
    color: var(--accent);
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.chat-send-btn:hover { background: var(--accent); color: #fff; }

/* ── Add Friend button on leaderboard ───────────────────────── */
.lb-add-btn {
    background: transparent;
    border: 1px solid rgba(255,0,60,0.3);
    color: var(--accent);
    padding: 4px 8px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    cursor: pointer;
    border-radius: 2px;
    white-space: nowrap;
    transition: all 0.2s;
}
.lb-add-btn:hover { background: rgba(255,0,60,0.1); border-color: var(--accent); }
.lb-add-btn.pending { color: #888; border-color: #333; cursor: default; }
.lb-add-btn.friends { color: #00ff80; border-color: rgba(0,255,80,0.3); cursor: default; }
