/**
 * ✨ Revolutionary Floating Chat System CSS v2.0 ✨
 * Ultra-modern design with exceptional UI/UX and creative positioning
 */

/* CSS Custom Properties for Dynamic Theming */
:root {
    /* Elegant Color Palette */
    --chat-primary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --chat-secondary: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --chat-accent: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --chat-success: linear-gradient(135deg, #10b981 0%, #047857 100%);
    --chat-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --chat-error: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --chat-purple: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --chat-blue: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --chat-green: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --chat-orange: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    --chat-pink: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
    
    /* Subtle Glass Effects */
    --glass-white: rgba(255, 255, 255, 0.9);
    --glass-dark: rgba(15, 23, 42, 0.9);
    --glass-blur: blur(12px);
    --glass-border: rgba(255, 255, 255, 0.15);
    
    /* Neumorphism Shadows */
    --neuro-light: #ffffff;
    --neuro-dark: #e6e6e6;
    --neuro-shadow-light: 20px 20px 60px #d9d9d9, -20px -20px 60px #ffffff;
    --neuro-shadow-inset: inset 20px 20px 60px #d9d9d9, inset -20px -20px 60px #ffffff;
    
    /* Advanced Spacing System */
    --space-3xs: 0.125rem;   /* 2px */
    --space-2xs: 0.25rem;    /* 4px */
    --space-xs: 0.5rem;      /* 8px */
    --space-sm: 0.75rem;     /* 12px */
    --space-md: 1rem;        /* 16px */
    --space-lg: 1.5rem;      /* 24px */
    --space-xl: 2rem;        /* 32px */
    --space-2xl: 3rem;       /* 48px */
    --space-3xl: 4rem;       /* 64px */
    
    /* Dynamic Border Radius */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-2xl: 32px;
    --radius-3xl: 48px;
    --radius-full: 9999px;
    
    /* Elevation System */
    --elevation-1: 0 2px 8px rgba(0, 0, 0, 0.1);
    --elevation-2: 0 4px 16px rgba(0, 0, 0, 0.12);
    --elevation-3: 0 8px 24px rgba(0, 0, 0, 0.15);
    --elevation-4: 0 16px 32px rgba(0, 0, 0, 0.18);
    --elevation-5: 0 24px 48px rgba(0, 0, 0, 0.20);
    --elevation-colored-1: 0 8px 32px rgba(102, 126, 234, 0.25);
    --elevation-colored-2: 0 16px 48px rgba(102, 126, 234, 0.35);
    
    /* Z-Index Scale */
    --z-base: 0;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 400;
    --z-modal: 500;
    --z-popover: 600;
    --z-tooltip: 700;
    --z-toast: 800;
    --z-floating-btn: 900;
    --z-chat-panel: 850;
    --z-chat-box-base: 800;
    
    /* Animation Easing */
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-snappy: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* 🎯 Revolutionary Floating Chat Button */
.floating-chat-btn {
    /* Base Positioning */
    position: fixed !important;
    bottom: var(--space-xl) !important;
    right: var(--space-xl) !important;
    left: auto !important;
    top: auto !important;
    
    /* Dynamic Sizing */
    width: clamp(60px, 8vw, 80px);
    height: clamp(60px, 8vw, 80px);
    
    /* Modern Glassmorphism Design */
    background: var(--chat-primary);
    backdrop-filter: var(--glass-blur);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-full);
    
    /* Enhanced Shadows */
    box-shadow: 
        var(--elevation-colored-2),
        0 0 0 0 rgba(102, 126, 234, 0.4);
    
    /* Layout & Typography */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 600;
    
    /* Interactive States */
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    
    /* Advanced Transitions */
    transition: all 0.4s var(--ease-spring);
    transform-origin: center center;
    
    /* Accessibility */
    outline: none;
    z-index: var(--z-floating-btn) !important;
}

/* Enhanced Hover Effects */
.floating-chat-btn:hover {
    transform: scale(1.15) rotate(8deg) !important;
    box-shadow: 
        var(--elevation-5),
        0 0 40px rgba(102, 126, 234, 0.6),
        0 0 0 8px rgba(102, 126, 234, 0.1);
    background: var(--chat-secondary);
}

/* Active State */
.floating-chat-btn:active {
    transform: scale(0.9) rotate(-5deg) !important;
    transition-duration: 0.1s;
}

/* Panel Open State */
.floating-chat-btn.panel-open {
    background: var(--chat-error);
    transform: rotate(45deg) scale(1.1) !important;
}

/* Notification Animation */
.floating-chat-btn.has-messages {
    animation: message-pulse 2s ease-in-out infinite;
}

@keyframes message-pulse {
    0%, 100% { 
        transform: scale(1) rotate(0deg);
        box-shadow: var(--elevation-colored-1);
    }
    25% { 
        transform: scale(1.05) rotate(2deg);
        box-shadow: var(--elevation-colored-2);
    }
    50% { 
        transform: scale(1.1) rotate(-1deg);
        box-shadow: var(--elevation-5), 0 0 30px rgba(102, 126, 234, 0.5);
    }
    75% { 
        transform: scale(1.05) rotate(1deg);
        box-shadow: var(--elevation-colored-2);
    }
}

/* 🔴 Modern Notification Badge */
.chat-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    
    /* Dynamic Sizing */
    min-width: clamp(24px, 3vw, 32px);
    height: clamp(24px, 3vw, 32px);
    
    /* Modern Design */
    background: var(--chat-error);
    border: 3px solid white;
    border-radius: var(--radius-full);
    
    /* Typography */
    color: white;
    font-size: clamp(10px, 1.5vw, 14px);
    font-weight: 800;
    
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Effects */
    box-shadow: var(--elevation-3);
    backdrop-filter: var(--glass-blur);
    
    /* Animation */
    animation: badge-bounce 1.8s ease-in-out infinite;
}

@keyframes badge-bounce {
    0%, 20%, 50%, 80%, 100% { 
        transform: translateY(0) scale(1); 
    }
    10% { 
        transform: translateY(-3px) scale(1.15); 
    }
    30% { 
        transform: translateY(-6px) scale(1.25); 
    }
    40% { 
        transform: translateY(-3px) scale(1.15); 
    }
    60% { 
        transform: translateY(-3px) scale(1.1); 
    }
}

/* 📱 Revolutionary Chat Panel */
.floating-chat-panel {
    position: fixed;
    bottom: calc(clamp(60px, 8vw, 80px) + var(--space-xl) + var(--space-md));
    right: var(--space-xl);
    
    /* Responsive Sizing */
    width: min(380px, calc(100vw - 2 * var(--space-xl)));
    max-height: min(500px, calc(100vh - 200px));
    
    /* Clean Modern Design */
    background: var(--glass-white);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    
    /* Subtle Shadow */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    
    /* State Management */
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    
    /* Fast Transitions */
    transition: all 0.15s ease;
    
    /* Lower z-index to never block chat boxes */
    z-index: 750;
    overflow: hidden;
}

.floating-chat-panel.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* 🎨 Modern Panel Header */
.floating-chat-header {
    background: var(--chat-primary);
    padding: var(--space-lg) var(--space-xl);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    position: relative;
    overflow: hidden;
}

.floating-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 100%);
    pointer-events: none;
}

.floating-chat-header h3 {
    margin: 0;
    color: white;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    position: relative;
    z-index: 1;
}

.panel-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

.panel-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* 📋 Friends List Redesign */
.floating-friends-list {
    max-height: calc(650px - 120px);
    overflow-y: auto;
    padding: var(--space-md);
    
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 126, 234, 0.3) transparent;
}

.floating-friends-list::-webkit-scrollbar {
    width: 6px;
}

.floating-friends-list::-webkit-scrollbar-track {
    background: transparent;
}

.floating-friends-list::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: var(--radius-full);
}

.floating-friends-list::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* 👤 Enhanced Friend Items */
.floating-friend-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s var(--ease-smooth);
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.floating-friend-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.5s ease;
}

.floating-friend-item:hover::before {
    left: 100%;
}

.floating-friend-item:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--elevation-3);
    background: rgba(255, 255, 255, 0.8);
}

.floating-friend-item:last-child {
    margin-bottom: 0;
}

.floating-friend-item.has-unread {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-color: rgba(102, 126, 234, 0.3);
}

/* 🎭 Dynamic Friend Avatar */
.floating-friend-avatar {
    position: relative;
    flex-shrink: 0;
}

.floating-friend-avatar .user-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--chat-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    position: relative;
    transition: all 0.3s var(--ease-spring);
    border: 3px solid white;
    box-shadow: var(--elevation-2);
}

.floating-friend-item:hover .user-avatar {
    transform: scale(1.1) rotate(5deg);
    box-shadow: var(--elevation-4);
}

/* 🟢 Status Indicator */
.floating-friend-avatar .status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: var(--radius-full);
    border: 2px solid white;
    box-shadow: var(--elevation-1);
}

.floating-friend-avatar .status-dot.online {
    background: var(--chat-success);
    animation: status-pulse 2s ease-in-out infinite;
}

.floating-friend-avatar .status-dot.offline {
    background: #94a3b8;
}

@keyframes status-pulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* 📝 Friend Information */
.floating-friend-info {
    flex: 1;
    min-width: 0;
}

.floating-friend-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: var(--space-2xs);
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.floating-friend-last-message {
    font-size: 14px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.8;
}

.floating-friend-last-message.own {
    color: #667eea;
}

.floating-friend-last-message.own::before {
    content: 'You: ';
    font-weight: 600;
}

/* 🔢 Unread Badge */
.floating-friend-unread {
    background: var(--chat-error);
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
    box-shadow: var(--elevation-2);
    animation: unread-glow 2s ease-in-out infinite;
}

@keyframes unread-glow {
    0%, 100% { 
        transform: scale(1);
        box-shadow: var(--elevation-2);
    }
    50% { 
        transform: scale(1.1);
        box-shadow: var(--elevation-3), 0 0 20px rgba(239, 68, 68, 0.5);
    }
}

/* 🚫 Empty State */
.floating-friends-empty {
    text-align: center;
    padding: var(--space-2xl);
    color: #6b7280;
}

.floating-friends-empty .empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.floating-friends-empty p {
    margin: 0;
    font-size: 16px;
}

/* ➕ Add Friends Button */
.add-friends-btn {
    width: 100%;
    background: var(--chat-primary);
    color: white;
    border: none;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s var(--ease-smooth);
    margin-top: var(--space-md);
    font-size: 16px;
    position: relative;
    overflow: hidden;
}

.add-friends-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    transform: translate(-50%, -50%);
    transition: all 0.4s var(--ease-spring);
}

.add-friends-btn:hover::before {
    width: 300px;
    height: 300px;
}

.add-friends-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--elevation-4);
}

/* 💬 Revolutionary Chat Boxes */
.popup-chat-box {
    position: fixed !important;
    width: 360px;
    height: 540px;
    
    /* Clean Modern Design */
    background: var(--glass-white);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    
    /* Clean Shadow */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    
    /* Layout */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    
    /* State Management */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    
    /* Fast Transitions */
    transition: all 0.2s ease;
    
    /* High z-index to stay above everything */
    z-index: 900;
}

.popup-chat-box.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.popup-chat-box:hover {
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px) scale(1.01);
}

.popup-chat-box.focused {
    z-index: 999;
    box-shadow: 
        0 30px 60px rgba(0, 0, 0, 0.2),
        0 0 0 2px rgba(79, 70, 229, 0.3);
    transform: translateY(-3px) scale(1.02) !important;
}

.popup-chat-box.minimized {
    height: 60px !important;
    overflow: hidden;
}

.popup-chat-box.minimized .popup-chat-messages,
.popup-chat-box.minimized .popup-chat-input {
    display: none;
}

/* 🎨 Subtle Chat Box Themes */
.popup-chat-box[data-theme="theme-1"] { 
    border-color: rgba(79, 70, 229, 0.2);
    box-shadow: 0 20px 40px rgba(79, 70, 229, 0.1);
}

.popup-chat-box[data-theme="theme-2"] { 
    border-color: rgba(6, 182, 212, 0.2);
    box-shadow: 0 20px 40px rgba(6, 182, 212, 0.1);
}

.popup-chat-box[data-theme="theme-3"] { 
    border-color: rgba(16, 185, 129, 0.2);
    box-shadow: 0 20px 40px rgba(16, 185, 129, 0.1);
}

.popup-chat-box[data-theme="theme-4"] { 
    border-color: rgba(249, 115, 22, 0.2);
    box-shadow: 0 20px 40px rgba(249, 115, 22, 0.1);
}

.popup-chat-box[data-theme="theme-5"] { 
    border-color: rgba(236, 72, 153, 0.2);
    box-shadow: 0 20px 40px rgba(236, 72, 153, 0.1);
}

/* 🎯 Smart Chat Box Header */
.popup-chat-header {
    background: var(--chat-primary);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    position: relative;
    overflow: hidden;
    min-height: 60px;
}

.popup-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 100%);
    pointer-events: none;
}

/* 👤 Chat Title Area */
.popup-chat-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: white;
    font-weight: 600;
    font-size: 16px;
    position: relative;
    z-index: 1;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.popup-chat-title .user-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    transition: all 0.3s var(--ease-spring);
    backdrop-filter: var(--glass-blur);
}

.popup-chat-title .user-avatar:hover {
    transform: scale(1.1) rotate(10deg);
    background: rgba(255, 255, 255, 0.3);
}

.popup-chat-title span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

/* 🎛️ Chat Controls */
.popup-chat-controls {
    display: flex;
    gap: var(--space-xs);
    position: relative;
    z-index: 1;
}

.popup-chat-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: var(--glass-blur);
}

.popup-chat-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* 💬 Messages Container */
.popup-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    background: rgba(248, 250, 252, 0.5);
    
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 126, 234, 0.3) transparent;
}

.popup-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.popup-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.popup-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: var(--radius-full);
}

.popup-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* 📨 Enhanced Message Bubbles */
.popup-message {
    margin-bottom: var(--space-md);
    animation: messageSlideIn 0.2s ease;
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.popup-message.other {
    align-self: flex-start;
    margin-right: auto;
    margin-left: 0;
}

.popup-message.own {
    align-self: flex-end;
    margin-left: auto;
    margin-right: 0;
    max-width: 85%; /* Slightly wider for own messages */
}

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

.popup-message.own {
    align-items: flex-end;
}

.popup-message.own .message-bubble {
    background: var(--chat-primary);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-xs) var(--radius-lg);
    box-shadow: var(--elevation-2);
}

.popup-message.other .message-bubble {
    background: white;
    color: #1f2937;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-xs);
    box-shadow: var(--elevation-1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.message-bubble {
    padding: var(--space-sm) var(--space-md);
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
    transition: all 0.15s ease;
    position: relative;
    backdrop-filter: var(--glass-blur);
}

.message-bubble:hover {
    transform: scale(1.01);
    box-shadow: var(--elevation-2);
}

.popup-message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: var(--space-2xs);
    font-weight: 500;
}

.popup-message.own .popup-message-time {
    text-align: right;
}

/* ✍️ Enhanced Input Area */
.popup-chat-input {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: var(--glass-blur);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
    position: relative;
}

.popup-chat-input input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: 2px solid rgba(102, 126, 234, 0.1);
    border-radius: var(--radius-full);
    background: white;
    color: #1f2937;
    font-size: 14px;
    transition: all 0.15s ease;
    outline: none;
}

.popup-chat-input input:focus {
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: scale(1.01);
}

.popup-chat-input input::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

.popup-chat-input button {
    background: var(--chat-primary);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-full);
    transition: all 0.15s ease;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--elevation-2);
    position: relative;
    overflow: hidden;
}

.popup-chat-input button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    transform: translate(-50%, -50%);
    transition: all 0.3s var(--ease-spring);
}

.popup-chat-input button:hover::before {
    width: 60px;
    height: 60px;
}

.popup-chat-input button:hover {
    transform: scale(1.05);
    box-shadow: var(--elevation-3);
}

.popup-chat-input button:active {
    transform: scale(0.95);
}

.popup-chat-input button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ⏳ Loading State */
.popup-chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    color: #6b7280;
    font-size: 14px;
}

.popup-chat-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    margin-right: var(--space-sm);
    border: 2px solid #e5e7eb;
    border-top: 2px solid #667eea;
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

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

/* 📱 Revolutionary Responsive Design */

/* Large Screens - Creative Positioning */
@media (min-width: 1400px) {
    .popup-chat-box:nth-child(1) {
        bottom: var(--space-xl);
        right: var(--space-xl);
        transform: rotate(0deg);
    }
    
    .popup-chat-box:nth-child(2) {
        bottom: calc(var(--space-xl) + 20px);
        right: calc(380px + var(--space-xl));
        transform: rotate(-2deg);
    }
    
    .popup-chat-box:nth-child(3) {
        bottom: calc(var(--space-xl) + 40px);
        right: calc(760px + var(--space-xl));
        transform: rotate(1.5deg);
    }
    
    .popup-chat-box:nth-child(4) {
        bottom: calc(580px + var(--space-xl));
        right: var(--space-xl);
        transform: rotate(-1deg);
    }
    
    .popup-chat-box:nth-child(5) {
        bottom: calc(580px + var(--space-xl) + 20px);
        right: calc(380px + var(--space-xl));
        transform: rotate(2deg);
    }
}

/* Medium Screens - Staggered Layout */
@media (min-width: 1024px) and (max-width: 1399px) {
    .popup-chat-box:nth-child(1) {
        bottom: var(--space-xl);
        right: var(--space-xl);
    }
    
    .popup-chat-box:nth-child(2) {
        bottom: calc(var(--space-xl) + 30px);
        right: calc(380px + var(--space-xl));
        width: 340px;
        height: 500px;
    }
    
    .popup-chat-box:nth-child(3) {
        bottom: calc(580px + var(--space-xl));
        right: var(--space-xl);
        width: 340px;
        height: 500px;
    }
    
    .popup-chat-box:nth-child(n+4) {
        display: none;
    }
}

/* Tablet Landscape - Smart Dual Chat */
@media (min-width: 768px) and (max-width: 1023px) {
    .popup-chat-box {
        width: 320px;
        height: 480px;
    }
    
    .popup-chat-box:nth-child(1) {
        bottom: var(--space-xl);
        right: var(--space-xl);
    }
    
    .popup-chat-box:nth-child(2) {
        bottom: calc(var(--space-xl) + 40px);
        right: calc(340px + var(--space-xl));
    }
    
    .popup-chat-box:nth-child(n+3) {
        display: none;
    }
}

/* Mobile - Full Screen Experience */
@media (max-width: 767px) {
    .floating-chat-panel {
        bottom: calc(clamp(60px, 8vw, 80px) + var(--space-lg));
        right: var(--space-md);
        left: var(--space-md);
        width: auto;
        max-height: calc(100vh - 150px);
    }
    
    .floating-chat-btn {
        bottom: var(--space-lg) !important;
        right: var(--space-lg) !important;
        width: 64px;
        height: 64px;
        font-size: 28px;
    }
    
    .popup-chat-box {
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        height: calc(100vh - 100px) !important;
        max-height: none !important;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0 !important;
        transform: translateY(100%) !important;
        margin: 0;
    }
    
    .popup-chat-box.active {
        transform: translateY(0) !important;
    }
    
    .popup-chat-box:not(.active) {
        transform: translateY(100%) !important;
    }
    
    .popup-chat-header {
        padding: var(--space-lg);
        min-height: 70px;
    }
    
    .popup-chat-title .user-avatar {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    .popup-chat-title span {
        font-size: 18px;
    }
    
    .popup-chat-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .popup-chat-messages {
        padding: var(--space-lg);
    }
    
    .message-bubble {
        font-size: 16px;
        padding: var(--space-md) var(--space-lg);
    }
    
    .popup-chat-input {
        padding: var(--space-lg);
    }
    
    .popup-chat-input input {
        font-size: 16px;
        padding: var(--space-md) var(--space-lg);
    }
    
    .popup-chat-input button {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
}

/* 🌙 Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --glass-white: rgba(17, 24, 39, 0.95);
        --glass-dark: rgba(255, 255, 255, 0.1);
        --glass-border: rgba(255, 255, 255, 0.1);
    }
    
    .floating-chat-panel,
    .popup-chat-box {
        background: var(--glass-white);
        color: white;
    }
    
    .popup-chat-messages {
        background: rgba(17, 24, 39, 0.5);
    }
    
    .popup-message.other .message-bubble {
        background: rgba(55, 65, 81, 0.8);
        color: white;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .popup-chat-input {
        background: rgba(17, 24, 39, 0.8);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .popup-chat-input input {
        background: rgba(55, 65, 81, 0.8);
        color: white;
        border-color: rgba(255, 255, 255, 0.2);
    }
}

/* ♿ Enhanced Accessibility */
@media (prefers-contrast: high) {
    .popup-chat-box {
        border: 3px solid #000;
    }
    
    .popup-chat-header {
        background: #000;
    }
    
    .popup-message.own .message-bubble {
        background: #000;
        color: #fff;
    }
    
    .popup-message.other .message-bubble {
        background: #fff;
        color: #000;
        border: 2px solid #000;
    }
    
    .popup-chat-input button {
        background: #000;
        border: 2px solid #fff;
    }
}

/* 🎭 Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .popup-chat-box,
    .floating-chat-btn,
    .popup-chat-btn,
    .message-bubble,
    .floating-friend-item {
        transition: none;
        animation: none;
    }
    
    .popup-chat-box:hover {
        transform: none;
    }
    
    .popup-chat-title .user-avatar::after {
        animation: none;
    }
}

/* 🖨️ Print Styles */
@media print {
    .floating-chat-btn,
    .floating-chat-panel,
    .popup-chat-box {
        display: none !important;
    }
}

/* 🎯 Focus Styles for Better Accessibility */
.floating-chat-btn:focus-visible,
.popup-chat-btn:focus-visible,
.panel-close-btn:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.6);
    outline-offset: 2px;
}

.popup-chat-input input:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.6);
    outline-offset: 2px;
}

/* 🔍 Screen Reader Support */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
} 