/**
 * Friend-related styles.
 * Friend code modal, friend chat UI, and related components.
 */

/* ============================================================================
   FRIEND CODE MODAL
   ============================================================================ */

.friend-code-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0a0a0e 0%, #1a1a2e 50%, #0a0a0e 100%);
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.friend-code-overlay.open {
    opacity: 1;
    visibility: visible;
}

.friend-code-content {
    text-align: center;
    padding: 40px;
    max-width: 400px;
}

.friend-code-logo {
    font-size: 48px;
    font-weight: 700;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2ff7 50%, #f107a3 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 40px;
    letter-spacing: 2px;
}

.friend-code-qr {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 32px;
    display: inline-block;
}

.friend-code-qr img {
    display: block;
}

.qr-fallback {
    font-size: 32px;
    font-weight: 600;
    color: white;
    padding: 60px 40px;
}

.friend-code-display {
    font-size: 28px;
    font-weight: 600;
    color: white;
    letter-spacing: 4px;
    margin-bottom: 32px;
    font-family: 'Monaco', 'Consolas', monospace;
}

.friend-code-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.friend-code-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.friend-code-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* ============================================================================
   FRIEND PASS - PREMIUM DESIGN
   ============================================================================ */

/* Background orbs for ambiance */
.friend-pass-orbs {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.friend-pass-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
}

.friend-pass-orb.orb-1 {
    width: 300px;
    height: 300px;
    background: #00d4ff;
    top: -100px;
    right: -50px;
    animation: floatOrb1 20s ease-in-out infinite;
}

.friend-pass-orb.orb-2 {
    width: 250px;
    height: 250px;
    background: #f107a3;
    bottom: -80px;
    left: -50px;
    animation: floatOrb2 25s ease-in-out infinite;
}

.friend-pass-orb.orb-3 {
    width: 200px;
    height: 200px;
    background: #7b2ff7;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    animation: floatOrb3 18s ease-in-out infinite;
}

@keyframes floatOrb1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-30px, 40px) scale(1.1); }
    66% { transform: translate(20px, -30px) scale(0.95); }
}

@keyframes floatOrb2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(40px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 40px) scale(1.1); }
}

@keyframes floatOrb3 {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.3; }
    50% { transform: translateX(-50%) scale(1.2); opacity: 0.4; }
}

/* Profile photo with pulsing glow */
.friend-pass-photo {
    position: relative;
    width: 88px;
    height: 88px;
    margin: 0 auto 16px;
}

.friend-pass-photo-glow {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #f107a3);
    opacity: 0.6;
    filter: blur(12px);
    animation: photoGlow 3s ease-in-out infinite;
}

@keyframes photoGlow {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.08);
    }
}

.friend-pass-photo img {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.9);
    z-index: 1;
}

.friend-pass-photo-fallback {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a1a2e, #2a2a4e);
    border: 3px solid rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.friend-pass-photo-fallback svg {
    width: 44px;
    height: 44px;
    color: rgba(255, 255, 255, 0.7);
}

/* User name */
.friend-pass-name {
    font-size: 18px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 28px;
    letter-spacing: 0.5px;
}

/* Premium pass card with animated gradient border */
.friend-pass-card {
    position: relative;
    padding: 3px;
    border-radius: 24px;
    background: linear-gradient(135deg, #00d4ff, #7b2ff7, #f107a3, #ffaa00, #00d4ff);
    background-size: 300% 300%;
    animation: borderRotate 8s linear infinite;
    margin-bottom: 28px;
    display: inline-block;
}

@keyframes borderRotate {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.friend-pass-card-inner {
    background: linear-gradient(135deg, #0d0d12 0%, #1a1a2e 50%, #0d0d12 100%);
    border-radius: 21px;
    padding: 28px 32px 24px;
}

/* QR code styling inside card */
.friend-pass-card .friend-code-qr {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow:
        0 0 20px rgba(0, 212, 255, 0.1),
        inset 0 0 20px rgba(255, 255, 255, 0.02);
}

/* Friend code display inside card */
.friend-pass-card .friend-code-display {
    font-size: 22px;
    margin-bottom: 0;
    letter-spacing: 3px;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

/* Action buttons */
.friend-pass-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
}

.friend-pass-btn {
    flex: 1;
    max-width: 140px;
    padding: 14px 20px;
    border-radius: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.friend-pass-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.2);
}

/* Copy button success state */
.friend-pass-btn.copied {
    background: rgba(0, 210, 106, 0.2) !important;
    border-color: rgba(0, 210, 106, 0.4) !important;
    color: #00d26a !important;
}

.friend-pass-btn.copied svg {
    stroke: #00d26a;
}

/* Secondary link */
.friend-pass-add-link {
    color: rgba(255, 255, 255, 0.6);
    font-size: 15px;
    margin-bottom: 16px;
    transition: color 0.2s ease;
}

.friend-pass-add-link:hover {
    color: #00d4ff;
}

/* Regenerate link */
.friend-pass-regen {
    opacity: 0.4;
    font-size: 13px;
    transition: opacity 0.2s ease;
}

.friend-pass-regen:hover {
    opacity: 0.7;
}

/* Card entrance animation */
.friend-code-overlay.open .friend-pass-card {
    animation: cardEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cardEnter {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Photo entrance animation */
.friend-code-overlay.open .friend-pass-photo {
    animation: photoEnter 0.3s ease-out forwards;
}

@keyframes photoEnter {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .friend-pass-orb,
    .friend-pass-photo-glow,
    .friend-pass-card,
    .friend-code-overlay.open .friend-pass-card,
    .friend-code-overlay.open .friend-pass-photo {
        animation: none;
    }
    .friend-pass-card {
        background: linear-gradient(135deg, #00d4ff, #f107a3);
        background-size: 100% 100%;
    }
    .friend-pass-photo-glow {
        opacity: 0.5;
    }
}

/* ============================================================================
   ADD FRIEND MODAL
   ============================================================================ */

/* Divider */
.add-friend-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
}

.add-friend-divider::before,
.add-friend-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* My Friend Code Display (inline in Add Friend modal) */
.my-friend-code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.my-friend-code-text {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 2px;
    color: #00d4ff;
}

.copy-code-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-code-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.add-friend-input-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.add-friend-input-group input {
    flex: 1;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.add-friend-input-group input::placeholder {
    text-transform: none;
    letter-spacing: normal;
}

/* ============================================================================
   FRIEND CHAT HEADER
   ============================================================================ */

.friend-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.friend-chat-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

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

.friend-chat-avatar .avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2ff7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    color: white;
}

.friend-chat-avatar .online-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #888;
    border: 2px solid #1a1a1e;
}

.friend-chat-avatar .online-status.online {
    background: #00d26a;
}

.friend-chat-info {
    flex: 1;
    min-width: 0;
}

/* Friend chat header actions */
.friend-chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.friend-chat-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.friend-chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.friend-chat-action-btn:active {
    transform: scale(0.95);
}

.friend-chat-name {
    font-weight: 600;
    color: white;
    font-size: 16px;
}

.friend-chat-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.friend-chat-menu-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.friend-chat-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.menu-dots {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
}

/* ============================================================================
   FRIEND CHAT MESSAGES
   ============================================================================ */

/* Friend chat now uses persona chat classes (.message, .message-user, .message-ai)
   for consistent styling. These friend-specific tweaks extend the base styles. */

.ai-avatar.friend-avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

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

.ai-avatar.friend-avatar .avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2ff7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.ai-avatar.friend-avatar .avatar-placeholder.persona {
    background: linear-gradient(135deg, #f107a3 0%, #7b2ff7 100%);
}

/* Legacy friend-message styles (kept for backwards compatibility) */
.friend-message {
    display: flex;
    gap: 10px;
    padding: 8px 16px;
    max-width: 85%;
}

.friend-message.mine {
    flex-direction: row-reverse;
    margin-left: auto;
}

.friend-message.theirs {
    margin-right: auto;
}

.friend-message.persona {
    margin-right: auto;
}

.friend-message .message-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
}

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

.friend-message .message-avatar .avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2ff7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.friend-message .message-avatar .avatar-placeholder.persona {
    background: linear-gradient(135deg, #f107a3 0%, #7b2ff7 100%);
}

.friend-message .message-bubble {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px 18px 18px 18px;
    padding: 12px 16px;
    max-width: 100%;
    transition: all 0.2s ease;
}

.friend-message .message-bubble:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.friend-message.mine .message-bubble {
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    border: none;
    border-radius: 18px 18px 4px 18px;
}

.friend-message.mine .message-bubble:hover {
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.2);
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
}

.friend-message .message-bubble.persona {
    background: rgba(247, 7, 163, 0.15);
    border: 1px solid rgba(247, 7, 163, 0.3);
    border-radius: 4px 18px 18px 18px;
}

.friend-message .message-sender {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 4px;
}

.friend-message .message-sender .ai-badge {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(247, 7, 163, 0.3);
    border-radius: 4px;
    font-size: 10px;
    margin-left: 6px;
}

.friend-message .message-content {
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    line-height: 1.7;
    word-wrap: break-word;
}

.friend-message.mine .message-content {
    color: white;
}

.friend-message .message-content a {
    color: inherit;
    text-decoration: underline;
}

.friend-message .message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.friend-message .message-images img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.friend-message .message-images img:hover {
    transform: scale(1.02);
}

.friend-message .message-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 4px;
    text-align: right;
}

.friend-message.mine .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Friend Chat Bubble Constraints (iMessage-style max width) */
.friend-bubble-container {
    flex: unset !important;  /* Override .ai-content flex: 1 */
    max-width: 80%;
}

.friend-bubble {
    width: fit-content;
    max-width: 100%;  /* Inherit max-width from container */
}

/* ============================================================================
   TYPING INDICATOR
   ============================================================================ */

.typing-indicator {
    display: flex;
    gap: 10px;
    padding: 8px 16px;
    align-items: flex-end;
}

.typing-avatar {
    width: 32px;
    height: 32px;
}

.typing-avatar .avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2ff7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.typing-bubble {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 12px 16px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    animation: typingDot 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Persona typing indicator (for @mention responses) */
.typing-indicator.persona .typing-avatar .avatar-placeholder {
    background: linear-gradient(135deg, #f107a3 0%, #7b2ff7 100%);
}

.typing-indicator.persona .typing-bubble {
    background: rgba(247, 7, 163, 0.15);
    border: 1px solid rgba(247, 7, 163, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-indicator.persona .typing-name {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

/* ============================================================================
   FRIEND CHAT MENU
   ============================================================================ */

.friend-chat-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a1e;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 400;
}

.friend-chat-menu.open {
    transform: translateY(0);
}

.friend-chat-menu-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.friend-chat-menu-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.friend-chat-menu-option.danger {
    color: #ff4757;
}

.friend-chat-menu-option.danger:hover {
    background: rgba(255, 71, 87, 0.1);
}

.friend-chat-menu-cancel {
    margin-top: 12px;
    padding: 16px;
    text-align: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.friend-chat-menu-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* ============================================================================
   BLOCKED USERS
   ============================================================================ */

.blocked-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 8px;
}

.blocked-user-avatar {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

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

.blocked-user-avatar .avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
}

.blocked-user-info {
    flex: 1;
    min-width: 0;
}

.blocked-user-name {
    font-weight: 500;
    color: white;
}

.blocked-user-username {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

/* ============================================================================
   FRIEND SIDEBAR ITEMS
   ============================================================================ */

.friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 12px;
    margin: 4px 8px;
}

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

.friend-item.active {
    background: rgba(0, 212, 255, 0.1);
}

.friend-item-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

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

.friend-item-avatar .avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2ff7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    color: white;
}

.friend-item-avatar .online-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #888;
    border: 3px solid #1a1a1e;
}

.friend-item-avatar .online-status.online {
    background: #00d26a;
}

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

.friend-item-name {
    font-weight: 500;
    color: white;
    margin-bottom: 2px;
}

.friend-item-preview {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-item-badge {
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* ============================================================================
   EMPTY CHAT STATE
   ============================================================================ */

.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    padding: 20px;
}

/* ============================================================================
   FRIEND CODE BUTTON (Me card)
   ============================================================================ */

.friend-code-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.3);
    color: #00d4ff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: auto;
}

.friend-code-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.5);
    transform: scale(1.05);
}

.friend-code-btn svg {
    width: 18px;
    height: 18px;
}

/* ============================================================================
   REAL FRIEND THREAD ITEMS (sidebar)
   ============================================================================ */

.thread-item.real-friend-item .thread-avatar {
    position: relative;
}

.thread-item.real-friend-item .avatar-initial {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2ff7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    color: white;
}

.thread-item .online-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #555;
    border: 2px solid rgba(6, 6, 10, 0.98);
    transition: background 0.2s ease;
}

.thread-item .online-indicator.online {
    background: #00d26a;
    box-shadow: 0 0 8px rgba(0, 210, 106, 0.5);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

/* ============================================================================
   FRIEND CHAT MESSAGE FOOTER & LISTEN BUTTON
   ============================================================================ */

.friend-message .message-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    gap: 8px;
}

.friend-message .message-footer .message-time {
    margin-top: 0;
}

/* Friend chat listen button (works with new .message class structure) */
.friend-message-listen-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
}

/* Show listen button on hover - supports both old .friend-message and new .message classes */
.friend-message:hover .friend-message-listen-btn,
.message:hover .friend-message-listen-btn {
    opacity: 1;
}

.friend-message-listen-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.friend-message.mine .friend-message-listen-btn {
    background: rgba(255, 255, 255, 0.2);
}

.friend-message.mine .friend-message-listen-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Loading state */
.friend-message-listen-btn.loading {
    opacity: 1;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Playing state */
.friend-message-listen-btn.playing {
    opacity: 1;
    background: rgba(0, 212, 255, 0.3);
    color: #00d4ff;
}

.friend-message.mine .friend-message-listen-btn.playing {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

/* ============================================================================
   READ RECEIPTS / MESSAGE STATUS
   ============================================================================ */

.message-status {
    display: inline-flex;
    align-items: center;
    height: 16px;
}

.message-status .status-check {
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.2s ease;
}

.message-status .status-check.double {
    margin-left: -4px;
}

/* Sent status - single gray checkmark */
.message-status .status-sent {
    display: inline-flex;
    align-items: center;
}

.message-status .status-sent .status-check {
    color: rgba(255, 255, 255, 0.4);
}

/* Delivered status - double gray checkmarks */
.message-status .status-delivered {
    display: inline-flex;
    align-items: center;
}

.message-status .status-delivered .status-check {
    color: rgba(255, 255, 255, 0.5);
}

/* Read status - double blue checkmarks */
.message-status .status-read {
    display: inline-flex;
    align-items: center;
}

.message-status .status-read .status-check {
    color: #00d4ff;
}

/* Animation for status changes */
@keyframes statusPop {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.message-status .status-read,
.message-status .status-delivered {
    animation: statusPop 0.3s ease-out;
}

/* ============================================================================
   MESSAGE REACTIONS
   ============================================================================ */

/* Reaction picker - floating pill above message */
.reaction-picker {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(30, 30, 40, 0.95);
    border-radius: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
    animation: reactionPickerIn 0.2s ease-out;
}

@keyframes reactionPickerIn {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.8) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1) translateY(0);
    }
}

.reaction-picker-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s ease;
}

.reaction-picker-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.2);
}

.reaction-picker-btn:active {
    transform: scale(0.95);
}

/* Reaction badges on messages */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.reaction-badge:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.reaction-badge.mine {
    background: rgba(0, 212, 255, 0.15);
    border-color: rgba(0, 212, 255, 0.3);
}

.reaction-emoji {
    font-size: 16px;
}

.reaction-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.reaction-badge.mine .reaction-count {
    color: #00d4ff;
}

/* Animation for new reactions */
@keyframes reactionPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.reaction-badge {
    animation: reactionPop 0.3s ease-out;
}

/* Reply button in picker */
.reaction-picker-btn.reply-btn {
    color: rgba(255, 255, 255, 0.6);
}

.reaction-picker-btn.reply-btn:hover {
    color: #00d4ff;
}

/* ============================================================================
   REPLY THREADING
   ============================================================================ */

/* Reply context on messages */
.reply-context {
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    max-width: 250px;
}

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

.reply-context-bar {
    width: 3px;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2ff7 100%);
    border-radius: 2px;
    flex-shrink: 0;
}

.reply-context-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.reply-context-name {
    font-size: 11px;
    font-weight: 600;
    color: #00d4ff;
}

.reply-context-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Reply preview bar above input */
.reply-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(0, 212, 255, 0.1);
    border-top: 1px solid rgba(0, 212, 255, 0.2);
    animation: replyPreviewIn 0.2s ease-out;
}

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

.reply-preview-bar {
    width: 3px;
    height: 36px;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2ff7 100%);
    border-radius: 2px;
    flex-shrink: 0;
}

.reply-preview-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow: hidden;
}

.reply-preview-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.reply-preview-label strong {
    color: #00d4ff;
}

.reply-preview-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.reply-preview-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Message highlight when scrolled to */
.message.highlight {
    animation: messageHighlight 2s ease-out;
}

@keyframes messageHighlight {
    0%, 30% {
        background: rgba(0, 212, 255, 0.15);
        border-radius: 12px;
    }
    100% {
        background: transparent;
    }
}

/* ============================================================================
   MESSAGE SEARCH
   ============================================================================ */

/* Search overlay */
.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 14, 0.98);
    z-index: 500;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.search-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Search header */
.search-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.search-input-wrapper:focus-within {
    border-color: rgba(0, 212, 255, 0.4);
    background: rgba(255, 255, 255, 0.1);
}

.search-icon {
    color: rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
}

.search-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 16px;
}

.search-input-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.search-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.search-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Search results area */
.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.search-empty,
.search-error,
.search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 200px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    text-align: center;
}

.search-error {
    color: #ff6b6b;
}

/* Search spinner */
.search-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #00d4ff;
    border-radius: 50%;
    animation: searchSpin 0.8s linear infinite;
}

@keyframes searchSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Individual search result */
.search-result {
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.search-result:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

.search-result:active {
    transform: translateX(2px);
}

.search-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.search-result-sender {
    font-weight: 600;
    font-size: 13px;
    color: #00d4ff;
}

.search-result-time {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}

.search-result-content {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Search highlight */
.search-highlight {
    background: rgba(0, 212, 255, 0.3);
    color: white;
    padding: 1px 3px;
    border-radius: 3px;
}

/* ============================================================================
   LINK PREVIEWS
   ============================================================================ */

.link-previews {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    max-width: 320px;
}

.link-preview-card {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
}

.link-preview-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.link-preview-image {
    width: 100%;
    max-height: 160px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
}

.link-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.link-preview-content {
    padding: 12px;
}

.link-preview-domain {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 6px;
}

.link-preview-favicon {
    width: 14px;
    height: 14px;
    border-radius: 2px;
}

.link-preview-title {
    font-size: 14px;
    font-weight: 600;
    color: white;
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.link-preview-description {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Adjust link previews inside sent messages */
.message-user + .link-previews .link-preview-card {
    background: rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.15);
}

.message-user + .link-previews .link-preview-card:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* ============================================================================
   MESSAGE EDITING
   ============================================================================ */

/* Edit button in reaction picker */
.reaction-picker-btn.edit-btn {
    color: rgba(255, 255, 255, 0.6);
}

.reaction-picker-btn.edit-btn:hover {
    color: #00d4ff;
}

/* Edited indicator on messages */
.message-edited {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    cursor: pointer;
    transition: color 0.15s ease;
}

.message-edited:hover {
    color: rgba(255, 255, 255, 0.6);
}

/* Edit mode container */
.message-edit-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    min-width: 200px;
}

.message-edit-input {
    width: 100%;
    min-height: 60px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    font-family: inherit;
}

.message-edit-input:focus {
    outline: none;
    border-color: rgba(0, 212, 255, 0.5);
}

.message-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.message-edit-cancel,
.message-edit-save {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.message-edit-cancel {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
}

.message-edit-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.message-edit-save {
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    border: none;
    color: white;
}

.message-edit-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .friend-code-content {
        padding: 20px;
    }

    .friend-code-logo {
        font-size: 36px;
        margin-bottom: 30px;
    }

    .friend-code-display {
        font-size: 22px;
        letter-spacing: 3px;
    }

    .friend-code-qr {
        padding: 16px;
    }

    .friend-message {
        max-width: 90%;
    }

    /* Always show listen button on mobile */
    .friend-message-listen-btn {
        opacity: 1;
    }

    /* Add Friend input group - stack vertically on mobile */
    .add-friend-input-group {
        flex-direction: column;
    }

    .add-friend-input-group input {
        width: 100%;
    }

    .add-friend-input-group .btn {
        width: 100%;
    }
}


/* ============================================================================
   CREATE MODE CONSENT FLOW
   ============================================================================ */

/* Consent Waiting Container (shown in chat area when waiting for friend approval) */
.consent-waiting-container {
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    animation: fadeIn 0.3s ease-out;
}

.consent-waiting-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    text-align: center;
}

.consent-waiting-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: #00d4ff;
    animation: pulse 2s ease-in-out infinite;
}

.consent-waiting-icon svg {
    width: 100%;
    height: 100%;
}

.consent-waiting-title {
    font-size: 18px;
    font-weight: 600;
    color: white;
    margin-bottom: 20px;
}

.consent-waiting-friends {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.consent-friend-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.consent-friend-status .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.consent-friend-status .status-dot.pending {
    background: #ffa500;
    animation: pulse 1.5s ease-in-out infinite;
}

.consent-friend-status .status-dot.approved {
    background: #00d4ff;
}

.consent-friend-status .status-dot.denied {
    background: #ff4444;
}

.consent-friend-status .friend-name {
    flex: 1;
    text-align: left;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.consent-friend-status .status-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.consent-friend-status .status-text.approved {
    color: #00d4ff;
}

.consent-friend-status .status-text.denied {
    color: #ff4444;
}

.consent-waiting-hint {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.5;
    margin-bottom: 20px;
}

.consent-cancel-btn {
    padding: 10px 24px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.consent-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

/* Mention autocomplete - Friend item styling */
.mention-item.friend-item {
    border-left: 2px solid #00d4ff;
}

.mention-avatar.friend-user-type {
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
}

.consent-badge {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(0, 212, 255, 0.2);
    border-radius: 4px;
    font-size: 10px;
    color: #00d4ff;
    margin-left: 6px;
    font-weight: 500;
}

.me-badge {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(247, 7, 163, 0.2);
    border-radius: 4px;
    font-size: 10px;
    color: #f707a3;
    margin-left: 6px;
    font-weight: 500;
}

/* Me mention avatar styling */
.mention-avatar.me-user-type {
    background: linear-gradient(135deg, #f707a3 0%, #c7058a 100%);
}

.mention-item.me-item {
    border-left: 2px solid #f707a3;
}

/* Consent modal expiration info */
.consent-modal-expiration {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
}

.consent-modal.create-mode {
    border-color: rgba(0, 212, 255, 0.3);
}

/* Animation for fade out */
@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}
