/* WhatsApp-like Chat Widget Styling */

/* Theme variables for light/dark mode support */
[data-theme="dark"] .chat-app {
    --message-sent-bg: #1f3a1f;
    --message-received-bg: #2a2a2a;
    --message-text-color: #ffffff;
    --message-text-muted: #a0a0a0;
    --message-border-color: #404040;
    --card-bg: #2a2a2a;
    --text-color: #ffffff;
    --border-color: #404040;
    --chat-bg: #1a1a1a;
    --date-line-bg: #1a1a1a;
    --scrollbar-track: #2a2a2a;
    --scrollbar-thumb: #404040;
    --scrollbar-thumb-hover: #505050;
    --hover-bg: #333333;
    --input-bg: #2a2a2a;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .chat-app {
    --message-sent-bg: #daf8cb;
    --message-received-bg: #f1f1f1;
    --message-text-color: #333333;
    --message-text-muted: #666666;
    --message-border-color: #e0e0e0;
    --card-bg: #ffffff;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --chat-bg: #e5ddd5;
    --date-line-bg: #e5ddd5;
    --scrollbar-track: #f1f1f1;
    --scrollbar-thumb: #c1c1c1;
    --scrollbar-thumb-hover: #a8a8a8;
    --hover-bg: #f5f5f5;
    --input-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

/* Main widget container */
.chat-app {
    position: fixed;
    bottom: 24px;
    right: 0px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    width: 100%;
    max-width: 385px;
    z-index: 1030;
    padding: 0 1rem 2rem 1rem;
    margin-bottom: 20px;
}

/* ===== COMPREHENSIVE RESPONSIVE DESIGN ===== */

/* Large Desktop (1200px and up) */
@media (min-width: 1200px) {
    .chat-app {
        max-width: 420px;
        bottom: 32px;
        right: 32px;
    }
    
    .chat-element {
        height: 700px;
    }
}

/* Medium Desktop (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .chat-app {
        max-width: 385px;
        bottom: 24px;
        right: 24px;
    }
    
    .chat-element {
        height: 650px;
    }
}

/* Small Desktop (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .chat-app {
        max-width: 360px;
        bottom: 20px;
        right: 20px;
        padding: 0 0.75rem 1.5rem 0.75rem;
    }
    
    .chat-element {
        height: 600px;
    }
}

/* Tablet Portrait (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .chat-app {
        max-width: 340px;
        bottom: 16px;
        right: 16px;
        padding: 0 0.5rem 1rem 0.5rem;
    }
    
    .chat-element {
        height: 550px;
    }
    
    .chat-bubble {
        width: 56px;
        height: 56px;
    }
    
    .chat-bubble svg {
        width: 22px;
        height: 22px;
    }
}

/* Mobile Large (425px - 575px) */
@media (min-width: 425px) and (max-width: 575px) {
    .chat-app {
        max-width: 320px;
        bottom: 12px;
        right: 12px;
        padding: 0 0.5rem 0.75rem 0.5rem;
    }
    
    .chat-element {
        height: 500px;
    }
    
    .chat-bubble {
        width: 52px;
        height: 52px;
        margin-bottom: 0.75rem;
    }
    
    .chat-bubble svg {
        width: 20px;
        height: 20px;
    }
}

/* Mobile Medium (375px - 424px) */
@media (min-width: 375px) and (max-width: 424px) {
    .chat-app {
        max-width: 300px;
        bottom: 8px;
        right: 8px;
        padding: 0 0.25rem 0.5rem 0.25rem;
    }
    
    .chat-element {
        height: 480px;
    }
    
    .chat-bubble {
        width: 48px;
        height: 48px;
        margin-bottom: 0.5rem;
    }
    
    .chat-bubble svg {
        width: 18px;
        height: 18px;
    }
}

/* Mobile Small (320px - 374px) */
@media (min-width: 320px) and (max-width: 374px) {
    .chat-app {
        max-width: 280px;
        bottom: 6px;
        right: 6px;
        padding: 0 0.25rem 0.5rem 0.25rem;
    }
    
    .chat-element {
        height: 450px;
    }
    
    .chat-bubble {
        width: 44px;
        height: 44px;
        margin-bottom: 0.5rem;
    }
    
    .chat-bubble svg {
        width: 16px;
        height: 16px;
    }
}

/* Extra Small Mobile (below 320px) */
@media (max-width: 319px) {
    .chat-app {
        max-width: 260px;
        bottom: 4px;
        right: 4px;
        padding: 0 0.25rem 0.5rem 0.25rem;
    }
    
    .chat-element {
        height: 420px;
    }
    
    .chat-bubble {
        width: 40px;
        height: 40px;
        margin-bottom: 0.5rem;
    }
    
    .chat-bubble svg {
        width: 14px;
        height: 14px;
    }
}

/* Height-based responsive adjustments */
@media (max-height: 800px) {
    .chat-app {
        bottom: 16px;
        padding: 0 1rem 1.5rem 1rem;
        margin-bottom: 16px;
    }
    
    .chat-element {
        height: 580px;
        margin-bottom: 1.5rem;
    }
    
    /* Chat list container - accounts for header + search + padding */
    .chat-rooms-container {
        height: calc(580px - 60px - 50px - 24px); /* header ~60px + search ~50px + padding */
    }
    
    /* Chat space container - accounts for header + input area + padding */
    .chat-space-container {
        height: calc(580px - 60px - 80px - 24px); /* header ~60px + input ~80px + padding */
    }
}

/* Specific fix for 742px height issue */
@media (min-height: 700px) and (max-height: 750px) {
    .chat-app {
        bottom: 20px;
        padding: 0 1rem 1.5rem 1rem;
        margin-bottom: 20px;
    }
    
    .chat-element {
        height: 520px;
        margin-bottom: 1.5rem;
    }
    
    /* Chat list container - accounts for header + search + padding */
    .chat-rooms-container {
        height: calc(520px - 60px - 50px - 24px); /* header ~60px + search ~50px + padding */
    }
    
    /* Chat space container - accounts for header + input area + padding */
    .chat-space-container {
        height: calc(520px - 60px - 80px - 24px); /* header ~60px + input ~80px + padding */
    }
    
    /* Ensure headers are always visible */
    .chat-list-header,
    .chat-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--card-bg);
    }
}

@media (max-height: 600px) {
    .chat-app {
        bottom: 12px;
        padding: 0 1rem 1rem 1rem;
        margin-bottom: 12px;
    }
    
    .chat-element {
        height: 500px;
        margin-bottom: 1rem;
    }
    
    /* Chat list container */
    .chat-rooms-container {
        height: calc(500px - 60px - 50px - 20px);
    }
    
    /* Chat space container */
    .chat-space-container {
        height: calc(500px - 60px - 80px - 20px);
    }
}

@media (max-height: 500px) {
    .chat-app {
        bottom: 8px;
        padding: 0 0.75rem 0.75rem 0.75rem;
        margin-bottom: 8px;
    }
    
    .chat-element {
        height: 400px;
        margin-bottom: 0.75rem;
    }
    
    /* Chat list container */
    .chat-rooms-container {
        height: calc(400px - 60px - 50px - 16px);
    }
    
    /* Chat space container */
    .chat-space-container {
        height: calc(400px - 60px - 80px - 16px);
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .chat-app {
        bottom: 4px;
        padding: 0 0.5rem 0.5rem 0.5rem;
        margin-bottom: 4px;
    }
    
    .chat-element {
        height: 350px;
        margin-bottom: 0.5rem;
    }
    
    /* Chat list container */
    .chat-rooms-container {
        height: calc(350px - 60px - 50px - 12px);
    }
    
    /* Chat space container */
    .chat-space-container {
        height: calc(350px - 60px - 80px - 12px);
    }
    
    .chat-bubble {
        margin-bottom: 0.5rem;
    }
}

/* Extra small height adjustments */
@media (max-height: 400px) {
    .chat-app {
        bottom: 4px;
        padding: 0 0.5rem 0.5rem 0.5rem;
        margin-bottom: 4px;
    }
    
    .chat-element {
        height: 300px;
        margin-bottom: 0.5rem;
    }
    
    /* Chat list container */
    .chat-rooms-container {
        height: calc(300px - 60px - 50px - 8px);
    }
    
    /* Chat space container */
    .chat-space-container {
        height: calc(300px - 60px - 80px - 8px);
    }
    
    .chat-bubble {
        margin-bottom: 0.25rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .chat-bubble {
        min-width: 44px;
        min-height: 44px;
    }
    
    .chat-bubble:hover {
        transform: none;
    }
    
    .chat-bubble:active {
        transform: scale(0.95);
    }
    
    .chat-room {
        min-height: 60px;
    }
    
    .chat-room:hover {
        background: var(--hover-bg);
    }
    
    .chat-room:active {
        background: var(--border-color);
    }
    
    .message-send-button,
    .open-attach-items {
        min-width: 44px;
        min-height: 44px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .chat-bubble {
        box-shadow: 0px 1px 3px var(--shadow-color),
            0px 0.5px 2px var(--shadow-color);
    }
    
    .bubble-badge {
        border-width: 1px;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .chat-bubble,
    .chat-room,
    .message-send-button,
    .open-attach-items {
        transition: none;
    }
    
    .chat-bubble:hover {
        transform: none;
    }
}

/* Dark mode system preference */
@media (prefers-color-scheme: dark) {
    .chat-app:not([data-theme]) {
        --message-sent-bg: #1f3a1f;
        --message-received-bg: #2a2a2a;
        --message-text-color: #ffffff;
        --message-text-muted: #a0a0a0;
        --message-border-color: #404040;
        --card-bg: #2a2a2a;
        --text-color: #ffffff;
        --border-color: #404040;
        --chat-bg: #1a1a1a;
        --date-line-bg: #1a1a1a;
        --scrollbar-track: #2a2a2a;
        --scrollbar-thumb: #404040;
        --scrollbar-thumb-hover: #505050;
        --hover-bg: #333333;
        --input-bg: #2a2a2a;
        --shadow-color: rgba(0, 0, 0, 0.3);
    }
}

/* Print styles */
@media print {
    .chat-app {
        display: none !important;
    }
}

/* Chat bubble (floating button) */
.chat-bubble {
    cursor: pointer;
    background: #25D366;
    color: white;
    border-radius: 100px;
    font-weight: bold;
    display: flex;
    align-items: center;
    width: 60px;
    height: 60px;
    justify-content: center;
    box-shadow: 0px 2px 6px var(--shadow-color),
        0px 1px 4px var(--shadow-color);
    transition: all 0.3s ease;
    margin-bottom: 1rem;
    position: relative;
}

.chat-bubble:hover {
    box-shadow: 0px 4px 12px var(--shadow-color);
    transform: scale(1.05);
}

.chat-bubble svg {
    fill: white;
    width: 24px;
    height: 24px;
}

.chat-bubble.active {
    background: #128C7E;
}

/* Badge for unread messages on chat bubble */
.bubble-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: none; /* Hidden by default */
}

/* Chat bubble with text (open state) */
.chat-bubble.p-3 {
    width: auto;
    height: auto;
    padding: 12px 20px !important;
    gap: 8px;
}

.chat-bubble .chat-message-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-bubble .chat-message-icon svg {
    width: 1.1rem;
    height: 1.1rem;
    fill: white;
}

/* Chat bubble closed state */
.chat-bubble-closed.chat-bubble {
    width: 60px;
    height: 60px;
    position: relative;
    text-align: center;
}

.chat-bubble-closed .cross-icon {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.chat-bubble-closed .cross-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

/* Chat space (main chat window) */
.chat-element {
    height: 650px;
    width: 100%;
    position: relative;
    box-shadow: 0px 2px 6px var(--shadow-color),
        0px 1px 4px var(--shadow-color);
    background: var(--card-bg);
    border-radius: 6px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 100px); /* Ensure it doesn't exceed viewport height */
}

/* Chat cross button */
.chat-cross-button {
    display: block;
    color: var(--text-color);
    cursor: pointer;
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    
    &:hover {
        background: var(--border-color);
        color: var(--text-color);
    }
    
    svg {
        width: 16px;
        height: 16px;
        fill: currentColor;
    }
}

/* Chat container */
.chat-container {
    padding: 0;
    margin: 0;
    height: 100%;
}

/* Chat list styling */
.chat-list {
    .chat-list-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border-color);
        background: var(--card-bg);
        min-height: 60px;
        box-sizing: border-box;
        position: sticky;
        top: 0;
        z-index: 10;
        
        .chat-list-left {
            display: flex;
            align-items: center;
            flex: 0 0 auto;
            
            .add-room {
                cursor: pointer;
                padding: 8px;
                border-radius: 50%;
                transition: all 0.2s ease;
                display: flex;
                align-items: center;
                justify-content: center;
                color: var(--text-color);
                
                &:hover {
                    background: var(--hover-bg);
                    color: var(--primary-color, #25D366);
                }
                
                svg {
                    width: 16px;
                    height: 16px;
                    fill: currentColor;
                }
            }
        }
        
        .header-title {
            flex: 1;
            text-align: center;
            font-weight: 600;
            color: var(--text-color);
            font-size: 0.875rem;
        }
        
        .chat-list-right {
            display: flex;
            align-items: center;
            flex: 0 0 auto;
            width: 32px;
            
            .chat-close-button {
                cursor: pointer;
                padding: 8px;
                border-radius: 50%;
                transition: all 0.2s ease;
                display: flex;
                align-items: center;
                justify-content: center;
                color: var(--text-color);
                
                &:hover {
                    background: var(--hover-bg);
                    color: #ff6b6b;
                }
                
                svg {
                    width: 16px;
                    height: 16px;
                    fill: currentColor;
                }
            }
        }
    }
    
    /* Responsive chat list header */
    @media (max-height: 600px) {
        .chat-list-header {
            padding: 10px 12px;
            min-height: 50px;
            
            .header-title {
                font-size: 0.8rem;
            }
            
            .add-room,
            .chat-close-button {
                padding: 6px;
                
                svg {
                    width: 14px;
                    height: 14px;
                }
            }
        }
    }
    
    @media (max-height: 500px) {
        .chat-list-header {
            padding: 8px 10px;
            min-height: 45px;
            
            .header-title {
                font-size: 0.75rem;
            }
            
            .add-room,
            .chat-close-button {
                padding: 5px;
                
                svg {
                    width: 12px;
                    height: 12px;
                }
            }
        }
    }
    .chat-search {
        position: relative;
        display: flex;
        align-items: center;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin: 8px 12px;
        padding: 0;
        transition: all 0.2s ease;
        
        &.focused {
            border-color: var(--primary-color, #25D366);
            box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.1);
        }
        
        .search-icon {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 40px;
            height: 40px;
            color: var(--text-muted, #666);
            flex-shrink: 0;
            
            svg {
                width: 16px;
                height: 16px;
                fill: currentColor;
            }
        }
        
        .chat-search-box {
            flex: 1;
            border: none;
            background: transparent;
            padding: 12px 8px;
            font-size: 0.875rem;
            color: var(--text-color);
            outline: none;
            
            &::placeholder {
                color: var(--text-muted, #666);
            }
            
            &:focus {
                box-shadow: none;
            }
        }
        
        .search-clear {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            cursor: pointer;
            color: var(--text-muted, #666);
            border-radius: 50%;
            transition: all 0.2s ease;
            margin-right: 4px;
            
            &:hover {
                background: var(--border-color);
                color: var(--text-color);
            }
            
            svg {
                width: 14px;
                height: 14px;
                fill: currentColor;
            }
        }
    }

    .chat-rooms-container {
        height: calc(100% - 60px - 56px - 24px); /* header ~60px + search ~56px + padding */
        overflow-y: scroll;
        padding: 12px;

        .chat-room {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px;
            border-bottom: 1px solid var(--border-color);
            cursor: pointer;
            transition: background-color 0.2s ease;
            
            &:hover {
                background: var(--hover-bg);
            }
            
            .chat-profile-info {
                flex: 1;
                min-width: 0;
                
                        .chat-name {
            font-weight: 600;
            color: var(--text-color);
            margin-bottom: 4px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', 'Android Emoji', 'EmojiSymbols', sans-serif;
        }
                
                        .chat-latest {
            font-size: 13px;
            color: var(--message-text-muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 200px;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', 'Android Emoji', 'EmojiSymbols', sans-serif;
        }
            }
            
            .chat-meta {
                display: flex;
                flex-direction: column;
                align-items: flex-end;
                gap: 4px;
                
                .chat-date {
                    font-size: 11px;
                    color: var(--message-text-muted);
                    white-space: nowrap;
                }
                
                .unread-badge {
                    background: #25D366;
                    color: white;
                    border-radius: 50%;
                    min-width: 18px;
                    height: 18px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    font-size: 11px;
                    font-weight: bold;
                    padding: 0 4px;
                }
            }
        }
    }
    
    /* Responsive search and chat rooms */
    @media (max-width: 575px) {
        .chat-search {
            margin: 6px 8px;
            
            .search-icon {
                width: 36px;
                height: 36px;
                
                svg {
                    width: 14px;
                    height: 14px;
                }
            }
            
            .chat-search-box {
                padding: 10px 6px;
                font-size: 0.8rem;
            }
            
            .search-clear {
                width: 28px;
                height: 28px;
                margin-right: 2px;
                
                svg {
                    width: 12px;
                    height: 12px;
                }
            }
        }
        
        .chat-rooms-container {
            height: calc(100% - 60px - 48px - 16px); /* Adjusted for smaller search */
            padding: 8px;
            
            .chat-room {
                padding: 10px 12px;
                
                .chat-profile-info {
                    .chat-name {
                        font-size: 14px;
                    }
                    
                    .chat-latest {
                        font-size: 12px;
                        max-width: 150px;
                    }
                }
                
                .chat-meta {
                    .chat-date {
                        font-size: 10px;
                    }
                    
                    .unread-badge {
                        min-width: 16px;
                        height: 16px;
                        font-size: 10px;
                    }
                }
            }
        }
    }
    
    @media (max-width: 374px) {
        .chat-search {
            margin: 4px 6px;
            
            .search-icon {
                width: 32px;
                height: 32px;
                
                svg {
                    width: 12px;
                    height: 12px;
                }
            }
            
            .chat-search-box {
                padding: 8px 4px;
                font-size: 0.75rem;
            }
            
            .search-clear {
                width: 24px;
                height: 24px;
                margin-right: 2px;
                
                svg {
                    width: 10px;
                    height: 10px;
                }
            }
        }
        
        .chat-rooms-container {
            height: calc(100% - 60px - 40px - 12px); /* Adjusted for smaller search */
            padding: 6px;
            
            .chat-room {
                padding: 8px 10px;
                
                .chat-profile-info {
                    .chat-name {
                        font-size: 13px;
                    }
                    
                    .chat-latest {
                        font-size: 11px;
                        max-width: 120px;
                    }
                }
                
                .chat-meta {
                    .chat-date {
                        font-size: 9px;
                    }
                    
                    .unread-badge {
                        min-width: 14px;
                        height: 14px;
                        font-size: 9px;
                    }
                }
            }
        }
    }
}

/* Chat header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 60px;
    box-sizing: border-box;

    .chat-header-left {
        display: flex;
        align-items: center;
        flex: 0 0 auto;
        
        .chat-back-button {
            cursor: pointer;
            padding: 8px;
            border-radius: 50%;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-color);
            
            &:hover {
                background: var(--border-color);
                color: var(--primary-color, #25D366);
            }
            
            svg {
                width: 16px;
                height: 16px;
                fill: currentColor;
            }
        }
    }

    .chat-profile-info {
        flex: 1;
        text-align: center;
        margin: 0 16px;
        min-width: 0;

        .chat-profile-name {
            font-weight: 600;
            color: var(--text-color);
            font-size: 0.875rem;
            margin-bottom: 2px;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', 'Android Emoji', 'EmojiSymbols', sans-serif;
        }

        .chat-profile-status {
            font-size: 12px;
            color: var(--message-text-muted);
            
            .connection-status {
                color: #25D366;
                font-size: 14px;
                margin-right: 4px;
                
                &.disconnected {
                    color: #ff6b6b;
                }
                
                &.connecting {
                    color: #ffa726;
                    animation: pulse 2s infinite;
                }
            }
        }
    }

    .chat-header-right {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 0 0 auto;
        
        .chat-channel-selector {
            .channel-select {
                background: var(--card-bg);
                border: 1px solid var(--border-color);
                border-radius: 4px;
                padding: 4px 8px;
                font-size: 0.75rem;
                color: var(--text-color);
                cursor: pointer;
                min-width: 120px;
                max-width: 150px;
                
                &:focus {
                    outline: none;
                    border-color: var(--primary-color, #25D366);
                }
                
                option {
                    background: var(--card-bg);
                    color: var(--text-color);
                }
            }
        }
        
        .chat-close-button {
            cursor: pointer;
            padding: 8px;
            border-radius: 50%;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-color);
            
            &:hover {
                background: var(--hover-bg);
                color: #ff6b6b;
            }
            
            svg {
                width: 16px;
                height: 16px;
                fill: currentColor;
            }
        }
    }
    
    /* Responsive chat header */
    @media (max-height: 600px) {
        padding: 10px 12px;
        min-height: 50px;
        
        .chat-profile-info {
            .chat-profile-name {
                font-size: 0.8rem;
            }
            
            .chat-profile-status {
                font-size: 0.7rem;
            }
        }
        
        .chat-back-button,
        .chat-close-button {
            padding: 6px;
            
            svg {
                width: 14px;
                height: 14px;
            }
        }
        
        .chat-channel-selector .channel-select {
            padding: 3px 6px;
            font-size: 0.7rem;
        }
    }
    
    @media (max-height: 500px) {
        padding: 8px 10px;
        min-height: 45px;
        
        .chat-profile-info {
            .chat-profile-name {
                font-size: 0.75rem;
            }
            
            .chat-profile-status {
                font-size: 0.65rem;
            }
        }
        
        .chat-back-button,
        .chat-close-button {
            padding: 5px;
            
            svg {
                width: 12px;
                height: 12px;
            }
        }
        
        .chat-channel-selector .channel-select {
            padding: 2px 4px;
            font-size: 0.65rem;
        }
    }
}

/* Chat space styling */
.chat-space {
    height: 100%;
    .chat-space-container {
        display: flex;
        flex-direction: column;
        padding: 12px;
        overflow-wrap: break-word;
        height: calc(100% - 60px - 80px - 24px); /* header ~60px + input ~80px + padding */
        overflow-y: scroll;
        background: var(--chat-bg);
        margin-bottom: 8px;
        .chat-image {
            max-width: 200px;
            max-height: 200px;
            border-radius: 8px;
            cursor: pointer;
            transition: transform 0.2s ease;
            
            &:hover {
                transform: scale(1.05);
            }
        }
        .message-name {
            font-size: 0.75rem;
            font-weight: bold;
            color: var(--message-text-muted);
        }
        .sender-message {
            margin-bottom: 5px;
            display: flex;
            flex-direction: column;
            align-items: flex-end !important;
            .message-bubble {
                background: var(--message-sent-bg);
                color: var(--message-text-color);
                padding: 8px 12px;
                font-size: 0.875rem;
                border-radius: 18px 18px 0px 18px;
                max-width: 78%;
                border: 1px solid var(--message-border-color);
            }
        }
        .recipient-message {
            margin-bottom: 5px;
            display: flex;
            flex-direction: column;
            align-items: flex-start !important;
            .message-bubble {
                background: var(--message-received-bg);
                color: var(--message-text-color);
                padding: 8px 12px;
                font-size: 0.875rem;
                border-radius: 18px 18px 18px 0px;
                max-width: 78%;
                border: 1px solid var(--message-border-color);
            }
        }

        .message-time {
            color: var(--message-text-muted);
            font-size: 0.75rem;
            margin-top: 4px;
        }
        .message-name {
            color: var(--message-text-muted);
            font-size: 0.75rem;
            margin-bottom: 4px;
        }
        .date-line {
            width: 100%;
            text-align: center;
            border-bottom: 1px solid var(--message-border-color);
            line-height: 0.1em;
            margin: 10px 0 20px;
            span {
                background: var(--date-line-bg);
                padding: 0 8px;
                font-size: 0.875rem;
            }
        }
        .file-attachment {
            display: inline-flex;
            align-items: center;
            padding: 8px 12px;
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            color: var(--text-color);
            text-decoration: none;
            font-size: 0.875rem;
            transition: all 0.2s ease;
            
            &:hover {
                background: var(--hover-bg);
                text-decoration: none;
                color: var(--text-color);
            }
        }
        
        .file-link {
            text-decoration: none;
            color: inherit;
            display: inline-block;
            
            &:hover {
                opacity: 0.8;
            }
            
            &:focus {
                outline: none;
            }
        }
        
        /* Message attachment and text layout */
        .message-attachment {
            margin-bottom: 8px;
            
            .chat-image {
                max-width: 200px;
                max-height: 200px;
                border-radius: 8px;
                display: block;
                margin-bottom: 0;
            }
            
            video {
                max-width: 200px;
                max-height: 200px;
                border-radius: 8px;
                display: block;
            }
            
            audio {
                max-width: 200px;
                display: block;
            }
            
            .audio-player {
                display: flex;
                flex-direction: column;
                margin: 6px 0;
                padding: 12px 16px;
                border-radius: 18px;
                background: var(--message-received-bg);
                border: 1px solid var(--border-color);
                box-shadow: 0 1px 3px var(--shadow-color);
                max-width: 280px;
                min-width: 200px;
                position: relative;
                overflow: hidden;
                
                .audio-player-content {
                    display: flex;
                    align-items: center;
                    gap: 12px;
                    margin-bottom: 8px;
                    
                    .audio-icon {
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        width: 32px;
                        height: 32px;
                        border-radius: 50%;
                        background: var(--primary-color, #25D366);
                        color: white;
                        flex-shrink: 0;
                        
                        svg {
                            width: 16px;
                            height: 16px;
                            fill: currentColor;
                        }
                    }
                    
                    .audio-info {
                        flex: 1;
                        min-width: 0;
                        
                        .audio-title {
                            font-size: 14px;
                            font-weight: 500;
                            color: var(--message-text-color);
                            margin-bottom: 2px;
                            white-space: nowrap;
                            overflow: hidden;
                            text-overflow: ellipsis;
                        }
                        
                        .audio-duration {
                            font-size: 12px;
                            color: var(--message-text-muted);
                            font-weight: 400;
                        }
                    }
                    
                    .audio-controls {
                        display: flex;
                        align-items: center;
                        flex-shrink: 0;
                        
                        .play-pause-btn {
                            display: flex;
                            align-items: center;
                            justify-content: center;
                            width: 36px;
                            height: 36px;
                            border-radius: 50%;
                            background: var(--primary-color, #25D366);
                            color: white;
                            border: none;
                            cursor: pointer;
                            transition: all 0.2s ease;
                            box-shadow: 0 2px 4px var(--shadow-color);
                            
                            &:hover {
                                background: var(--primary-color-dark, #128C7E);
                                transform: scale(1.05);
                                box-shadow: 0 3px 6px var(--shadow-color);
                            }
                            
                            &:active {
                                transform: scale(0.95);
                            }
                            
                            svg {
                                width: 20px;
                                height: 20px;
                                fill: currentColor;
                            }
                            
                            &.playing {
                                .play-icon {
                                    display: none;
                                }
                                .pause-icon {
                                    display: block;
                                }
                            }
                            
                            &:not(.playing) {
                                .play-icon {
                                    display: block;
                                }
                                .pause-icon {
                                    display: none;
                                }
                            }
                        }
                    }
                }
                
                .audio-progress {
                    width: 100%;
                    
                    .progress-bar {
                        width: 100%;
                        height: 4px;
                        background: var(--border-color);
                        border-radius: 2px;
                        overflow: hidden;
                        position: relative;
                        
                        .progress-fill {
                            height: 100%;
                            background: var(--primary-color, #25D366);
                            border-radius: 2px;
                            width: 0%;
                            transition: width 0.1s ease;
                            position: relative;
                            
                            &::after {
                                content: '';
                                position: absolute;
                                right: -4px;
                                top: 50%;
                                transform: translateY(-50%);
                                width: 8px;
                                height: 8px;
                                background: var(--primary-color, #25D366);
                                border-radius: 50%;
                                border: 2px solid white;
                                box-shadow: 0 1px 3px var(--shadow-color);
                                opacity: 0;
                                transition: opacity 0.2s ease;
                            }
                        }
                        
                        &:hover .progress-fill::after {
                            opacity: 1;
                        }
                    }
                }
                
                /* Legacy audio element styling (hidden) */
                audio {
                    display: none !important;
                }
            }
            
            .file-attachment {
                display: inline-flex;
                align-items: center;
                gap: 8px;
                padding: 8px 12px;
                background: rgba(0, 0, 0, 0.05);
                border-radius: 8px;
                text-decoration: none;
                color: inherit;
                font-size: 14px;
                max-width: 200px;
                word-break: break-word;
                
                &:hover {
                    background: rgba(0, 0, 0, 0.1);
                    text-decoration: none;
                    color: inherit;
                }
            }
        }
        
        .message-text {
            line-height: 1.4;
            word-wrap: break-word;
            white-space: pre-wrap;
            font-family: 
                -apple-system, BlinkMacSystemFont, 'Segoe UI',
                'Apple Color Emoji',           /* macOS, iOS */
                'Segoe UI Emoji',              /* Windows */
                'Noto Color Emoji',            /* Android, Linux */
                'Android Emoji',               /* Android */
                'EmojiSymbols',                /* Legacy */
                'Twemoji Mozilla',             /* Firefox fallback */
                'Symbola',                     /* Universal fallback */
                sans-serif;
            
            /* If there's no attachment above, remove top margin */
            &:first-child {
                margin-top: 0;
            }
        }
        
        .emoji-text {
            font-family: 
                'Apple Color Emoji',           /* macOS, iOS */
                'Segoe UI Emoji',              /* Windows */
                'Noto Color Emoji',            /* Android, Linux */
                'Android Emoji',               /* Android */
                'EmojiSymbols',                /* Legacy */
                'Twemoji Mozilla',             /* Firefox fallback */
                'Symbola',                     /* Universal fallback */
                sans-serif;
            font-size: 1.1em;
            line-height: 1.2;
        }
    }
    .chat-space-actions {
        display: flex;
        align-items: center;
        padding: 12px;
        gap: 8px;
        border-top: 1px solid var(--border-color);
        background: var(--card-bg);
        position: relative;
        z-index: 5;
        min-height: 60px;
        box-sizing: border-box;

        .open-attach-items {
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            color: var(--text-color);
            transition: all 0.2s ease;
            position: relative;
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            z-index: 10;
            pointer-events: auto;
            
            &:hover {
                background: var(--primary-color, #25D366);
                color: white;
                border-color: var(--primary-color, #25D366);
                transform: scale(1.05);
            }
            
            &.uploading {
                animation: spin 1s linear infinite;
                color: var(--primary-color, #25D366);
            }
            
            svg {
                width: 18px;
                height: 18px;
                fill: currentColor;
                pointer-events: none;
            }
        }

        .emoji-picker-button {
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            color: var(--text-color);
            transition: all 0.2s ease;
            position: relative;
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            z-index: 10;
            pointer-events: auto;
            
            &:hover {
                background: var(--primary-color, #25D366);
                color: white;
                border-color: var(--primary-color, #25D366);
                transform: scale(1.05);
            }
            
            &:active {
                transform: scale(0.95);
            }
            
            svg {
                width: 18px;
                height: 18px;
                fill: currentColor;
                pointer-events: none;
            }
        }

        .type-message {
            flex: 1;
            border: 1px solid var(--border-color);
            border-radius: 20px;
            padding: 10px 16px;
            background: var(--card-bg);
            color: var(--text-color);
            font-size: 0.875rem;
            margin: 0 8px;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', 'Android Emoji', 'EmojiSymbols', sans-serif;
            
            &:focus {
                outline: none;
                border-color: var(--primary-color, #25D366);
            }
            
            &::placeholder {
                color: var(--message-text-muted);
            }
        }

        .message-send-button {
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: var(--primary-color, #25D366);
            color: white;
            transition: all 0.2s ease;
            border: 1px solid var(--primary-color, #25D366);
            
            &:hover {
                background: var(--primary-color-dark, #128C7E);
                border-color: var(--primary-color-dark, #128C7E);
                transform: scale(1.05);
            }
            
            &:active {
                transform: scale(0.95);
            }
            
            svg {
                width: 16px;
                height: 16px;
                fill: currentColor;
            }
        }
        
        /* Responsive chat actions */
        @media (max-width: 575px) {
            padding: 10px;
            gap: 6px;
            min-height: 56px;
            
            .open-attach-items,
            .emoji-picker-button,
            .message-send-button {
                width: 32px;
                height: 32px;
                
                svg {
                    width: 16px;
                    height: 16px;
                }
            }
            
            .type-message {
                padding: 8px 12px;
                font-size: 0.8rem;
                margin: 0 6px;
            }
        }
        
        @media (max-width: 374px) {
            padding: 8px;
            gap: 4px;
            min-height: 52px;
            
            .open-attach-items,
            .emoji-picker-button,
            .message-send-button {
                width: 28px;
                height: 28px;
                
                svg {
                    width: 14px;
                    height: 14px;
                }
            }
            
            .type-message {
                padding: 6px 10px;
                font-size: 0.75rem;
                margin: 0 4px;
            }
        }
    }

    .file-preview {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 8px;
        position: relative;
        
        .file-preview-content {
            flex: 1;
            display: flex;
            align-items: center;
            gap: 8px;
            
            .preview-image {
                border: 1px solid var(--border-color);
            }
            
            .preview-document {
                display: flex;
                align-items: center;
                gap: 4px;
                font-size: 0.875rem;
                color: var(--text-color);
            }
        }
        
        .file-preview-actions {
            .remove-file-btn {
                cursor: pointer;
                display: flex;
                align-items: center;
                justify-content: center;
                width: 24px;
                height: 24px;
                border-radius: 50%;
                background: var(--border-color);
                color: var(--text-color);
                border: none;
                transition: all 0.2s ease;
                
                &:hover {
                    background: #ff4444;
                    color: white;
                }
                
                svg {
                    width: 14px;
                    height: 14px;
                    fill: currentColor;
                }
            }
        }
    }
    
    .no-chats-found {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 40px 20px;
        text-align: center;
        color: var(--text-muted, #666);
        
        .no-chats-icon {
            font-size: 3rem;
            margin-bottom: 16px;
            opacity: 0.6;
        }
        
        .no-chats-text {
            font-size: 1.1rem;
            font-weight: 500;
            margin-bottom: 8px;
            color: var(--text-color);
        }
        
        .no-chats-hint {
            font-size: 0.9rem;
            opacity: 0.8;
        }
    }
}

/* Scrollbar styling */
.chat-list::-webkit-scrollbar,
.chat-space-container::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-track,
.chat-space-container::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.chat-list::-webkit-scrollbar-thumb,
.chat-space-container::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

.chat-list::-webkit-scrollbar-thumb:hover,
.chat-space-container::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Animations */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Navbar notification badge styling */
.chat-navbar-icon {
    position: relative;
    cursor: pointer;
}

.chat-navbar-icon .badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.chat-navbar-icon .badge:empty {
    display: none;
}

/* Enhanced emoji font support */
@font-face {
    font-family: 'Segoe UI Emoji';
    src: local('Segoe UI Emoji');
}

@font-face {
    font-family: 'Apple Color Emoji';
    src: local('Apple Color Emoji');
}

@font-face {
    font-family: 'Noto Color Emoji';
    src: local('Noto Color Emoji');
}

@font-face {
    font-family: 'Android Emoji';
    src: local('Android Emoji');
}

@font-face {
    font-family: 'EmojiSymbols';
    src: local('EmojiSymbols');
}

@font-face {
    font-family: 'Twemoji Mozilla';
    src: local('Twemoji Mozilla');
}

/* Universal emoji font stack for better cross-platform support */
.emoji-font-stack {
    /* Modern emoji fonts with Unicode 16.0 support */
    font-family: 
        /* Apple devices - supports up to Unicode 16.0 */
        "Apple Color Emoji",
        /* Windows 11 - supports up to Unicode 15.0 */
        "Segoe UI Emoji",
        /* Google Noto - supports up to Unicode 15.0 */
        "Noto Color Emoji",
        /* Android - supports up to Unicode 14.0 */
        "Android Emoji",
        /* Microsoft Windows 10 - supports up to Unicode 13.0 */
        "Segoe UI Symbol",
        /* Twitter/Mozilla - supports up to Unicode 14.0 */
        "Twemoji Mozilla",
        /* EmojiOne - supports up to Unicode 12.0 */
        "EmojiOne Mozilla",
        /* EmojiSymbols - supports up to Unicode 12.0 */
        "EmojiSymbols",
        /* Symbola - universal fallback with good Unicode support */
        "Symbola",
        /* Fallback to system UI font */
        "Segoe UI",
        "Helvetica Neue",
        Arial,
        sans-serif;
    font-weight: normal;
    font-style: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Ensure emojis render at proper size */
    font-size: 1em;
    /* Prevent emoji from being squished */
    font-feature-settings: "liga" 1, "kern" 1;
    /* Enable color emoji support */
    -webkit-font-feature-settings: "liga" 1, "kern" 1;
    -moz-font-feature-settings: "liga" 1, "kern" 1;
}



/* Ensure emoji text uses the emoji font stack */
.message-text {
    font-family: inherit;
}

.message-text .emoji-font-stack {
    /* Override inherited font to use emoji font stack */
    font-family: 
        "Apple Color Emoji",
        "Segoe UI Emoji",
        "Noto Color Emoji",
        "Android Emoji",
        "Segoe UI Symbol",
        "Twemoji Mozilla",
        "EmojiOne Mozilla",
        "EmojiSymbols",
        "Symbola",
        "Segoe UI",
        "Helvetica Neue",
        Arial,
        sans-serif !important;
    font-weight: normal;
    font-style: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 1em;
    font-feature-settings: "liga" 1, "kern" 1;
    -webkit-font-feature-settings: "liga" 1, "kern" 1;
    -moz-font-feature-settings: "liga" 1, "kern" 1;
}

/* Clickable contact name styles */
.clickable-contact-name {
    cursor: pointer;
    transition: color 0.2s ease;
    position: relative;
    
    &:hover {
        color: var(--primary-color, #25D366);
        text-decoration: underline;
    }
    
    &:active {
        transform: scale(0.98);
    }
}

/* Contact dropdown styles */
.contact-dropdown {
    background: var(--card-bg, white);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    max-width: 300px;
    z-index: 1000;
    overflow: hidden;
    
    .dropdown-header {
        padding: 12px 16px;
        background: var(--primary-color, #25D366);
        color: white;
        font-weight: 600;
        font-size: 0.9rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        
        span {
            display: block;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    }
    
    .dropdown-items {
        max-height: 300px;
        overflow-y: auto;
        
        .dropdown-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 16px;
            cursor: pointer;
            transition: background-color 0.2s ease;
            border-bottom: 1px solid var(--border-color, #f0f0f0);
            
            &:last-child {
                border-bottom: none;
            }
            
            &:hover {
                background: var(--hover-bg, #f8f9fa);
            }
            
            &:active {
                background: var(--active-bg, #e9ecef);
            }
            
            .item-icon {
                font-size: 1.2rem;
                width: 20px;
                text-align: center;
                flex-shrink: 0;
            }
            
            .item-text {
                font-weight: 500;
                color: var(--text-color, #333);
                flex: 1;
                min-width: 0;
            }
            
            .item-name {
                font-size: 0.8rem;
                color: var(--text-muted, #666);
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                max-width: 120px;
            }
        }
    }
}

/* Dark theme support for no results */
[data-theme="dark"] .no-chats-found {
    color: var(--text-muted, #a0aec0);
    
    .no-chats-text {
        color: var(--text-color, #e2e8f0);
    }
    
    .no-chats-hint {
        color: var(--text-muted, #a0aec0);
    }
}

/* Dark theme support for search */
[data-theme="dark"] .chat-search {
    background: var(--card-bg, #2d3748);
    border-color: var(--border-color, #4a5568);
    
    .search-icon {
        color: var(--text-muted, #a0aec0);
    }
    
    .chat-search-box {
        color: var(--text-color, #e2e8f0);
        
        &::placeholder {
            color: var(--text-muted, #a0aec0);
        }
    }
    
    .search-clear {
        color: var(--text-muted, #a0aec0);
        
        &:hover {
            background: var(--border-color, #4a5568);
            color: var(--text-color, #e2e8f0);
        }
    }
}

/* Dark theme support for dropdown */
[data-theme="dark"] .contact-dropdown {
    background: var(--card-bg, #2d3748);
    border-color: var(--border-color, #4a5568);
    
    .dropdown-header {
        background: var(--primary-color, #25D366);
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
    
    .dropdown-items .dropdown-item {
        border-bottom-color: var(--border-color, #4a5568);
        
        &:hover {
            background: var(--hover-bg, #4a5568);
        }
        
        &:active {
            background: var(--active-bg, #2d3748);
        }
        
        .item-text {
            color: var(--text-color, #e2e8f0);
        }
        
        .item-name {
            color: var(--text-muted, #a0aec0);
        }
    }
}

/* Responsive dropdown */
@media (max-width: 575px) {
    .contact-dropdown {
        min-width: 180px;
        max-width: 250px;
        
        .dropdown-header {
            padding: 10px 14px;
            font-size: 0.85rem;
        }
        
        .dropdown-items .dropdown-item {
            padding: 10px 14px;
            gap: 10px;
            
            .item-icon {
                font-size: 1.1rem;
                width: 18px;
            }
            
            .item-name {
                max-width: 100px;
            }
        }
    }
}

@media (max-width: 374px) {
    .contact-dropdown {
        min-width: 160px;
        max-width: 220px;
        
        .dropdown-header {
            padding: 8px 12px;
            font-size: 0.8rem;
        }
        
        .dropdown-items .dropdown-item {
            padding: 8px 12px;
            gap: 8px;
            
            .item-icon {
                font-size: 1rem;
                width: 16px;
            }
            
            .item-name {
                max-width: 80px;
            }
        }
    }
}

/* Web font loading for better emoji support */
@import url('https://fonts.googleapis.com/css2?family=Noto+Color+Emoji:wght@400&display=swap');

/* Emoji picker element custom styles */
emoji-picker {
  --background: var(--card-bg, #fff);
  --border-radius: 12px;
  --box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  --font-family: inherit;
  --category-button-active-bg: var(--primary-color, #25D366);
  --category-button-hover-bg: var(--hover-bg, #f8f9fa);
  --category-button-color: var(--text-color, #333);
  --search-input-bg: var(--input-bg, #f8f9fa);
  --search-input-color: var(--text-color, #333);
  --search-input-border: 1px solid var(--border-color, #e0e0e0);
  --indicator-color: var(--primary-color, #25D366);
  z-index: 1001 !important;
  min-width: 320px;
  max-width: 360px;
  box-shadow: var(--box-shadow);
  border-radius: var(--border-radius);
  font-family: var(--font-family);
  background: var(--background);
  padding: 0;
  border: none;
  /* Ensure it doesn't overflow the chat container */
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 200px);
  overflow: hidden;
  /* Smooth animations */
  transition: all 0.2s ease;
  /* Better positioning */
  position: absolute;
}

emoji-picker::part(search) {
  background: var(--search-input-bg);
  color: var(--search-input-color);
  border: var(--search-input-border);
  border-radius: 8px;
  margin: 12px 16px 8px 16px;
  font-size: 1rem;
  padding: 8px 12px;
}

emoji-picker::part(category-buttons) {
  background: transparent;
  border-bottom: 1px solid var(--border-color, #e0e0e0);
  padding: 0 8px;
}

emoji-picker::part(category-button) {
  border-radius: 8px;
  margin: 0 2px;
  padding: 4px 6px;
  background: transparent;
  color: var(--category-button-color);
  transition: background 0.2s;
}

emoji-picker::part(category-button-active) {
  background: var(--category-button-active-bg);
  color: #fff;
}

emoji-picker::part(category-button):hover {
  background: var(--category-button-hover-bg);
}

emoji-picker::part(emoji) {
  font-size: 1.5rem;
  border-radius: 6px;
  transition: background 0.15s;
}

emoji-picker::part(emoji):hover {
  background: var(--hover-bg, #f0f0f0);
}

emoji-picker::part(indicator) {
  background: var(--indicator-color);
}

emoji-picker {
  outline: none !important;
}

@media (max-width: 575px) {
  emoji-picker {
    min-width: 220px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 150px);
    font-size: 0.95rem;
  }
  emoji-picker::part(search) {
    font-size: 0.95rem;
    margin: 8px 8px 6px 8px;
    padding: 6px 8px;
  }
}

@media (max-width: 374px) {
  emoji-picker {
    min-width: 200px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 120px);
    font-size: 0.9rem;
  }
  emoji-picker::part(search) {
    font-size: 0.9rem;
    margin: 6px 6px 4px 6px;
    padding: 4px 6px;
  }
} 