.floating-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    font-family: inherit;
}

.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--nav-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(143, 171, 143, 0.4);
    transition: all 0.3s ease;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(143, 171, 143, 0.6);
}

.chat-toggle-icon {
    font-size: 28px;
    transition: transform 0.3s ease;
}

.chat-toggle-btn.active .chat-toggle-icon {
    transform: rotate(180deg);
}

.floating-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 360px;
    height: 500px;
    background: var(--surface-card);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-default);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    margin-right: 8px;
}

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

.floating-chat-window.open {
    display: flex;
}

.floating-chat-header {
    padding: 0;
    background: var(--accent-primary);
    color: white;
    display: flex;
    flex-direction: column;
}

.floating-chat-header-top {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.floating-chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

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

.floating-chat-search-container {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.15);
    position: relative;
}

.floating-chat-search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    color: #fff;
    font-size: 14px;
    padding: 8px 16px;
    outline: none;
    transition: all 0.3s ease;
}

.floating-chat-search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.floating-chat-search-input:focus {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.floating-chat-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-top: none;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 10;
}

.floating-search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid var(--border-default);
}

.floating-search-result-item:last-child {
    border-bottom: none;
}

.floating-search-result-item:hover {
    background: var(--surface-elevated);
}

.floating-search-result-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.floating-search-result-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 0;
}

.floating-search-result-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.floating-search-unread-badge {
    background: var(--accent-primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 8px;
}

.floating-search-no-results {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.floating-chat-header-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.floating-chat-header-name:hover {
    opacity: 0.8;
}

.floating-chat-header-status {
    font-size: 12px;
    opacity: 0.9;
}

.floating-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-primary);
}

.floating-message {
    display: flex;
    animation: messageIn 0.3s ease-out;
}

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

.floating-message.own {
    justify-content: flex-end;
}

.floating-message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    white-space: pre-wrap;
    word-break: break-word;
}

.floating-message-bubble.own {
    background: var(--accent-primary);
    color: white;
    border-radius: 16px 16px 4px 16px;
}

.floating-message-bubble.other {
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    border-radius: 16px 16px 16px 4px;
}

.floating-message-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
}

.floating-chat-input-area {
    padding: 16px;
    border-top: 1px solid var(--border-default);
    background: var(--surface-elevated);
    display: flex;
    gap: 8px;
}

.floating-chat-input {
    flex: 1;
    background: var(--bg-primary);
    border: 2px solid var(--border-default);
    border-radius: 24px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    outline: none;
    transition: border-color 0.3s ease;
}

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

.floating-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.floating-chat-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(143, 171, 143, 0.4);
}

.floating-chat-send:active {
    transform: scale(0.95);
}

.unread-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #EF4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid var(--bg-primary);
}

@media (max-width: 768px) {
    .floating-chat-window {
        width: calc(100vw - 32px);
        max-width: 380px;
        height: 480px;
        bottom: 70px;
    }
}

/* Hide chat widget on profile page */
body.profile-page .floating-chat-widget {
    display: none !important;
}

