/* Friends Panel - Bottom Right */
.friends-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a6fbf 100%);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 2000;
    box-shadow: 0 4px 16px rgba(43, 135, 218, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.friends-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(43, 135, 218, 0.6);
}

.friends-toggle-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Friends Panel */
.friends-panel {
    position: fixed;
    bottom: 86px;
    right: 20px;
    width: 340px;
    max-height: 520px;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.friends-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    visibility: visible;
}

.friends-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255,255,255,0.03);
}

.friends-panel-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.friends-panel-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.friends-panel-close:hover {
    color: var(--text-primary);
}

/* Panel Tabs */
.friends-panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.friends-panel-tab {
    flex: 1;
    padding: 10px 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.friends-panel-tab:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.03);
}

.friends-panel-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.friends-panel-tab .tab-badge {
    background: var(--danger-color);
    color: white;
    border-radius: 8px;
    padding: 1px 6px;
    font-size: 0.7rem;
    margin-left: 4px;
    font-weight: 700;
}

/* Panel Body */
.friends-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    min-height: 200px;
    max-height: 280px;
}

/* Add Friend Section */
.friends-add-section {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

.friends-add-input {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
}

.friends-add-input:focus {
    border-color: var(--primary-color);
}

.friends-add-input::placeholder {
    color: var(--text-secondary);
}

.friends-add-btn {
    padding: 8px 14px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.friends-add-btn:hover {
    background: #2478c5;
}

/* Friend Item */
.friend-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    transition: background 0.15s ease;
}

.friend-item:hover {
    background: rgba(255,255,255,0.05);
}

.friend-item:active {
    background: rgba(255,255,255,0.08);
}

.friend-actions {
    -webkit-tap-highlight-color: transparent;
}

.friend-action-btn:active ~ .friend-item,
.friend-actions:active {
    background: none;
}

.friend-item:last-child {
    border-bottom: none;
}

.friend-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a6fbf 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
    position: relative;
}

.friend-avatar .online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success-color);
    border: 2px solid var(--card-bg);
}

.friend-avatar .offline-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #666;
    border: 2px solid var(--card-bg);
}

.friend-avatar .away-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f59e0b;
    border: 2px solid var(--card-bg);
}

.friend-status.away {
    color: #f59e0b;
}

.friend-info {
    flex: 1;
    margin-left: 10px;
    min-width: 0;
}

.friend-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.friend-status.online {
    color: var(--success-color);
}

.friend-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.friend-action-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.friend-action-btn:hover {
    background: rgba(255,255,255,0.15);
    color: var(--text-primary);
}

.friend-action-btn.danger:hover {
    background: rgba(220, 53, 69, 0.2);
    color: var(--danger-color);
}

.friend-action-btn.accept {
    background: rgba(40, 167, 69, 0.15);
    color: var(--success-color);
}

.friend-action-btn.accept:hover {
    background: rgba(40, 167, 69, 0.3);
}

.friend-unread-badge {
    background: var(--danger-color);
    color: white;
    border-radius: 10px;
    padding: 2px 7px;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-left: 6px;
}

/* Empty state */
.friends-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.friends-empty span {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

/* Chat Window */
.friends-chat {
    position: fixed;
    bottom: 86px;
    right: 370px;
    width: 320px;
    max-height: 420px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    z-index: 2001;
    display: none;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.friends-chat.open {
    display: flex;
}

.friends-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255,255,255,0.03);
}

.friends-chat-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.friends-chat-header-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.friends-chat-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
}

.friends-chat-close:hover {
    color: var(--text-primary);
}

.friends-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 250px;
    max-height: 320px;
}

.chat-bubble {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-bubble.sent {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-bubble.received {
    align-self: flex-start;
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-bubble .chat-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 2px;
    display: block;
}

.friends-chat-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
}

.friends-chat-input {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
}

.friends-chat-input:focus {
    border-color: var(--primary-color);
}

.friends-chat-input::placeholder {
    color: var(--text-secondary);
}

.friends-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.friends-chat-send:hover {
    background: #2478c5;
}

/* Friend context menu */
.friend-context-menu {
    position: fixed;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    min-width: 160px;
    z-index: 3000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: none;
}

.friend-context-menu.show {
    display: block;
}

.ctx-icon {
    display: inline-flex;
    width: 20px;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.friend-context-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.friend-context-item:hover {
    background: rgba(255,255,255,0.08);
}

.friend-context-item.danger {
    color: var(--danger-color);
}

.friend-context-item.danger:hover {
    background: rgba(220, 53, 69, 0.15);
}

.friend-context-item.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* Request item styling */
.request-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.request-item .friend-info {
    flex: 1;
    margin-left: 10px;
}

.request-actions {
    display: flex;
    gap: 4px;
}

/* Toast notification for friends */
.friend-toast {
    position: fixed;
    bottom: 90px;
    left: 20px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 12px 18px;
    color: var(--text-primary);
    z-index: 3000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    animation: friendToastIn 0.3s ease;
    font-size: 0.9rem;
}

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

/* Chat body wrapper for collapse */
.friends-chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Chat header cursor hint */
.friends-chat-header {
    cursor: pointer;
}

.friends-chat-header:hover {
    background: rgba(255,255,255,0.05);
}

/* Mini chat bubble animation */
.chat-mini-bubble {
    animation: bubbleIn 0.2s ease;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a6fbf 100%);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-mini-bubble,
.chat-mini-bubble:hover,
.chat-mini-bubble:active,
.chat-mini-bubble:focus {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    border-radius: 50% !important;
    padding: 0 !important;
}

.chat-mini-bubble:hover {
    transform: translateX(-10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.chat-mini-bubble .mini-bubble-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.chat-mini-bubble .mini-bubble-close {
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: 18px;
    height: 18px;
    background: #dc2626;
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
    z-index: 2;
    border: 2px solid var(--bg-primary, #1a1a2e);
    text-align: center;
}

.chat-mini-bubble:hover .mini-bubble-close {
    display: flex;
}

@keyframes bubbleIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Party Invite Notification */
.party-invite-notification {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 10000;
    animation: slideInLeft 0.3s ease;
}

.party-invite-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 14px 18px 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.2);
    max-width: 360px;
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
}

.party-invite-timer-bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 4px;
}

.party-invite-timer-fill {
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
}

.party-invite-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.party-invite-text {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.party-invite-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.party-invite-accept {
    padding: 6px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.party-invite-accept:hover {
    background: var(--primary-hover);
}

.party-invite-decline {
    padding: 6px 10px;
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary);
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}

.party-invite-decline:hover {
    background: rgba(255,255,255,0.15);
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .friends-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
        z-index: 2000;
    }

    .friends-panel-body {
        max-height: none;
        flex: 1;
    }

    .friends-toggle-btn {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
        bottom: 15px;
        right: 15px;
    }

    .friends-chat {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
        z-index: 2001;
    }

    .friends-chat-messages {
        min-height: 0;
        max-height: none;
        flex: 1;
    }

    .party-invite-content {
        max-width: 90%;
    }

    .party-invite-notification {
        left: 10px;
        right: 10px;
    }

    .friend-toast {
        left: 10px;
        right: 10px;
        bottom: 76px;
    }

    /* Chat mini bubbles */
    .chat-mini-bubble,
    .chat-mini-bubble:hover,
    .chat-mini-bubble:active,
    .chat-mini-bubble:focus {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        max-width: 40px !important;
        max-height: 40px !important;
    }
}

@media (max-width: 480px) {
    .friends-toggle-btn {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
        bottom: 12px;
        right: 12px;
    }

    .friends-panel-tab {
        font-size: 0.75rem;
        padding: 8px 6px;
    }

    .friend-item {
        padding: 8px 10px;
    }

    .friend-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
}
